CImage:FiltBlockAvg


The FiltBlockAvg method averages neighboring pixels in blocks of m x n to make a smaller image having better signal to noise ratio in each pixel.

Syntax

bSuccess = CImage:FiltBlockAvg( ColBlock, RowBlock )

bSuccess = CImage:FiltBlockAvg( ColBlock, RowBlock, datatype )

where

    ColBlock is the number, m, of adjacent columns to average.

    RowBlock is the number, n, of adjacent rows to average.

    datatype is the data type for the output image, defaults to "same" if not specified.

    bSuccess is the returned success code. On success it is true, otherwise 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 data 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 data type is acceptable, then do not specify the optionaldatatype 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

FiltBlockSum

CImage class