This describes the BB finding algorithm and precise measurement of the BB's location.
The first step is to determine the BB's approximate location within the EPID plane. This is done by restricting the search area to a square centered in the image. The size of the square is 2 x BBbyEPIDSearchDistance_mm, where BBbyEPIDSearchDistance_mm is a configuration value. The size of the square is smaller than the cube containing the BB, as shown by the yellow box below.
The square is searched by examining each possible array of 2x2 pixels to see which is the brightest. Next, the brightest adjacent pixels are included until an area has been acquired that is equivalent to the area of the BB.
The image below shows a close up image with pixel values contrasted for clarity. The pixels of the BB are identified and marked as green.
The center of mass (which includes the pixels' location and brightness) of the BB's pixels is calculated in X and Y to determine the BB's precise location.
For the BB's location to be valid, it must be significantly brighter than the surrounding pixels. For validation, the standard deviation and mean of the pixels in the search area that are not included by the BB is calculated. A BB standard deviation multiple is calculated by:
$SearchArea_{mean}$ : Mean value of pixels inside the search area but not part of the BB
$BB_{mean}$ : Mean value of BB's pixels (shown in green)
$SearchArea_{StandardDeviation}$ : Standard deviation of pixels in search area but not part of BB
$$absoluteValueOf(BB_{mean} - SearchArea_{mean}) / SearchArea_{StandardDeviation} $$
If this value is large enough, then the BB is considered valid. The configuration value EPIDBBMinimumStandardDeviation is used for the comparison.