FSHARP

Sharpening filter


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

Back to top

Description


Applies an edge-sharpening filter to image data. This filter improves the detail and contrast of an image.
Back to top

Parameters


fsharp(file, dbic, dboc, flsz, mask, 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 -    
FLSZ List[int] Filter size 0 - 2 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33
Default: 3,3
MASK List[int] Area mask 0 - 4  
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 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.

FLSZ

Optionally specifies the horizontal and vertical dimensions of the filter, in pixel units. Acceptable values are odd integers from 1 to 33, inclusively. The filter need not be square. Minimum filter sizes are 1x3 or 3x1; the default size is 3x3.

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.

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

FSHARP applies an edge-sharpening filter to image data. FSHARP uses a subtractive smoothing method to sharpen an image. An average filter is first applied to the image. The averaged image retains all low spatial-frequency information, but attenuates the high-frequency features, such as edges and lines. Consequently, the averaged image is subtracted from the original and the resulting difference image substantially retains only the edges and lines. When the edges are determined in this manner, the difference image is returned to the original to provide an edge-enhanced image. The resulting image has a clearer high-frequency detail, although there is a tendency for enhanced noise.

The dimensions of the filter window (FLSZ) must be odd. The minimum filter size is 1x3 and the maximum allowed filter size is 1001x1001. The filter window need not be square.

The input channel (DBIC) can be the same as the output channel (DBOC). For 8-bit channels, if the result is less than zero, it is truncated to zero. If the result is more than 255, it is truncated to 255.

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

Examples

A bitmap that delineates urban land use is stored in segment 11 of the file 'irvine.pix'. Apply a 3x3 sharpening window to the urban features of channel 4 and save the filtered result in channel 8.

from pci.fsharp import fsharp

file	=	'irvine.pix'	# input file
dbic	=	[4]	# channel to filter
dboc	=	[8]	# output channel
flsz	=	[]	# default, 3x3 filter
mask	=	[11]	# process area under bitmap 11
bgzero	=	''	# default, YES

fsharp( file, dbic, dboc, flsz, mask, bgzero )

Sharpen the 16-bit elevation data stored in channel 10 in irvine.pix using a 5x5 square filter. Save the filtered result over the original input data.

from pci.fsharp import fsharp

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

fsharp( file, dbic, dboc, flsz, mask, bgzero )

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