FME -- Median Filter (up to 7x7)

Performs MEDIAN filtering on image data. The median filter smooths image data, while preserving sharp edges.

Progress of this program can be monitored. See MONITOR section.

See Also: FAV, FED, FGA, FMO, FPR, FAD, FLE, FSOBEL, FPRE, FSHARP

PARAMETERS

FME is controlled by the following global parameters:

Name     Prompt                                  Count     Type
FILE     Database File Name                      1-64      Char
DBIC     Database Input Channel List             1         Int
DBOC     Database Output Channel List            1         Int
FLSZ     Filter Size: Pixels, Lines              1-2       Int
MASK     Area Mask (Window or Bitmap)            0-4       Int

FILE

Specifies the name of the PCIDSK file containing channels to be filtered.

 EASI>FILE="filespec"

DBIC

Specifies the input channel to be filtered.

 EASI>DBIC=i

DBOC

Specifies the output channel for the filtered result.

 EASI>DBOC=j

FLSZ

Specifies the filter size in units of pixels and lines:

 EASI>FLSZ=i,j

MASK

Specifies the area in the input channel which should be processed. This can be one of the following:

 EASI> MASK =                       | process entire channel

 EASI> MASK = xoff,yoff,xsize,ysize | process window

 EASI> MASK = b                     | process only under bitmap
                                    | stored in segment b

MONITOR

Program progress can be monitored by printing the percentage of completed processing in odometer fashion. A system parameter, MONITOR, controls this activity:

 EASI>MONITOR="ON"           | turn monitor ON  (default)
 EASI>MONITOR="OFF"          | turn monitor OFF (recommended if
                             | running in batch/background mode)

DETAILS

The median filter computes the median value of the grey-level values within a rectangular filter window surrounding 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 1 by 3, and the maximum filter size allowed is 7 by 7. The filter window does not need to be square. The input channel(DBIC) can be the same as the output channel (DBOC).

The MASK parameter specifies the area within the input channel which will be processed. Only the area under the mask will be filtered and the rest of the image will be unchanged. If a single value is specified, then this value points to a bitmap segment, which defines the area to be filtered. When four values are specified, these values define the x,y offsets and x,y dimensions of the rectangular window within the image to be filtered. If MASK is defaulted, the entire database is processed.

ALGORITHM

The implementation of median filter consists of computing the median of the grey-level values within the square or rectangular filter window surrounding each pixel.

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

         +--------+
         | 5 3 11 |
         |12 4  9 |     <---    Filter window 3 X 3
         | 8 6 14 |
         +--------+
The median filter finds the median pixel value ( the "middle" value in an ordered set of values, below and above which there is an equal number of values). For example 8 is the median value for given set of values: (3,4,5,6,(8),9,11,12,14).

Example of using 5x5 median filter on 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 being reused, for cases where the filter does not have a full window.

EXAMPLE

A 5 by 5 median filter is used under bitmap 11 (Urban area) on 8-bit database channel 4 (Near Infra-Red) using IRVINE.PIX file. Only the area under bitmap is filtered and transferred to the output channel.

 EASI>FILE = "IRVINE.PIX"
 EASI>DBIC = 4                  | Near IR
 EASI>DBOC = 8                  | Working area
 EASI>FLSZ = 5,5                | Filter 5x5
 EASI>MASK = 11                 | Bitmap 11
 EASI>RUN FME
A 5 by 5 median filter is used under 16-bit sign database channels 10 (which contains elevation data), using IRVINE.PIX file. The output channel equals the input channel.

 EASI>FILE = "IRVINE.PIX"
 EASI>DBIC = 10                 | Elevation data
 EASI>DBOC = 10                 
 EASI>FLSZ = 5,5                | Filter 5x5
 EASI>MASK =                    | Entire database
 EASI>RUN FME

About PCI Help Gateway