Ask Your Question

edge detection and contour extraction

asked 2019-11-14 14:12:17 -0500

Jiangnan Cai gravatar image

I want to measure the size of the welding. The image of welding is attached below. At first I need to extract the edge of the object. I got some problem!

image description

I have tried a lot of algorithms to extract the edge, but it is hard to get the inner edge of the welding, because the image is noisy and the boundary is blurry.

image description

the image below is the ideal contour I want to get.

image description

Could someone tell how can I get it?

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2019-11-14 16:07:17 -0500

Martian gravatar image

Median filtering could help to make the areas more uniform. You'll need to work at optimizing parameters, and maybe even break the area of interest into different segments, since the pixels near the apex appear to be close in value. That area looks like it will be the toughest to solve, since pixel values are less differentiated.

In order to better delineate edges, you could try bilateral filtering or another of the 'anisotropic' variants (also check the contrib libs). Expect that to be slower than normal Gaussian blur, but it will not blur edges as severely as Gaussian.

Judicious use of erode and dilate afterward may help to get rid of any remaining small islands, though I would try to do more pre-processing before resorting to that.

After the areas are more uniform, adaptive thresholding could help to 'ride' larger variations in luminance. This is another algorithm that can be sensitive to its parameters, so I recommend patching in a limited GUI with a couple slider controls to help in finding best settings.

After finding contours, you can sort the list by area, and choose only the largest three (or however many you want).

edit flag offensive delete link more


Try converting to hsv. Then threshold by value In your example is not dificult to find the object and the background, because the black top área and the near área are in levels. There are three evident levels of value.

Greydel gravatar imageGreydel ( 2019-12-04 01:52:38 -0500 )edit
Login/Signup to Answer

Question Tools



Asked: 2019-11-14 14:12:17 -0500

Seen: 418 times

Last updated: Nov 14 '19