Question

So, I have to implement an algorithm of Constant False Alarm Rate(CFAR). It kind of works like this: BackgroundWindow

I am using the notion that, in case that the target window contains more than one pixels, this operator (CFAR) uses the following detection criterion

Equation2

where μt is the mean value of pixels in the target window. In this case, t should be replaced by t√n (where n is the number of pixels in the target window) in the PFA calculation, and where μb is the background mean, σb is the background standard deviation and t is a detector design parameter which is computed from PFA by the following equation:

Equation3

Now, (enough with the equations already! XD), I know that I have to implement some loops over an image (which is a 2d matrix). I know the pixel to distance ratio for my image (which is 10.054m per pixel in both directions approximately). I can translate the distance entered by user into pixel sizes, suppose the background window is 800m (roughly 80 pixel), the guard window is 400m (roughly 40 pixel), while the target window is given to be 20m (roughly 2 pixel). My question is:

How to loop over the image?

The problem is not as easy as it seems, atleast not to me. You see, I can't figure out, for mxn pixels, how to implement the moving window. At first I thought that the target size would be fixed, and I could hardcode my pixel coordinates, but that is not the point. Any help is appreciated :)

EDIT: The Target window moves inside the guard window. After this has finished, the guard window will move inside the background window, where the above will again take place, then finally the background window will move across the whole image!

Was it helpful?

Solution

Assuming that the windows progress from left to right and then top to bottom, the pseudo code may be as follow:

consider four attributes of each window, namely, bg_top, bg_left, bg_width, bg_hight, grd_top... etc.

also considering a inner window will never go outside crossing the outer window,

set all windows left and top to image's left and top, that may be (0,0).

now the loop

while(bg_top+bg_hight <= image_top+image_hight)
{
    while(bg_laft+bg_width <= image_left+image_width)
    {
        while(grd_top+gdr_hight <= bg_top+bg_hight) 
        {   
            while(grd_left+gdr_width <= bg_left+bg_width)
            //some pixels may be left out if the inner and outer window sizes are not divisible, it will not change the window size to fit in the last case.
            {
                 while(target_top+target_hight <= grd_top+grd_hight)
                 {
                      while(target_left+target_width <= grd_left+grd_width)
                      // the condition will move till end but never goes outside nor changes the inner window size to fit
                      {
                          //DO THE PROCESSING
                          //target_left+=target_width; //if they do not overlap
                          target_left+=1; //if they overlap
                      }
                      target_top+=target_hight// don't overlap. use 1 for overlaping
                      // use 1 if it goes down 1 pixel
                 }
                 grd_left+=grd_width; //or 1
            }
            grd_top+=grd_hight; //or 1
         }
         bg_left+=bg_width; //or 1
     }
     bg_top+=bg_hight; //or 1
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top