FSOBEL

Sobel edge filter


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

Back to top

Description


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

Parameters


fsobel(file, dbic, dboc, mask, factor, 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 -    
MASK List[int] Area mask 0 - 4
FACTOR List[float] Gain factor 0 - 1 Default: 1.0
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 PCIDSK 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 channels.

For more accurate results, it is recommended that the output channels be 32-bit real channels. If an 8-bit channel is used, all generated values greater than 255 are truncated to 255.

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.

FACTOR

Specifies the gain factor applied to the filtered input channel. The default value is 1.0.

Values of 0.0 or negative real numbers are not allowed.

BGZERO

Specifies how the background pixels are processed. Background pixels can be identified as not being covered by a mask you specify. If no mask is 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

FSOBEL performs Sobel edge detector filtering on image data.

Sobel edge detection produces an image where higher gray-level values indicate the presence of an edge between two objects. The Sobel edge detector filter computes the root mean square of two 3x3 templates. For more details about the filter, see the Algorithm section.

The input channel (DBIC) can be the same as the output channel (DBOC). You can apply a gain factor (FACTOR) to each filtered input channel before averaging. A factor of 1.0 (the default) implies no gain.

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.

Back to top

Example

Using the irvine.pix demonstration file, calculate the Sobel edge detection gradient.

from pci.fsobel import fsobel

file	=	'irvine.pix'	# input file
dbic	=	[1]	# channel to filter
dboc	=	[8]	# output channel
mask	=	[11]	# process area under bitmap 11
factor	=	[1.0]	# gain factor
bgzero	=	''	# default, YES

fsobel( file, dbic, dboc, mask, factor, bgzero )
Back to top

Algorithm

The Sobel edge detection filter uses the two 3x3 templates to calculate the gradient value.

-1   0   1           1   2   1
-2   0   2           0   0   0
-1   0   1          -1  -2  -1

     X                   Y

Consider the following 3x3 image window:

+---------+
| a1 a2 a3|
| a4 a5 a6|     <---  3x3 filter window
| a7 a8 a9|
+---------+
where:

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

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