Structure Element iplconvkernel and operations

Source: Internet
Author: User
In opencv, a structure is defined to describe structural elements in morphology. The structure is defined as follows:

Typedef struct _ iplconvkernel

{

Int ncols;

Int nrows;

Int anchorx;

Int anchory;

Int * values;

Int nshiftr;

}

Iplconvkernel;

Here, we will briefly describe the variable definition:

Ncols, nrows: the row width and column height of the structure element;

Anchorx and anchory: coordinates, horizontal, and vertical of the structure element origin (anchorx;

Nshiftr: used to represent the shape type of structural elements. It has the following values:

# Define cv_shape_rect 0

# Define cv_shape_cross 1

# Define cv_shape_ellipse 2

# Define cv_shape_custom 100

Rectangle, cross, elliptic, and custom.

Values: When nshiftr is custom, value is a pointer to the data of structural elements. If the size of structural elements is defined as 8*6, then values is a 48-long int array, the value is 0 or 1.

 

Two operations on the structure element iplconvkernel are defined in opencv for the creation and release of the structure element.

Cvcreatestructuringelementex
Create Structure Element
Iplconvkernel * cvcreatestructuringelementex (INT cols, int rows, int anchor_x, int anchor_y,
Int shape, int * values = NULL );
Cols
Number of columns of structure elements
Rows
Number of rows in the Structure Element
Anchor_x
Relative horizontal offset of the anchor
Anchor_y
Relative vertical offset of the anchor
Shape
The shape of the structure element, which can be the following values:
Cv_shape_rect, rectangular element;
Cv_shape_cross, a cross-shaped element;
Cv_shape_ellipse, an elliptical element;
Cv_shape_custom, a user-defined element. In this case, the values parameter defines the mask, that is, the neighbor of the pixel must be considered.
Values
A pointer to a structure element. It is a flat array that scans the element matrix row by row. (Non-zero point indicates that the point belongs to the structure element ). If the pointer is null, all elements in the flat array are non-zero, that is, the structure element is a rectangle (this parameter is considered only when the shape parameter is cv_shape_custom ).
The function CV createstructuringelementex allocates and fills the structure iplconvkernel, which can be used as a structural element in morphological operations.

 

Cvreleasestructuringelement

Delete structure elements
Void cvreleasestructuringelement (iplconvkernel ** element );
Element
Pointer to the deleted Structure Element
Function cvreleasestructuringelement releases the iplconvkernel structure. If * element is null, the function does not work.

For more information about the extension operations of other structural elements, see:

Http://lh2078.blog.163.com/blog/static/56811372201051891044624/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.