CVB++ 14.0
Cvb::Foundation::Filter Namespace Reference

Namespace for collection of filter functions from the Foundation package. More...

Enumerations

enum class  FixedFilterSize { Kernel3x3 = CExports::FM_3x3 , Kernel5x5 = CExports::FM_5x5 , Kernel7x7 = CExports::FM_7x7 }
 Filter size values for filters using a fixed or discrete sized kernel. More...
 
enum class  FilterOrientation { Horizontal , Vertical }
 Orientation options for edge filters. More...
 
enum class  EdgeFilter { Scharr = CExports::CE_Scharr , Sobel = CExports::CE_Sobel , Sobel2nd = CExports::CE_Sobel2nd }
 Edge filter modes. Currently only used by Canny(). More...
 
enum class  RobertsDirection { Up , Down }
 Directions of the Roberts edge filter. More...
 

Functions

std::unique_ptr< ImageCanny (const ImagePlane &imagePlane, Filter::EdgeFilter edgeFilter, int lowerThreshold, int upperThreshold)
 Edge filter using the Canny algorithm. More...
 
std::unique_ptr< ImageLaplace (const Image &image, Filter::FixedFilterSize size)
 This function applies a square high pass Laplace filter to an image. More...
 
std::unique_ptr< ImageSharpen (const Image &image)
 This function applies a Filter::FixedFilterSize::Kernel3x3 sharpen filter to an image. More...
 
std::unique_ptr< ImageLowPass (const Image &image, Filter::FixedFilterSize size)
 This function applies a square low pass filter to an image. More...
 
std::unique_ptr< ImageHighPass (const Image &image, Filter::FixedFilterSize size)
 This function applies a square high pass filter to an image. More...
 
std::unique_ptr< ImageGauss (const Image &image, Filter::FixedFilterSize size)
 This function applies a low high pass Gaussian filter to an image. More...
 
std::unique_ptr< ImageBoxMean (const Image &image, Size2D< int > maskSize, Point2D< int > maskOffset)
 This function sets each pixel in the output image to the average of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters. More...
 
std::unique_ptr< ImageBoxMean (const Image &image, Size2D< int > maskSize)
 This function sets each pixel in the output image to the average of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter. More...
 
std::unique_ptr< ImageBoxMin (const Image &image, Size2D< int > maskSize, Point2D< int > maskOffset)
 This function sets each pixel in the output image to the minimum value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters. More...
 
std::unique_ptr< ImageBoxMin (const Image &image, Size2D< int > maskSize)
 This function sets each pixel in the output image to the minimum value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter. More...
 
std::unique_ptr< ImageBoxMax (const Image &image, Size2D< int > maskSize, Point2D< int > maskOffset)
 This function sets each pixel in the output image to the maximum value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters. More...
 
std::unique_ptr< ImageBoxMax (const Image &image, Size2D< int > maskSize)
 This function sets each pixel in the output image to the maximum value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter. More...
 
std::unique_ptr< ImageBoxMedian (const Image &image, Size2D< int > maskSize, Point2D< int > maskOffset)
 This function sets each pixel in the output image to the median value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters. More...
 
std::unique_ptr< ImageBoxMedian (const Image &image, Size2D< int > maskSize)
 This function sets each pixel in the output image to the median value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter. More...
 
std::unique_ptr< ImageColorMedian (const Image &image, Filter::FixedFilterSize maskType)
 Apply a color-correct box median filter to an RGB image. More...
 
std::unique_ptr< ImageWiener (const Image &image, Size2D< int > maskSize, Point2D< int > maskOffset, double noiseThreshold=0.0)
 This function performs adaptive filtering of an image degraded by constant power additive noise. More...
 
std::unique_ptr< ImageWiener (const Image &image, Size2D< int > maskSize, double noiseThreshold=0.0)
 This function performs adaptive filtering of an image degraded by constant power additive noise. More...
 
