FED

Edge detection filter


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

Back to top

Description


Performs edge detection filtering on image data. The edge detection filter creates an image where edges (sharp changes in gray-level values) are emphasized.
Back to top

Parameters


fed(file, dbic, dboc, flsz, mask, factor)

Name Type Caption Length Value range
FILE * str Input file name 1 -    
DBIC * List[int] Input raster channel 1 - 1  
DBOC * List[int] Output raster channel 1 - 1  
FLSZ * List[int] Filter size (pixels, lines) 1 - 2 1 - 33
MASK List[int] Area mask 0 - 4 Xoffset, Yoffset, Xsize, Ysize
FACTOR List[float] Gain factor 0 - 1 0.000001 -
Default: 1.0

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the PCIDSK file containing the channels to be filtered.

DBIC

Specifies the input image channel to be filtered.

DBOC

Specifies the output channel to receive the filtered result.

The output channel can be the same as the input channel (DBIC). If an area mask is specified, only the area under the bitmap mask (MASK) is written to the output channel.

FLSZ

Specifies the size of the filter, in units of pixels and lines.

The filter need not be square. For example:
FLSZ	=	i, j

where i and j are odd integers between 1 and 33, inclusively.

If a second values is not specified, it is equal to the first value. The default filter size is 3x3.

MASK

Specifies the window or bitmap that defines the area to be processed within the input raster.

If a single value is specified, that value represents the channel number of the bitmap segment in the input file. Only the pixels under the bitmap are processed; the rest of the image remains unchanged.

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.

If no value is specified, the entire channel is processed.

FACTOR

Specifies a gain multiplication factor to be applied to the input channel.

Values of 0.0 or negative real numbers are not allowed. The default value is 1.0.

Back to top

Details

FED performs edge detection filtering on image data. The edge detection filter creates an image where edges (sharp changes in gray-level values) are emphasized. FED computes the mean of the absolute difference between the gray-level value at the central pixel and at each of its neighbors within the filter window. The dimensions of the filter window must be odd. The minimum filter size is 1 x 3, with a maximum allowable size of 33 x 33. The filter window does not need to be square.

Edge detection filtering produces an image where higher gray-level values indicate the presence of an edge between two objects. The user has the option of applying a factor to each input channel before averaging. A gain factor of 1.0 (default) implies no gain factor.

The MASK parameter specifies the area within the input channel to be processed. Only the area under mask will be filtered; the rest of the image will be unchanged.

If a single mask value is specified, it points to a bitmap segment that defines the area to be filtered. If four values are specified, these define the x,y offsets and x,y dimensions of the rectangular window within the image to be filtered.

If no mask is specified, the entire image is processed by default.

Back to top

Examples

A 5 x 5 edge detection filter is used under bitmap 11 (Urban area) on 8-bit channel 4 (Near Infra-Red), using the file IRVINE.PIX.

from pci.fed import fed

file	=	'irvine.pix'
dbic	=	[4]	# near infra-red channel
dboc	=	[8]	# output channel
flsz	=	[5,5]	# 5x5 edge filter
mask	=	[11]	# bitmap mask
factor	=	[]	# default, 1.0

fed( file, dbic, dboc, flsz, mask, factor )

A 5 x 5 edge detection filter is used under 16-bit signed channel 10, which contains elevation data, using the file IRVINE.PIX. The output channel is equal to the input channel.

from pci.fed import fed

file	=	'irvine.pix'
dbic	=	[10]	# elevation channel
dboc	=	[10]	# overwrite input data
flsz	=	[5,5]	# 5x5 edge filter
mask	=	[]	# process entire image
factor	=	[]	# default, 1.0

fed( file, dbic, dboc, flsz, mask, factor )
Back to top

Algorithm

The edge detection filter computes the mean of the absolute difference between the gray-level value at the central pixel and at each of its neighbors within the filter window.

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

         +---------+
         | a1 a2 a3|
         | a4 CT a5|     <---   Filter window 3 X 3
         | a6 a7 a8|
         +---------+

The edge detection filter finds edge pixel values in the filter window. The filtered pixel is the sum of the absolute differences between the center pixel (CT) and the surrounding pixels in the filter window, divided by the number of pixels surrounding the central pixel (8).

filtered pixel CT = SUM (ABS(CT-a1) +...+ ABS(CT-a8)) / 8
where:

The following is an example of using a 5x5 filter on an 8x8 image, with a gain factor of 1.0:

   Image before filtering           Image after filtering

   8 8  8 9 9 9 7 6 6 6   6 6
   8 8  8 9 9 9 7 6 6 6   6 6
       +----------------+           +----------------+
   8 8 |8 9 9 9 7 6 6 6 | 6 6       |1 2 3 4 4 2 0 0 |
   8 8 |8 9 9 7 6 6 6 6 | 6 6       |2 2 4 4 3 1 0 0 |   
   9 9 |9 8 8 6 6 6 6 6 | 6 6       |3 3 3 4 2 1 0 0 |
   9 9 |9 8 7 7 6 5 6 6 | 6 6       |4 3 3 3 1 3 0 0 |
   7 7 |7 7 7 6 6 6 6 6 | 6 6       |3 3 3 1 1 0 0 0 |
   6 6 |6 6 6 6 6 6 6 6 | 6 6       |2 2 1 1 1 0 0 0 |   
   6 6 |6 6 6 6 6 6 6 5 | 5 5       |1 1 0 0 0 0 0 3 |
   6 6 |6 6 6 6 6 6 6 6 | 6 6       |0 0 0 0 0 0 0 0 |
       +----------------+           +----------------+        
   6 6  6 6 6 6 6 6 6 6   6 6      
   6 6  6 6 6 6 6 6 6 6   6 6

In the "Image before filtering" on the left, columns and scanlines outside the box represent the last image column or scanline being reused, for the case where the filter does not have a full window.

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