CImage:FiltBlockSum
The FiltBlockSum method sums neighboring pixels in blocks of m x n to make a smaller image having higher signal level and higher signal to noise ratio in each pixel.
bResult = CImage:FiltBlockSum( ColBlock, RowBlock, datatype=nil ) ColBlock is the number, m, of adjacent columns to sum. RowBlock is the number, n, of adjacent rows to sum. datatype is an optional data type for the output image, defaults to "same" if not specified. On success, this method returns true. On failure, this method returns false. |
This method increases the signal to noise ratio by sqrt(mn) for using blocking factors of m and n. This approximates the effect of using a binning mode during image acquisition except that each blocked pixel will have m x n units of readout noise in its total noise budget whereas a binned pixel of the same blocking factor will have 1 unit of readout noise in its total noise budget.
Usually the output data type should be enlarged to handle the higher pixel values in the summed image. For example, if the data are 16 bit integer type, then the output data type should at least be "long" to handle the m x n increase in signal level of each pixel.
Suppose an image is displayed in a CImageView named V. The following script fragment block sums the image to 2x2 super pixels and then redisplays the new image:
I = V:GetImage() |
-- attach the current displayed image |
I:FiltBlockSum(2,2,"long") |
-- average the pixels and convert to 32 bit integer. |
V:Update() |
-- update the display after the scale |
V:SetZoom(2) |
-- magnify the image 2x |