The goals of this project are as follows:
First the number of training cells, guard cells are set to an initial value. Then a sliing window algorithm is implemented where the cell under test goes across the complete matrix. The CUT always has margin for training and guard cells from the edges. That creates a small frame around the edges where the process is not applied. That region is set to zero independently (next step). Every iteration sums the signal level within all the training cells, by converting the value from logarithmic to linear using db2pow function. An average of the sum for all of the training cells used is calculated. After averaging it is converted back to logarithmic using pow2db, and an offset is add to the threshold. Each signal value is compared the threshold, and if the greater than threshold the cell is assigned a value of 1. Otherwise cells are set to 0.
Training and guard cells were selected so to provide a good background determination minimizing the processing time. The offset was decided based on a dry run without CFAR and noting what the level of noise seemed to start to cut some of the noise out.
The process above generates a thresholded block, which is smaller than the Range Doppler Map as the cut or noise cannot be located at the edges of the matrix describing the data. A ew cells will not be processed properly and so in order to keep the map size same I set all values at the edge to 0.