std::unique_ptr< ImagePrewitt (const Image &image, Filter::FilterOrientation orientation)
 Applies a Prewitt edge filter to the input image. More...
 
std::unique_ptr< ImageScharr (const Image &image, Filter::FilterOrientation orientation)
 Applies a Scharr edge filter to the input image. More...
 
std::unique_ptr< ImageSobel (const Image &image, Filter::FilterOrientation orientation, Filter::FixedFilterSize maskSize)
 Applies a Sobel edge filter to the input image. More...
 
std::unique_ptr< ImageSobel2nd (const Image &image, Filter::FilterOrientation orientation, Filter::FixedFilterSize maskSize)
 Applies a 2nd order Sobel edge filter to the input image. More...
 
std::unique_ptr< ImageSobel2ndCross (const Image &image, Filter::FixedFilterSize maskSize)
 Applies a 2nd order Sobel cross edge filter to the input image. More...
 
std::unique_ptr< ImageRoberts (const Image &image, Filter::RobertsDirection direction)
 Apply a Roberts edge detector to the input image. More...
 

Detailed Description

Namespace for collection of filter functions from the Foundation package.

Remarks
CMake users: Link to imported target CVB::CvbFoundationFilter

Enumeration Type Documentation

◆ EdgeFilter

enum class EdgeFilter
strong

Edge filter modes. Currently only used by Canny().

Enumerator
Scharr 

Scharr edge detection.

Sobel 

1st order Sobel filter.

Sobel2nd 

2nd order Sobel filter.

◆ FilterOrientation

enum class FilterOrientation
strong

Orientation options for edge filters.

Enumerator
Horizontal 

Horizontal.

Vertical 

Vertical.

◆ FixedFilterSize

enum class FixedFilterSize
strong

Filter size values for filters using a fixed or discrete sized kernel.

Please refer to the respective filter's documentation, as not all filters support all filter kernel sizes. Functions, that used fixed size filter masks, are implicitly always assuming the mask to be centered around the center pixel.

Enumerator
Kernel3x3 

Filter mask 3x3 pixels.

Kernel5x5 

Filter mask 5x5 pixels.

Kernel7x7 

Filter mask 7x7 pixels.

◆ RobertsDirection

enum class RobertsDirection
strong

Directions of the Roberts edge filter.

Enumerator
Up 

Filter for edges, that are positive when looking from the top right corner.

Down 

Filter for edges, that are positive when looking from the top left corner.

Function Documentation

◆ BoxMax() [1/2]

std::unique_ptr< Image > BoxMax ( const Image image,
Size2D< int >  maskSize 
)
inline

This function sets each pixel in the output image to the maximum value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image. Mask offset is automatically set to the center of the mask rectangle.

◆ BoxMax() [2/2]

std::unique_ptr< Image > BoxMax ( const Image image,
Size2D< int >  maskSize,
Point2D< int >  maskOffset 
)
inline

This function sets each pixel in the output image to the maximum value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]maskOffsetMask center pixel location.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image.

◆ BoxMean() [1/2]

std::unique_ptr< Image > BoxMean ( const Image image,
Size2D< int >  maskSize 
)
inline

This function sets each pixel in the output image to the average of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image. Mask offset is automatically set to the center of the mask rectangle.

◆ BoxMean() [2/2]

std::unique_ptr< Image > BoxMean ( const Image image,
Size2D< int >  maskSize,
Point2D< int >  maskOffset 
)
inline

This function sets each pixel in the output image to the average of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]maskOffsetMask center pixel location.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image.

◆ BoxMedian() [1/2]

std::unique_ptr< Image > BoxMedian ( const Image image,
Size2D< int >  maskSize 
)
inline

This function sets each pixel in the output image to the median value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image. Mask offset is automatically set to the center of the mask rectangle.

◆ BoxMedian() [2/2]

std::unique_ptr< Image > BoxMedian ( const Image image,
Size2D< int >  maskSize,
Point2D< int >  maskOffset 
)
inline

