FMO

Mode filter


EnvironmentsPYTHON :: EASI :: MODELER
Batch ModeYes
Quick linksDescription :: Parameters :: Parameter descriptions :: Details :: 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 Length Value range
Input: Input raster channels * Raster port 1 - 1024  
Output: Output raster channels * Raster port 1 - 1024  
Filter X Size Integer 0 - 2 1 -
Default: 3
Filter Y Size Integer 0 - 2 1 -
Default: 3
Mask: Area mask Bitmap port 0 - 4
Port Settings: Resample mode Raster port 1 - 1024 Nearest | Bilinear | Cubic
Default: Nearest
Thin Line Preservation String 0 - 1 ON | OFF
Default: ON
Exclude Values List Float 0 - 16 0.0 -
Background Set To Zero String 0 - 1 YES | NO
Default: YES

* Required parameter
Back to top

Parameter descriptions

Input: Input raster channels

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

Output: Output raster channels

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).

Filter X Size

Specifies the width of the filter, in pixels, used for resampling.

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

Filter Y Size

Specifies the height of the filter, in pixels, used for resampling.

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

Mask: Area mask

Optionally specifies the bitmap that defines the area to be processed within the input raster. If this parameter is not specified, the entire layer is used by default.

To define a bitmap mask, you must specify the bitmap segment that you want to use. All of the pixels within the specified segment, having a pixel value of 1, define the area to be processed.

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.

Port Settings: Resample mode

Specifies the type of image resampling desired.

Supported methods include:

Thin Line Preservation

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.

Exclude Values List

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.

Background Set To Zero

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

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

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.