Morphological Filtering: On, closed, morphological gradient, top hat, black hat, and morphological gradient

Source: Internet
Author: User

Morphological Filtering: On, closed, morphological gradient, top hat, black hat, and morphological gradient
Not to mention, first

1. Morphological overview II
The previous article introduced the expansion and corrosion of basic morphological operations. We will use expansion and corrosion operations to achieve more advanced morphological operations on images, these are based on expansion and corrosion operations. First, morphology is mainly used to obtain the topology and result information of an object. It obtains a more essential form of an object through some operations on objects and structural elements. The main applications of morphology in image processing include: (1 ). the basic operation of morphology is used to observe and process the image, so as to improve the image quality (2 ). describes and defines various geometric parameters and features of an image, such as area, perimeter, connectivity, granularity, skeleton, and directionality. We achieve open and closed operations through two basic morphological operations: Corrosion and expansion, morphological gradient, top hat, and black hat.
2. introduction and analysis of specific morphological operations

Opening)

The operation is achieved through corrosion and expansion of the image. The principle expression is as follows:
dst=open(src,element)=dilate(erode(src,element))
The ability to exclude small block objects (assuming that the objects are brighter than the background), the results of the open operation Delete the object area that cannot contain structural elements, smooth the outline of the object, and disconnect the narrow connection, removed small highlights.

Closing)

The closed operation is the result of first expansion and then corrosion in mathematics. The principle expression is as follows:
dst=close(src,element)=erode(dilate(src,element))
A small black hole (black area) can be ruled out to smooth the outline of an object. However, unlike an open operation, a closed operation usually connects a narrow gap to form a slim bend, and fill holes smaller than the structural elements.

Morphological Gradient (Morphological Gradient)

The morphological gradient is the difference between the Expansion Diagram and the corrosion diagram. The operating principle expression is as follows:
dst=morph(src,element)=dilate(src,element)-erode(src,element)
Morphological gradient operation can retain the edge contour of an object

Top Hat)

The top hat operation is the difference between the original image and the open computing result graph. The principle expression is as follows:
dst=tophat(src,element)=src-open(src,element)
The result of the open operation is to enlarge the crack or partial brightness reduction area. Therefore, the calculated image is subtracted from the source image to highlight a brighter area than the area around the source image contour, this operation depends on the size of the selected core. The top hat operation is often used to separate the adjacent sections that are lit near the corner. When an image has a large background and small items are relatively regular, you can use the top hat operation to extract the background.

Black Hat)

The Black Hat operation is the difference between the closed operation result graph and the original image. The principle expression is as follows:
dst=blackhat(src,element)=close(src,element)-src
After the black hat operation, the area is darker than the area around the source image contour. This operation is also related to the selected core size. Therefore, the black hat operation is used to separate the patches that are darker than the neighboring near points and has a perfect contour. Opencv provides the morphological operation function morphologyEx () for opening, closing, morphological gradient, top hat, black hat, and other 5 relatively advanced operations, the two basic morphological operations of expanded nucleus corrosion can also be achieved.
3. source code reference
# Include  # Include  # Include  Using namespace cv; using namespace std; int main () {Mat srcImage = imread ("F: // Pic01.png"); imshow ("source image", srcImage ); mat element = getStructuringElement (MORPH_RECT, Size (15, 15); Mat dst1, dst2, dst3, dst4, dst5,; morphologyEx (srcImage, dst1, MORPH_OPEN, element ); imshow ("open operation", dst1); morphologyEx (srcImage, dst2, MORPH_CLOSE, element); imshow ("closed operation", dst2); morphologyEx (srcImage, dst3, MORPH_TOPHAT, element); imshow ("Top Hat", dst3); morphologyEx (srcImage, dst4, MORPH_GRADIENT, element); imshow ("morphological gradient", dst4); morphologyEx (srcImage, dst5, MORPH_BLACKHAT, element); imshow ("Black Hat", dst5); waitKey (0); return 0 ;}   

Source image

Open operation diagram

Closed Operation Diagram

Morphological gradient Graph

Top Hat chart

Black Hat chart

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.