EDGE

Edge Detection Filter


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

Back to top

Description


EDGE applies an edge detection filter for image data. The output is an image showing the magnitude of edge pixels. An optional gradient direction image can also be created.
Back to top

Parameters


edge(fili, filo, dbic, dboc_mag, dboc_dir, need_dir, radius)

Name Type Caption Length Value range
FILI * str Input file name 1 -    
FILO str 0 0 -    
DBIC * List[int] Input raster channel 1 -    
DBOC_MAG List[int] Gradient magnitude output channel 0 -   1 -
DBOC_DIR List[int] Gradient direction output channel 0 -   1 -
NEED_DIR str Create gradient direction channels 0 - 3 YES | NO
Default: YES
RADIUS List[int] Filter radius (pixels) 0 - 1 1 -
Default: 5

* Required parameter
Back to top

Parameter descriptions

FILI

Specifies the name of the image file that contains raster channels to filter.

FILO

Specifies the name of the image file to receive the output channels. If this parameter is not specified, it is assumed to be the same as FILI. If the specified output file exists, it must have the same projection as FILI.

If the specified output file does not exist, a new PCIDSK file will be created. By default, the georeferencing information from the input file will be copied to the new output file.

DBIC

Contains the input unfiltered channel(s).

DBOC_MAG

Specifies the output channel(s) to receive the output magnitude channel(s).

If the output file (FILO) is an existing file, the output magnitude channel (DBOC_MAG) type must be CHN_8U and the number of output channels must be the same as the number of input channels (DBIC). If the output file is created, this parameter is ignored.

DBOC_DIR

Specifies the output channel(s) to receive the output gradient direction channel(s).

If the output file (FILO) is an existing file, the output gradient direction channel (DBOC_DIR) type must be CHN_8U and the number of output channels must be the same as the number of input channels (DBIC). If the output file is created, this parameter is ignored.

NEED_DIR

Specifies whether to create gradient direction channels in the output file.

Supported options are:

RADIUS

Specifies the size of the Gaussian filter's radius, in pixels. The filter is applied as the first step of edge detection. The filter size determines the smallest feature to be detected. The default value is 5.

Back to top

Details

EDGE applies a Canny Edge Detector filter. This process produces an output image where higher gray-level values indicate the presence of an edge between two objects. An optional gradient direction image can also be created.

For more information about the method used, see the Algorithm section.

Back to top

Example

This example demonstrates the use of EDGE.

from pci.edge import edge

fili	=	"irvine.pix"	# input file
filo	=	"output.pix"	# create new output file
dbic	=	list(range(1,6))	# input channel list
dboc_mag	=	list(range(6,11))	# gradient magnitude output channels
dboc_dir	=	list(range(11,17))	# gradient direction output channels
need_dir	=	''
radius	=	[]	# filter radius, defaults to 5

edge( fili, filo, dbic, dboc_mag, dboc_dir, need_dir, radius )
        
Back to top

Algorithm

Canny edge detection consists of the following steps:
  1. Apply a Gaussian filter to the input image.
  2. Compute X, Y gradients of the filtered image.
  3. Suppress pixels for which the gradient is non-maximum along the gradient direction. The output is an image of gradient magnitude at those pixels for which the gradient is maximum.

In the PCI implementation, the Gaussian filter and gradient operator are decomposed into two 1-dimensional filters: a 1D Gaussian filter and a 1D DOG (difference of Gaussian) filter. One of these two 1D filters is applied to rows; the other is applied to the columns. The choice of which one to apply to the rows/columns provides either the X gradient or Y gradient.

When the gradients are computed, the magnitude at each pixel is compared to those of its neighbors. Along the gradient direction, if the gradients of neighbor pixels (computed via interpolation) are larger then the gradient of the current pixel (thus it is non-maximum), the gradient of the current pixel is suppressed (set to zero).

The output gradient magnitude represents edge strength. The output is scaled based on the dynamic range of the input image.

An optional output of gradient direction image can be created. Each pixel is in the range of [0,255], scaled from [0, 2*PI].

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