FME

Median filter


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

Back to top

Description


FME performs median filtering on image data. The median filter smoothes image data, while preserving sharp edges.
Back to top

Parameters


Name Type Length Value range
Input: Input raster channels * Raster port 1 - 1024  
Output: Output filtered image channel * Raster port 1 - 1024  
Filter X Size Integer 0 - 1 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33
Default: 3
Filter Y Size Integer 0 - 1 1 | 3 | 5 | 7 | 9 | 11 | 13 | 15 | 17 | 19 | 21 | 23 | 25 | 27 | 29 | 31 | 33
Default: 3
Mask: Area mask Bitmap port 0 - 4
Port Settings: Resample mode Raster port 1 - 1024 Nearest | Bilinear | Cubic
Default: Nearest

* Required parameter
Back to top

Parameter descriptions

Input: Input raster channels

Specifies the input channels to filter.

Output: Output filtered image channel

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.

Filter X Size

Optionally specifies the horizontal size of the filter, in pixel units. This value must be an odd integer between 1 and 33. The default value is 3 pixels.

Filter Y Size

Optionally specifies the vertical size of the filter, in pixel units. This value must be an odd integer between 1 and 33. The default value is 3 pixels.

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:
Back to top

Details

The median filter computes the median value of the gray-level values within a rectangular filter window that surrounds each pixel. This has the effect of smoothing the image and preserving edges. The dimensions of the filter window (FLSZ) must be odd. The minimum filter size is 1x3 and the maximum allowed filter size is 33x33. The filter window need not be square. The input channel (DBIC) can be the same as the output channel (DBOC).

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 a median filter consists of computing the average of the gray-level values in a square or rectangular filter window that surrounds each pixel.

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

         +--------+
         | 5 3 11 |
         |12 4  9 |     <---    A 3x3 filter window.
         | 8 6 14 |
         +--------+

The median filter finds the 'middle' pixel value in an ordered set of values, below and above, where there is an equal number of values. For example, 8 is the median value for the following set of values: 3,4,5,6,(8),9,11,12,14.

The following example shows a 5x5 median filter used on an 8x8 pixel database.

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

In the image before filtering on the left, columns and scanlines outside the box represent the last image column or scanline that is reused where the filter does not have a full window.

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