This function sets each pixel in the output image to the median value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]maskOffsetMask center pixel location.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image.

◆ BoxMin() [1/2]

std::unique_ptr< Image > BoxMin ( const Image image,
Size2D< int >  maskSize 
)
inline

This function sets each pixel in the output image to the minimum value of all the input image pixels in the rectangular neighborhood defined by the maskSize parameter.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image. Mask offset is automatically set to the center of the mask rectangle.

◆ BoxMin() [2/2]

std::unique_ptr< Image > BoxMin ( const Image image,
Size2D< int >  maskSize,
Point2D< int >  maskOffset 
)
inline

This function sets each pixel in the output image to the minimum value of all the input image pixels in the rectangular neighborhood defined by the maskSize and the maskOffset parameters.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]maskOffsetMask center pixel location.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

This has the effect of smoothing or blurring the input image.

◆ Canny()

std::unique_ptr< Image > Canny ( const ImagePlane imagePlane,
Filter::EdgeFilter  edgeFilter,
int  lowerThreshold,
int  upperThreshold 
)
inline

Edge filter using the Canny algorithm.

Parameters
[in]imagePlaneImage plane to be filtered.
[in]edgeFilterEdge filter method to be used.
[in]lowerThresholdLower threshold for hysteresis thresholding.
[in]upperThresholdUpper threshold for edge detection and hysteresis thresholding.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The algorithm uses three stages:

  1. imagePlane is differentiated in x and y direction using the edgeFilter. From the two derivatives the direction and magnitude is computed.
  2. The directional information is simplified and then the local maximum along an edge contour is determined that lies above the upperThreshold.
  3. The contours are then traced starting from the local maximum using hysteresis thresholding with the lowerThreshold to counter broken edges.

◆ ColorMedian()

std::unique_ptr< Image > ColorMedian ( const Image image,
Filter::FixedFilterSize  maskType 
)
inline

Apply a color-correct box median filter to an RGB image.

Parameters
[in]imageImage to apply the filter to.
[in]maskTypeMask size to use.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The input image must have an RGB color model.

◆ Gauss()

std::unique_ptr< Image > Gauss ( const Image image,
Filter::FixedFilterSize  size 
)
inline

This function applies a low high pass Gaussian filter to an image.

Parameters
[in]imageImage to be filtered.
[in]sizeEither Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ HighPass()

std::unique_ptr< Image > HighPass ( const Image image,
Filter::FixedFilterSize  size 
)
inline

This function applies a square high pass filter to an image.

Parameters
[in]imageImage to be filtered.
[in]sizeEither Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Laplace()

std::unique_ptr< Image > Laplace ( const Image image,
Filter::FixedFilterSize  size 
)
inline

This function applies a square high pass Laplace filter to an image.

Parameters
[in]imageImage to be filtered.
[in]sizeEither Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ LowPass()

std::unique_ptr< Image > LowPass ( const Image image,
Filter::FixedFilterSize  size 
)
inline

This function applies a square low pass filter to an image.

Parameters
[in]imageImage to be filtered.
[in]sizeEither Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Prewitt()

std::unique_ptr< Image > Prewitt ( const Image image,
Filter::FilterOrientation  orientation 
)
inline

Applies a Prewitt edge filter to the input image.

Parameters
[in]imageImage to filter.
[in]orientationOrientation of the filter.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

Note that the Prewitt filter zeros out negative edges - if you want to use a filter that preserves the negative edges, please use Sobel() or Scharr() instead.

◆ Roberts()

std::unique_ptr< Image > Roberts ( const Image image,
Filter::RobertsDirection  direction 
)
inline

Apply a Roberts edge detector to the input image.

Parameters
[in]imageImage to be filtered.
[in]directionFilter direction.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

Result values of the Roberts filter that are less than zero will be zeroed out.

◆ Scharr()

