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.

Syntax

bResult = CImage:FiltBlockAvg( ColBlock, RowBlock, pixel_type=nil )

Remarks

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.

Example

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:

I = V:GetImage()

-- attach the current displayed image

I:FileBlockAvg(2,2,"float")

-- average the pixels and convert to 32 bit float.

V:Update()

-- update the display after the scale

V:SetZoom(2)

-- magnify the image 2x

Related Topics

CImage class, FiltBlockSum


Mira Pro x64 Script User's Guide, Copyright Ⓒ 2023 Mirametrics, Inc. All Rights Reserved.