Ask Your Question
0

Morpho filter reduce sharp

asked 2016-09-30 18:53:06 -0600

greenworld gravatar image

updated 2016-09-30 18:53:25 -0600

Hi everyone, How I can restore the sharp of a triangle after use morpho filter, My program as below: erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(size, size))); dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(size, size))); //morphological closing (fill small holes in the foreground) dilate(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(size, size))); erode(imgThresholded, imgThresholded, getStructuringElement(MORPH_ELLIPSE, Size(size, size)));

The orgImg:

image description

The Output after using Morpho

image description

I just want to fill the holes without change the size and sharp of triangle. Can you suggest some method to solve my problem. Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-09-30 21:06:00 -0600

Tetragramm gravatar image

You can't easily do that. That's not how morphology works. However, if that is representative of all your images, you can pretty simply solve the problem without morphology. First use Flood Fill to set the white background to a different color. Then find all remaining white pixels. Replace them with the nearest color. Then use Flood Fill again to return the background to white.

edit flag offensive delete link more

Comments

Thank you!

greenworld gravatar imagegreenworld ( 2016-10-01 05:27:24 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-09-30 18:53:06 -0600

Seen: 162 times

Last updated: Sep 30 '16