std::unique_ptr< Image > Scharr ( const Image image,
Filter::FilterOrientation  orientation 
)
inline

Applies a Scharr edge filter to the input image.

Parameters
[in]imageImage to filter.
[in]orientationOrientation of the filter.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The Scharr filter's output, in case of an 8 bit monochrome input image, will be scaled to the range 0...255, with 128 corresponding to a filter result of zero.

◆ Sharpen()

std::unique_ptr< Image > Sharpen ( const Image image)
inline

This function applies a Filter::FixedFilterSize::Kernel3x3 sharpen filter to an image.

Parameters
[in]imageImage to be filtered.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

◆ Sobel()

std::unique_ptr< Image > Sobel ( const Image image,
Filter::FilterOrientation  orientation,
Filter::FixedFilterSize  maskSize 
)
inline

Applies a Sobel edge filter to the input image.

Parameters
[in]imageImage to filter.
[in]orientationOrientation of the filter.
[in]maskSizeMask size (Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5).
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The Sobel filter's output, in case of an 8 bit monochrome input image, will be scaled to the range 0...255, with 128 corresponding to a filter result of zero.

◆ Sobel2nd()

std::unique_ptr< Image > Sobel2nd ( const Image image,
Filter::FilterOrientation  orientation,
Filter::FixedFilterSize  maskSize 
)
inline

Applies a 2nd order Sobel edge filter to the input image.

Parameters
[in]imageImage to filter.
[in]orientationOrientation of the filter.
[in]maskSizeMask size (Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5).
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The Sobel filter's output, in case of an 8 bit monochrome input image, will be scaled to the range 0...255, with 128 corresponding to a filter result of zero.

◆ Sobel2ndCross()

std::unique_ptr< Image > Sobel2ndCross ( const Image image,
Filter::FixedFilterSize  maskSize 
)
inline

Applies a 2nd order Sobel cross edge filter to the input image.

Parameters
[in]imageImage to filter.
[in]maskSizeMask size (Filter::FixedFilterSize::Kernel3x3 or Filter::FixedFilterSize::Kernel5x5).
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

The Sobel filter's output, in case of an 8 bit monochrome input image, will be scaled to the range 0...255, with 128 corresponding to a filter result of zero.

◆ Wiener() [1/2]

std::unique_ptr< Image > Wiener ( const Image image,
Size2D< int >  maskSize,
double  noiseThreshold = 0.0 
)
inline

This function performs adaptive filtering of an image degraded by constant power additive noise.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]noiseThresholdNoise suppression threshold. Valid input ranges from 0 to 1, with 0 causing the function to determine the threshold automatically.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

For each pixel of the input image, the function determines the local image mean and variance in the rectangular neighborhood (mask) defined by maskSize and maskOffset. The deviation from the local average is then diminished according to the local variance and the noise threshold parameters. The noise threshold parameter may be zero, in which case the function tries to determine itself what local noise threshold to apply. This normally yields the best results. Mask offset is automatically set to the center of the mask rectangle.

◆ Wiener() [2/2]

std::unique_ptr< Image > Wiener ( const Image image,
Size2D< int >  maskSize,
Point2D< int >  maskOffset,
double  noiseThreshold = 0.0 
)
inline

This function performs adaptive filtering of an image degraded by constant power additive noise.

Parameters
[in]imageImage to be filtered.
[in]maskSizeFilter mask to be used.
[in]maskOffsetMask center pixel location.
[in]noiseThresholdNoise suppression threshold. Valid input ranges from 0 to 1, with 0 causing the function to determine the threshold automatically.
Returns
The filtered image.
Exceptions
Anyexception derived from std::exception including CvbException.

For each pixel of the input image, the function determines the local image mean and variance in the rectangular neighborhood (mask) defined by maskSize and maskOffset. The deviation from the local average is then diminished according to the local variance and the noise threshold parameters. The noise threshold parameter may be zero, in which case the function tries to determine itself what local noise threshold to apply. This normally yields the best results.