CImage:FiltBlockAvg
The FiltBlockAvg method averages neighboring pixels in m x n blocks to increase the signal to noise ratio in return for lower spatial resolution. Also see the related FiltBlockSum method.
bResult = CImage:FiltBlockAvg( ColBlock, RowBlock, pixel_type=nil )
ColBlock is the number, m, of adjacent columns to average.
RowBlock is the number, n, of adjacent rows to average.
pixel_type is an optional pixel 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 ofm 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. If the unblocked image has an integer type and the output type is also an integer type, then 0.29 counts of quantization noise is also added to each super-pixel.
It may be desirable to change the output pixel type to a real number variety such as "float" or "double" to accommodate fractional pixel values. However, the gain in statistical significance is usually small. If the current pixel type is acceptable, then do not specify the optionalpixel_type argument.
Suppose an image is displayed in a CImageView named V. The following script block averages the image to 2x2 super pixels and then redisplays the new image:
|
-- attach the current displayed image |
|
-- average the pixels and convert to 32 bit float. |
|
-- update the display after the scale |
|
-- magnify the image 2x |
Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics,
Inc. All Rights Reserved.