# Corrosion, expansion, open and closed operations in morphological operations.

Source: Internet
Author: User

Corrosion, expansion, open and closed operations in morphological operations.

1. corrosion is a process of eliminating boundary points and shrinking the boundary to the interior. It can be used to eliminate small and meaningless objects.
Corrosion algorithm:
Scan each pixel of an image with a 3x3 structure element
Perform the "and" operation with the structure element and the binary image covered by it
If both are 1, the pixel of the result image is 1. Otherwise, it is 0.
Result: The second-value image is reduced by one lap.

2. Expansion refers to the process of merging all background points in contact with the object into the object to make the boundary expand externally. It can be used to fill holes in objects.
Expansion algorithm:
Scan each pixel of an image with a 3x3 structure element
Perform the "and" operation with the structure element and the binary image covered by it
If both are 0, the pixel of the result image is 0. Otherwise, the value is 1.
Result: The binary image is enlarged.

3. The process of first corrosion and then expansion is called an open operation. It is used to remove small objects, separate objects at slender points, and smooth the boundary of large objects without significantly changing the area.
4. The process of first expansion and then corrosion is called closed operation. It is used to fill the body with small holes, connect adjacent objects, and smooth its boundary without significantly changing its area.

// Example code of Corrosion
// Use structural elements in the horizontal direction for corrosion
For (j = 0; j <lheight; j ++)
{
For (I = 1; I <lWidth-1; I ++)
{
...
// The current vertex in the target image is first black.
* Lpdst = (unsigned char) 0;

// If the current or left vertices in the source image are not black,
// The current vertex in the target image is white.
For (n = 0; n <3; n ++)
{
Pixel = * (lpsrc + N-1 );
If (pixel = 255)
{
* Lpdst = (unsigned char) 255;
Break;
}
}
}
}

Related Keywords:

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.