FGA

Gaussian filter


EnvironmentsPYTHON :: EASI :: MODELER
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: Example :: Algorithm :: Acknowledgements :: Related

Back to top

Description


FGA performs Gaussian filtering on image data. This program can be used as a low-pass filter to blur the image if only one Gaussian filter parameter, SigmLow, is specified. It can also be used as a band-pass filter to detect sudden intensity change in the image, if both SigmLow and SigmHigh parameters are specified.
Back to top

Parameters


fga(file, dbic, dboc, sigmsq, mask, bgrange, failvalu, bgzero)

Name Type Caption Length Value range
FILE * str Input file name 1 -    
DBIC * List[int] Input raster channels 1 -    
DBOC * List[int] Output filtered image channels 1 -    
SIGMSQ * List[float] Square of Gaussian filter parameter 1 - 2 1.0 - 32.0
MASK List[int] Area mask 0 - 4
BGRANGE List[float] Background value range 0 - 2  
FAILVALU List[float] Failure value 0 - 1  
BGZERO str Set background to zero 0 - 3 YES | NO
Default: YES

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the GDB-supported input file that contains the channels to filter.

DBIC

Specifies the input channels to filter.

DBOC

Specifies the output channels to receive the filtered result.

The output channels (DBOC) can be the same as the input channels (DBIC). If a mask is specified, only the area under the mask is written to the output channel.

If two Gaussian filter parameter (SIGMSQ) values are specified and the output channel is an 8-bit or 16-bit unsigned integer channel, the output contains absolute values.

SIGMSQ

Specifies the low-pass filter cutoff value and, optionally, the high-pass cutoff value obtained by the square of Gaussian distribution deviation.

This parameter must be in the range of 1.0 to 32.0. If both values are specified, the first and second square Gaussian distribution values must be different; otherwise, the kernel for low-pass and band-pass filters are identical and the result will be 0.0.

MASK

Optionally specifies the window or bitmap that defines the area to be processed within the input raster. If this parameter is not specified, the entire channel is processed.

If a single value is specified, that value represents the segment number of the bitmap in the input file. All the pixels within the specified segment, having a pixel value of 1, define the area to be processed.

If four values are specified, they define the X,Y offsets and X,Y dimensions of a rectangular window identifying the area to process. Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height.

Only the area under the mask is written to the output. Pixels that are outside the mask but within the filter size window will be used to determine the output pixel values.

BGRANGE

Specifies the range of background values. If this parameter is not specified, no background value is used. If two values are specified, those values define the maximum and minimum range, respectively.

FAILVALU

Specifies the failure value; this value is not used in the calculation.

BGZERO

Specifies how the background pixels are processed. Background pixels can be identified as not being covered by a mask or background range you specify. If neither a mask nor a background range are specified, BGZERO is ignored. By default, background pixels will be set to the NoData of the output channel, or zero when NoData is not defined. Alternatively, by specifying BGZERO=NO, the background pixels will not be altered in the output and the value of the pixels prior to processing is retained.

Back to top

Details

FGA performs Gaussian filtering on image data.

FGA accepts one or two SIGMSQ values. SIGMSQ is the square of the Gaussian distribution deviation. The SIGMSQ value must be in a range of 1.0 to 32.0.

If only one Gaussian filter parameter is specified, FGA is used as a low-pass filter to blur the image. The function computes the weighted sum of the gray-level values in a square filter window that surrounds each pixel. The weights are the results of the Gaussian function with the specified deviation. The filter window is a square of size 2*SIGMSQ + 1.

If both Gaussian filter parameters are specified, this function is used as a band-pass filter to detect any sudden intensity change in the image. The resulting image is the difference of the image produced by SIGMSQ(2) subtracted from the image produced by SIGMSQ(1). The filter window size is 2*n + 1, where n is the larger value of SIGMSQ(1) and SIGMSQ(2).

The background values are specified with the BGRANGE range parameter. If BGRANGE has only one value, the maximum and minimum values are the same.

The MASK parameter specifies the area in the input channel that is processed. If no mask is specified, the entire image is processed by default.

The output channel (DBOC) can be the same as the input channel (DBIC). If FGA is a band-pass filter, the results are both positive and negative; if the output channel is an 8-bit or 16-bit unsigned integer channel, , however, FGA generates only the absolute value of the results.

Back to top

Example

A Gaussian filter with SIGMSQ=2 is used under bitmap 11 (urban areas) on the 8-bit database channel 4 (near infra-red) in the input file 'irvine.pix'.

from pci.fga import fga

file	=	'irvine.pix'
dbic	=	[4]
dboc	=	[8]
sigmsq	=	[2.0]
mask	=	[11]
bgrange	=	[]
failvalu	=	[0.0]
bgzero	=	''

fga( file, dbic, dboc, sigmsq, mask, bgrange, failvalu, bgzero )
Back to top

Algorithm

FGA uses the following Gaussian function to compute the filter weights:

G(i,j) = exp( -((i-u)**2 + (j-v)**2)/(2 * sigma**2) )
  
where:

The filter weights W(i,j) are the normalized values of G(i,j) over the entire filter window, hence the sum of all weights is 1.

The gray level of a filtered pixel is the sum of W(i,j)*V(i,j) over all pixels in the filter window, where V(i,j) is the original value at location (i,j).

All pixels in the image are filtered by FGA. To filter pixels located near edges of the image, FGA replicates edge pixel values to provide sufficient data.

Back to top

Acknowledgements

This program was developed with the assistance of the Institute for Space and Terrestrial Science (ISTS) at the University of Waterloo, Ontario, Canada.

© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.