embadpixfind estimates an upper limit to the local statistical average from the median + 1 (1 is added to take care of the case when the median is 0). Then it builds a map of local excesses in units of the local statistical dispersion (Poisson regime) by subtracting the estimated average and dividing by its square root. This map of local excesses is then used to locate the most promising candidate bad pixels. They are examined in turn, in decreasing order. The local statistical average or median+1 (whichever is smaller) is recomputed ignoring the candidate bad pixel. From the Poisson distribution at that value is deduced the threshold in counts corresponding to probathreshold divided by the number of pixels in the window used for median filtering (normally 24). If the local count number is larger than that threshold, the pixel is flagged as bright, the median is recomputed around the bad pixel ignoring it, and the loop goes on. If the local count number is smaller than the threshold then the loop stops.
In a second step (if findbadsegments=Y) embadpixfind
looks for too bright rows and columns. This is done by projecting
the image along rows and columns, and applying the same algorithm
as above on the resulting 1-D vectors.
If a bright row or column is found, it is analysed to look for bright segments within. If it is found that the rest of the row/column is compatible (to 10% probability) with the neighboring rows/columns, then only the bright segments are declared as bad. The minimum length of the bright segments is set such that one expects about 1 count in that length in the normal (not bright) parts.