Implementation of corrosion expansion algorithm based on FPGA

Source: Internet
Author: User

This article I want to write is based on the corrosion expansion algorithm implementation, corrosion expansion is the basis of morphological image processing, corrosion on the basis of binary image to do "contraction" or "refinement" operation, the expansion of the binary image on the basis of "extended" or "coarse" operation. So what is a two-value image? Look at a picture into a two-dimensional array, then two value image is a logical array of only 0 and 1, we front sobel edge detection image output edge effect, set a threshold value, greater than the threshold output is 1, less than the threshold output is 0, the final output is a two-dimensional image.

I was directly with the processing of MATLAB grayscale image Sobel edge detection, in the selection of the image will inevitably have a noise, so in order to make the edge detection effect more significant, we will image first median filtering, and then the Sobel edge detection, Finally, the corrosion expansion algorithm makes the edge of the image more delicate and tough.

First of all, we compare the median filter before Sobel and median filtering Sobel two methods of the display effect.

Median filter before Sobel

Median filter after Sobel

It can be clearly seen that the median filter Sobel picture edge More obvious, especially from the Lena hair and hat part of the display effect, a lot of redundant edges are filtered out, so median filtering after edge detection is imperative. For this part of the project, I think there should be no difficulty, median filter code I have given, only need to add Sobel when the output is finished. I hope that the reader can do their own debugging to get it done.

Corrosion algorithms

Corrosion is a process of eliminating boundary points and narrowing the boundary inward. can be used to eliminate small and meaningless objects. With a 3x3 structure element, each pixel of the image is scanned, and the "and" operation is done with the structure element with its two value image covered, if all 1, the pixel of the resulting image is 1. Otherwise, it is 0. The result is a small circle of two value images.

The image analogy is used to illustrate the operation, and 0 is used to denote the worm and 1 for rice. The process by which moths corrode rice is the corrosion operation,

Corrosion

, for a pixel matrix, because of the existence of moth (0), so the 8 rice (1) eroded, even if there is only one moth (0), but still will be moth corrosion finished, the last picture because there is no moth (0), is not lazy rice, is preserved intact.

The implementation of the algorithm can be represented by the following formula, that is, the operation of a 3x3 pixel:

P = P11 & P12 & P13 & P21 & P22 & P23 & P31 & P32 & P33

In HDL, in order to change the speed through the area, we will change the type as follows:

P1 = P11 & P12 & P13

P2 = P21 & P22 & P23

P3 = P31 & P32 & P33

P = P1 & P2 & P3

, that is, the results of corrosion operations can be achieved by the operation of 2 clocks/steps

Corrosion Simulation

Expansion algorithm

Swelling is the process of merging all background points in contact with an object into the object, allowing the boundary to expand outward. can be used to fill the void in an object. With a 3x3 structure element, scan each pixel of the image, and use the structure element with its covered two value image to do "and" operation, if all is 0, the result image of the pixel is 0,. Otherwise, it is 1. Result: The two value image is enlarged by one turn.

The process of first corrosion and swelling is called open operation. It is used to eliminate small objects, separate objects at slender points, and smooth the boundaries of larger objects without significantly altering their area. The process of first swelling and corrosion is called the specific operation, which fills the small space inside the object, joins the neighboring object, smooths its boundary and does not change its area obviously.

The expansion algorithm is described in the simplest analogy: 0 for pests, 1 for frogs, frogs to eat pests for expansion operations, we use 3*3 pixel arrays to explain:

Figure expansion

, the left only pests (0), so the pests are well alive, the middle of the map, although there is only one pest, but it is unavoidable to be eaten by the frog fate, the right side of the picture, are frogs, so the frog is always a frog.

The implementation of the algorithm can be represented by the following formula, that is, the operation of a 3x3 pixel:

P = P11 | | P12 | | P13 | | P21 | | P22 | | P23 | | P31 | | P32 | | P33

In HDL, in order to change the speed through the area, we will change the type as follows:

P1 = P11 | | P12 | | P13

P2 = P21 | | P22 | | P23

P3 = P31 | | P32 | | P33

P = P1 | | P2 | | P3

, that is, the results of corrosion operations can be achieved by the operation of 2 clocks/steps

Simulation of expansion operation

The above simulation is my previous simulation with Modelsim, here is not repeated with Isim simulation. The FPGA implementation of corrosion expansion can be said to be very simple, the two-value image is generated by the 3x3 matrix, and finally by the above formula, the output can be.

Corrosion

Expansion

From the above two pictures can be seen, the image edge of the corrosion after the obvious thinning, eliminating more false edges, on the basis of corrosion based on the expansion algorithm Lena will be corroded edge expansion, bold, so it seems clearer, ultimately for our subsequent image recognition, to make better preparations. At this point, the corrosion expansion algorithm is written, if there is any shortage please your guidance, what is the problem we can leave a message to discuss together, study together!

  If you want to get all the courseware in this article, please pay attention to my personal subscription number: Open source Fpganinghechuan or scan the QR code below to follow the subscription number, back in the background image Processing , you can get all the courseware, materials and more FPGA learning materials in this article Oh!

Reprint Please specify source: Ninghechuan (Ning River)

Personal Subscription Number: Open Source Fpganinghechuan

If you want to receive a personal blog post in time, you can scan the QR code on the left (or long press the QR code) to follow your personal subscription number

Know Id:ninghechuan

Micro Bo Id:ninghechuan

Original address: http://www.cnblogs.com/ninghechuan/p/7574309.html

Image Processing Series Articles

First: FPGA-based VGA display static picture

Second: FPGA-based Rgb565_ycbcr_gray algorithm implementation

Third: The FPGA-based UART receives the image data to the VGA display

Digital image processing industry standard image Lena behind the story

Fourth: The realization of the mean filter algorithm based on FPGA

Fifth: Deep understanding Shift_ram IP core--Image Processing Learning Notes

Sixth: The realization of median filter algorithm based on FPGA

Seventh: Implementation of Sobel edge detection based on FPGA

Implementation of corrosion expansion algorithm based on FPGA

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.