FMO

Mode filter


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

Back to top

Description


FMO performs mode filtering on image data. The mode filter is used primarily to clean thematic maps for presentation purposes.
Back to top

Parameters


Name Type Caption Length Value range
FILE * String Input file name 1 - 192  
DBIC * Integer Input raster channels 1 -    
DBOC * Integer Output raster channels 1 -    
FLSZ Integer Filter size (pixels) 0 - 2 1 -
Default: 3,3
MASK Integer Area mask 0 - 4
THINLINE String Thin line preservation 0 - 3 ON | OFF
Default: ON
KEEPVALU Float Values excluded from filtering 0 - 16 0.0 -
BGZERO String Set background to zero 0 - 3 YES | NO
Default: YES
MONITOR String Monitor mode 0 - 3 ON, OFF
Default: ON

* Required parameter
Back to top

Parameter descriptions

FILE

Specifies the name of the PCIDSK file that contains the channels to filter.

DBIC

Specifies the channels or layers in the input file to be filtered.

DBOC

Specifies the output channels or layers to receive the filtered results. Only the area under a mask is processed.

The output channels (DBOC) may be the same as the input channels (DBIC).

FLSZ

Specifies the size of the filter, in pixels, used for resampling by using a moving filter window.

The default filter size is 3x3. The filter need not be square.

Specify FLSZ as:

            FLSZ = i, j
          

where i and j are odd integers.

If j is not specified, j = i.

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.

THINLINE

Specifies whether a thin line preservation is applied to the data.

If this parameter is specified, a mode filter is applied to a pixel only if the number of occurrences of the center pixel value in the 3x3 window surrounding it is less than 3.

This parameter can be set to ON for a 3x3 filter window only, which ensures that thin classes (such as streams or roads) are not removed when cleaning up thematic images.

KEEPVALU

Specifies up to 16 pixel values (classes) that are not filtered. Although these classes are not replaced in the filtering process, other pixels can assume these values as a result of filtering.

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.

MONITOR

The program progress can be monitored by printing the percentage of processing completed. A system parameter, MONITOR, controls this activity.

Available options are:

Back to top

Details

FMO performs mode filtering on image data. The mode filter is used primarily to clean thematic maps for presentation purposes.

FMO progress may be monitored.

The mode filter computes the mode of the gray-level values (the most frequently occurring gray-level value) in the filter window that surrounds each pixel. Mode filtering is ideal for cleaning thematic maps for presentation purposes because it replaces small 'island' themes with larger surrounding themes. The minimum filter size is 1x3. The filter window need not be square. The input channel (DBIC) can be the same as the output channel (DBOC).

If the thin line preservation flag (THINLINE) is used, a mode filter is applied to a pixel only if the number of occurrences of the center pixel value in the 3x3 window that surrounds it is less than 3. THINLINE can be set to ON only for a 3x3 filter window. This ensures that thin classes (such as streams or roads) are not removed when cleaning thematic maps.

The KEEPVALU (Exclude Values List) parameter specifies up to 16 values (classes) that are not filtered. This is useful for preserving specified classes.

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

Use a 3x3 mode filter under bitmap 11 (Urban area) on the 8-bit database channel 7 (supervised classification results) using irvine.pix.

EASI>FILE		=	"IRVINE.PIX"
EASI>DBIC		=	7		! Filters channel 7
EASI>DBOC		=	7
EASI>FLSZ		=	3,3		! Specifies a 3x3 filter size
EASI>MASK		=	11		! Processes only the area under the
								! bitmap stored in segment 11
EASI>THINLINE	=	"ON"	! Preserves thin lines
EASI>KEEPVALU	=
EASI>BGZERO		=	"YES"	! Sets background value to 0

EASI>RUN FMO
      

Apply a 5x5 mode filter to a whole channel using irvine.pix.

EASI>FILE		=	"IRVINE.PIX"
EASI>DBIC		=	7		! Filters channel 7
EASI>DBOC		=	8
EASI>FLSZ		=	5,5		! Specifies a 5x5 filter size
EASI>MASK		=			! Processes the entire database
EASI>THINLINE	=	"OFF"	! Does not preserve thin lines
EASI>KEEPVALU	=
EASI>BGZERO		=

EASI>RUN FMO

      
Back to top

Algorithm

The implementation of the mode filter consists of computing the mode of the gray-level values (the most frequently occurring gray-level value) in the square or rectangular filter window that surrounds each pixel.

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


        +---------+
        | 5  3  3 |
        | 3  5  3 |     <-- A 3x3 filter window
        | 3  4  5 |
        +---------+

      

When THINLINE = "OFF", the output pixel is equal to the most-frequently occurring value in the filter window.

For example:

        THINLINE = "OFF"
      

The filtered pixel of the filter window (3,3,3,3,3,4,5,5,5) is set to 3, which occurs five times.

When THINLINE = "ON" , in order to preserve thin lines in the image, the central pixel is filtered only if the gray-level value of the central pixel occurs less than three times in the 3x3 filter window.

For example:

        THINLINE = "ON"
      

The filtered pixel of the filter window (3,3,3,3,3,4,5,5,5) is set to 5 because the central pixel 5 occurs three times.

The following example shows a 5x5 filter applied to an 8x8 database image. THINLINE="OFF".


        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       |8 9 9 6 6 6 6 6 |
        8 8 |8 9 9 7 6 6 6 6 | 6 6       |8 9 9 6 6 6 6 6 |
        9 9 |9 8 8 6 6 6 6 6 | 6 6       |9 7 7 6 6 6 6 6 |
        9 9 |9 8 7 7 6 5 6 6 | 6 6       |9 7 6 6 6 6 6 6 |
        7 7 |7 7 7 6 6 6 6 6 | 6 6       |6 6 6 6 6 6 6 6 |
        6 6 |6 6 6 6 6 6 6 6 | 6 6       |6 6 6 6 6 6 6 6 |
        6 6 |6 6 6 6 6 6 6 5 | 5 5       |6 6 6 6 6 6 6 6 |
        6 6 |6 6 6 6 6 6 6 6 | 6 6       |6 6 6 6 6 6 6 6 |
        +----------------+           +----------------+
        6 6  6 6 6 6 6 6 6 6   6 6
        6 6  6 6 6 6 6 6 6 6   6 6

      

If the filter does not specify a full window (see the image before filtering on the left), columns and scanlines outside the box represent the last image column or scanline that is reused.

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