completing non contiguous border regions

1 view (last 30 days)
stuart
stuart on 19 Oct 2012
hello, i have managed to isolate a colour border from an image and can display it in binary format http://i.imgur.com/2lAKp.jpg, however there is two non-contiguous regions which i need filled. is there a way to do this in matlab? or could someone please assist with helping me complete this problem. please note, i don't want to do this by hand using the paint tool.

Answers (2)

Matt J
Matt J on 19 Oct 2012
Maybe a morphological operation: IMCLOSE, IMDILATE, etc...

Image Analyst
Image Analyst on 19 Oct 2012
I need more information. Is this some kind of fixed, permanent boundary that will be in all your images? If so, just set some pixels to white and be done with it. It looks like some kind of jig or something that will always be the same.
If the gaps occur in random and various places, not always in the same place like where you have them in that one single image you uploaded, then you can use imclose() like Matt J suggested, or you can use Edge Linking.
If you use a morphological closing, it depends on what you are attempting to do, and how accurate you need to boundary to be in regions not near the gap. The closing will change (smooth) the boundary everywhere, not just at the gaps. Maybe you don't want it smoothed anywhere except near the gaps. For example, you could close it, then detect the difference. Then try to get rid of thin lines around the edges that changed but you really didn't want them to change, disconnect them from the big chunks where there really are gaps, and remove them based on their size and shape. Then add back in the big chunks. So then you'd have the original boundary where there is no gap. The exact algorithm depends on what your images look like, so you can upload more images if you want more advice. And, like I said, it depends on how accurate the gap-filled image needs to be away from the gaps.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!