Morphological operation
Hunnish Note:
This translation is to translate directly according to the OpenCV Beta 4.0 version of the user manual, the original file is:
There must be many mistakes in the translation, and some terms and original semantic understandings are not accurate or wrong, please also enlighten me. The purpose of these English reference manuals is to improve the actual application level of OpenCV in computer vision, pattern recognition, and image processing with the enthusiasts of OpenCV in China.
CreatestructureLementex
Create structural elements
IPlConvkernel * CvcreatestructureLeferenceEx (int COLS, INT ROWS, INT ANCHOR_X, INT ANCHOR_Y,
INT Shape, INT * VALUES = NULL);
COLS
Columns of structural elements
Rows
Number of lines of structural elements
Anchor_x
Relative horizontal offset of anchor points
Anchor_Y
The relative vertical and convenient amount of anchor point
shape
The shape of the structural element can be the following value:
CV_SHAPE_RECT, rectangular elements; CV_Shape_Cross, Interleave Elements A cross-shaped Element; CV_Shape_ellipse, elliptical element; CV_Shape_custom, user-defined element. In this case, the parameter values defines Mask, that is, the neighborhood of the pixel must be considered.
Values
Pointer to structural elements, it is a planar array, indicating a progressive scan of the element matrix. The non-zero value indicates that this point belongs to this element. If the point is
NULL, then all values are considered to be non-zero, that is, the element is a rectangle. This parameter is only a shape
CV_Shape_custom is considered.
Function CV CreateStructureLementex Assign and Fill Structure IPLConvkernel, which can be used as structural elements in morphological operations.
ReleaseStructuringeLement
Delete structural elements
Void CVRELESSTRUCTURINGELEMENT (IPLConvkernel ** Element);
ELEMENT
Pointer for deleted structural elements
Function CVRELESSTRUCTURINGELEMENT Release Structure IPLConvkernel. If * ELEMENT is NULL, the function does not work.
Erode
Corrosion image using structural elements
Void Cverode (Const Cvarr * SRC, CVARR * DST, IPLConvkernel * Element = null, int utions = 1);
SRC
Enter the image.
DST
Output image.
ELEMENT
Structural elements for corrosion. If
NULL, use 3 × 3 rectangular structural elements
iTerations
Corrosion
The function CVRODE corrodes the input image using the specified structural element, which determines the neighborhood shape of each having the minimum value pixel point:
DST = ERODE (SRC, Element): DST (x, y) = min ((x ', y') in element) SRC (x x ', y y')
Function support (in-place) mode. Corrosion can be repeated (Itemions) times. For color images, each color channel is handled separately.
Dilate
Using structural elements Expanded image Void CVDilate (Const Cvarr * SRC, CVARR * DST, IPLConvkernel * Element = null, int ution = 1);
SRC
Enter the image.
DST
Output image.
ELEMENT
Structural elements for expansion. If
NULL, use 3 × 3 rectangular structural elements
iTerations
Expand
The function CVRODE corrodes the input image using the specified structural element, which determines the neighborhood shape of each having the minimum value pixel point:
Function CVDilate expands the input image using the specified structural element, which determines the neighborhood shape of each having the minimum value pixel point:
DST = Dilate (SRC, Element): DST (x, y) = max ((x ', y') in element)) SRC (X X ', Y Y')
Function support (in-place) mode. Expansion can be repeated (Items) times. For color images, each color channel is handled separately.
MorphologyEX
Advanced morphological transformation
Void CvmorphologyEx (Const Cvarr * SRC, CVARR * DST, CVARR * TEMP,
IPLConvkernel * Element, int operation, int ution = 1);
SRC
Enter the image.
DST
Output image.
Temp
Dinning images, in some cases
ELEMENT
Structural element
Operation
Morphological operation type:
CV_MOP_Open - Opening
CV_MOP_CLOSE - Closed
CV_MOP_GRADIENT - Morphological Gradient
CV_MOP_TOPHAT - "Top Hed"
CV_MOP_BLACKHAT - "Black Hat"
iTerations
The number of expansion and corrosion.
The function CVMorphologyEX completes some advanced morphological transformations on the basis of expansion and corrosion basic operation:
Opening:
DST = Open (src, element) = Dilate (ERC, Element), ELEMENT
Close:
DST = Close (src, element) = Erode (Dilate (src, element), ELEMENT)
Form gradient
DST = Morph_Grad (src, element) = Dilate (src, element) -er (src, element)
"Top hat":
DST = Tophat (src, element) = src-open (src, element)
"Black Hat":
DST = Blackhat (src, element) = close (src, element) -src
Temporary image TEMP needs in the morphological gradient and the IN-Place mode when "top hat" and "black hats" operation.