Common Pipeline Library Reference Manual  6.1.1
Typedefs | Enumerations
Filters

Typedefs

typedef enum _cpl_border_mode_ cpl_border_mode
 The border mode type.
typedef enum _cpl_filter_mode_ cpl_filter_mode
 The filter mode type.

Enumerations

enum  _cpl_border_mode_ {
  CPL_BORDER_FILTER,
  CPL_BORDER_ZERO,
  CPL_BORDER_CROP,
  CPL_BORDER_NOP,
  CPL_BORDER_COPY
}
 These are the supported border modes. For a kernel of width 2n+1, the n left- and rightmost image/mask columns do not have elements for the whole kernel. The same holds for the top and bottom image/mask rows. The border mode defines the filtering of such border pixels. More...
enum  _cpl_filter_mode_ {
  CPL_FILTER_EROSION,
  CPL_FILTER_DILATION,
  CPL_FILTER_OPENING,
  CPL_FILTER_CLOSING,
  CPL_FILTER_LINEAR,
  CPL_FILTER_AVERAGE,
  CPL_FILTER_AVERAGE_FAST,
  CPL_FILTER_MEDIAN,
  CPL_FILTER_STDEV,
  CPL_FILTER_STDEV_FAST,
  CPL_FILTER_MORPHO
}
 These are the supported filter modes. More...

Detailed Description

This module provides definitions for filtering of a cpl_image and a cpl_mask. The actual filtering functions are defined in the cpl_image and cpl_mask modules.

Synopsis:
#include "cpl_filter.h"

Typedef Documentation

The border mode type.

The filter mode type.


Enumeration Type Documentation

These are the supported border modes. For a kernel of width 2n+1, the n left- and rightmost image/mask columns do not have elements for the whole kernel. The same holds for the top and bottom image/mask rows. The border mode defines the filtering of such border pixels.

Enumerator:
CPL_BORDER_FILTER 

Filter the border using the reduced number of pixels. If in median filtering the number of pixels is even choose the mean of the two central values, after the borders have been filled with a chess-like pattern of +- inf

CPL_BORDER_ZERO 

Set the border of the filtered image/mask to zero.

CPL_BORDER_CROP 

Crop the filtered image/mask.

CPL_BORDER_NOP 

Do not modify the border of the filtered image/mask.

CPL_BORDER_COPY 

Copy the border of the input image/mask.

These are the supported filter modes.

Enumerator:
CPL_FILTER_EROSION 

The erosion filter (for a cpl_mask).

CPL_FILTER_DILATION 

The dilation filter (for a cpl_mask).

CPL_FILTER_OPENING 

The opening filter (for a cpl_mask).

CPL_FILTER_CLOSING 

The closing filter (for a cpl_mask).

CPL_FILTER_LINEAR 
    A linear filter (for a @c cpl_image). The kernel elements are used as
    weights like this:
    Kernel          Image        ...
           1 2 3         ... 1.0 2.0 3.0 ...
           4 5 6         ... 4.0 5.0 6.0 ...
           7 8 9         ... 7.0 8.0 9.0 ...
                                 ...
 The filtered value corresponding to the pixel whose value is 5.0 is:

$\frac{(1*1.0+2*2.0+3*3.0+4*4.0+5*5.0+6*6.0+7*7.0+8*8.0+9*9.0)} {1+2+3+4+5+6+7+8+9}$

CPL_FILTER_AVERAGE 
    An average filter (for a @c cpl_image), i.e. the output pixel is the
    arithmetic average of the surrounding (1 + 2 * hsizex)

(1 + 2 * hsizey) pixels. The cost per pixel is O(hsizex*hsizey). The two images may have different pixel types. When the input and output pixel types are identical, the arithmetic is done with that type, e.g. int for two integer images. When the input and output pixel types differ, the arithmetic is done in double precision when one of the two images have pixel type CPL_TYPE_DOUBLE, otherwise float is used.

CPL_FILTER_AVERAGE_FAST 

The same as CPL_FILTER_AVERAGE, except that it uses a running average, which will lead to a significant loss of precision if there are large differences in the magnitudes of the input pixels. The cost per pixel is O(1) if all elements in the kernel are used, otherwise the filtering is done as for CPL_FILTER_AVERAGE.

CPL_FILTER_MEDIAN 

A median filter (for a cpl_image). The pixel types of the input and output images must be identical.

CPL_FILTER_STDEV 
    The filtered value is the standard deviation of the included
    input pixels.
       Kernel                Image        ...
              1   0   1           ... 1.0 2.0 3.0 ...
              0   1   0           ... 4.0 5.0 6.0 ...
              1   0   1           ... 7.0 8.0 9.0 ...
                                          ...

The pixel with value 5.0 will have a filtered value of: std_dev(1.0, 3.0, 5.0, 7.0, 9.0)

CPL_FILTER_STDEV_FAST 

The same as CPL_FILTER_STDEV, except that it uses the same running method employed in CPL_FILTER_AVERAGE_FAST, which will lead to a significant loss of precision if there are large differences in the magnitudes of the input pixels. As for CPL_FILTER_AVERAGE_FAST, the cost per pixel is O(1) if all elements are used, otherwise the filtering is done as for CPL_FILTER_STDEV.

CPL_FILTER_MORPHO 
    A morphological filter (for a @c cpl_image). The kernel elements
    are used as weights on the sorted values covered by the kernel:
    Kernel          Image        ...
           1 2 3         ... 4.0 6.0 5.0 ...
           4 5 6         ... 3.0 1.0 2.0 ...
           7 8 9         ... 7.0 8.0 9.0 ...
                                 ...
 The filtered value corresponding to the pixel whose value is 5.0 is:

$\frac{(1*1.0+2*2.0+3*3.0+4*4.0+5*5.0+6*6.0+7*7.0+8*8.0+9*9.0)} {1+2+3+4+5+6+7+8+9}$