Foundation (CVFoundation.dll) 14.0
Morphological Operations

Functions

cvbres_t BlackhatImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method performs the black-hat operation on the input image ImgIn. More...
 
cvbres_t ClosingImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method first dilates the input image ImgIn and then erodes it. More...
 
cvbres_t DilateImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method is the opposite morphological operation of the erosion (see ErodeImage). More...
 
cvbres_t ErodeImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 The morphological technique of erosion is also known as "grow", "bolden", and "expand". More...
 
cvbres_t MorphologicalGradientImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method calculates the morphological gradient of an image. More...
 
cvbres_t OpeningImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method first erodes the input image ImgIn and then dilates it. More...
 
cvbres_t TophatImage (IMG ImgIn, TMorphologyMask MaskType, long MaskWidth, long MaskHeight, long MaskOffsetX, long MaskOffsetY, IMG CustomMask, IMG &ImgOut)
 This method performs the (white) top-hat operation on the input image ImgIn. More...
 

Detailed Description

Function Documentation

◆ BlackhatImage()

cvbres_t BlackhatImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method performs the black-hat operation on the input image ImgIn.

The black-hat transform is equivalent to the subtraction of the initial source image from the closed image using a given structure element.

The black-hat transform is useful for enhancing details, especially, in the presence of shading.

Parameters
[in]ImgInHandle to input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle to result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
#TMorphologyMask, ClosingImage, TophatImage

◆ ClosingImage()

cvbres_t ClosingImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method first dilates the input image ImgIn and then erodes it.

The Closing operation is usually used for deleting small holes lying inside an object. Inner edges get smoothed out and distances smaller than the filter mask are bypassed. Any non-black pixel in that mask image represents a pixel belonging to the structure element.

Parameters
[in]ImgInHandle of input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
TMorphologyMask, ErodeImage, DilateImage, OpeningImage
Examples:
C++ Builder - C++ Builder Morphology Example

◆ DilateImage()

cvbres_t DilateImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method is the opposite morphological operation of the erosion (see ErodeImage).

It applies a structuring element (defined by some or all of the parameters MaskType, MaskWidth, MaskHeight, MaskOffsetX and MaskOffsetY plus CustomMask) to each pixel of the image and sets the value of the corresponding output pixel to the maximum value of all the pixels that are part of the structure element. Any non-black pixel in that mask image represents a pixel belonging to the structure element.

Parameters
[in]ImgInHandle of input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
TMorphologyMask, ClosingImage, ErodeImage, OpeningImage
Examples:
C++ Builder - C++ Builder Morphology Example

◆ ErodeImage()

cvbres_t ErodeImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

The morphological technique of erosion is also known as "grow", "bolden", and "expand".

It applies a structuring element (defined by some or all of the parameters MaskType, MaskWidth, MaskHeight, MaskOffsetX and MaskOffsetY plus CustomMask) to each pixel of the image and sets the value of the corresponding output pixel to the minimum value of all the pixels that are part of the structure element. Any non-black pixel in that mask image represents a pixel belonging to the structure element.

Parameters
[in]ImgInHandle of input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
TMorphologyMask, ClosingImage, DilateImage, OpeningImage
Examples:
C++ Builder - C++ Builder Morphology Example

◆ MorphologicalGradientImage()

cvbres_t MorphologicalGradientImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method calculates the morphological gradient of an image.

The morphological gradient is similar to the difference between the dilated source image and
the eroded source image.

The result image describes the contrast changes/intensity in the close neighbourhood of
a pixel. This function is useful for edge detection and segmentation applications.
Parameters
[in]ImgInHandle to input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle to result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
#TMorphologyMask, ErodeImage, DilateImage

◆ OpeningImage()

cvbres_t OpeningImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method first erodes the input image ImgIn and then dilates it.

The Opening operator is used for deleting small regions lying outside of the object. Whereas outer edges are smoothed and thin bridges are broken. The size of morphological mask is defined by the parameters MaskHeight and MaskWidth.
The mask has a model point, that is defined by the parameters MaskOffsetX and MaskOffsetY. The mask is set directly on every pixel and its new intensity is calculated in respect to the neighbouring pixels covered by the mask.

Parameters
[in]ImgInHandle of input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle of result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
TMorphologyMask, ErodeImage, DilateImage, ClosingImage
Examples:
C++ Builder - C++ Builder Morphology Example

◆ TophatImage()

cvbres_t TophatImage ( IMG  ImgIn,
TMorphologyMask  MaskType,
long  MaskWidth,
long  MaskHeight,
long  MaskOffsetX,
long  MaskOffsetY,
IMG  CustomMask,
IMG ImgOut 
)

This method performs the (white) top-hat operation on the input image ImgIn.

The top-hat transform is defined as the difference between the source image and its opening by a given structure element. In most cases a structure element of the form of a "top-hat" is being used.

Note
The size or width of the elements that are extracted can be controlled by the choice of the structuring element b.
Parameters
[in]ImgInHandle to input image.
[in]MaskTypeType of mask to be used. See TMorphologyMask for more details.
[in]MaskWidthWidth of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskWidth is ignored and set to the width of the custom mask image.
[in]MaskHeightHeight of the mask. Valid values are between 1 and 256.
Attention: If MaskType is set to MM_Custom, the MaskHeight is ignored and set to the height of the custom mask image.
[in]MaskOffsetXX-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskWidth - 1.
May be -1 in which case it will be set to width / 2.
[in]MaskOffsetYY-offset of the mask centre relative to the top left corner of the mask. Must be in the range of 0 to MaskHeight - 1.
May be -1 in which case it will be set to height / 2.
[in]CustomMaskHandle of custom mask. This mask is used for MaskType = MM_Custom, otherwise this parameter is ignored.
The mask is a monochrome image of 8 bit pixel depth with height and width not greater than 256.
[out]ImgOutImage handle to result image.
Returns
0 : OK
< 0: an error occurred.
Supported platforms:
Win32
Win64
Related Topics:
#TMorphologyMask, OpeningImage, BlackhatImage