CImage:FiltEllipse CImage:FiltRect

CImage:FiltGaussian


The FiltGaussian method smooths an image by applying a filter kernel having Gaussian weights in an elliptical shape. The filter can be rotated.

Syntax

bResult = CImage:FiltGaussian( sigma, ratio, angle, CRect=nil )

    sigma is the kernel major axis length, in pixels.

    ratio is ratio of minor to major axes, which is 1.0 or less.

    angle is the rotation angle in degrees.

    CRect is the rectangle defining the area to process. If omitted, it defaults to nil and the entire image is processed.

    On success, this method returns true.

    On failure, this method returns false.

Remarks

This method smooths the image using an elliptical shaped filter kernel having Gaussian weights. By comparison, FiltEllipse uses an elliptical shape with equal weights.

This filter is specified in terms of its major axis. Be wary of the apparent small size of the filter based on its sigma value. The filter extends to 2.5 x sigma along the semi-major axis. Therefore specifying sigma=3 produces a filter kernel 2 x 3 x 2.5 = 15 pixels wide. Note that the processing time increases in proportion to the product filter width x filter height; processing a 15x15 kernel takes 9 times longer than processing a 5x5 kernel.

Example

Suppose an image is displayed in a CImageView named V. The following script fragment smooths the region [100:300, 400:800] using a 10x5 Gaussian filter rotated 45 degrees:

I = V:GetImage()

-- attach the current displayed image

R = CRect:new(100,300,400,800)

-- setup the rectangle to process

I:FiltGaussian(10,0.5,45,R)

-- apply the filter

V:Update()

-- update the display after the scale

R:delete()

-- done with the CRect

Related Topics

CImage, FiltEllipse, FiltBinomial, FiltRect