I have an image (left image), but it has some discountinuties and noises in the edges. I want to use a method (filtering, image repairing, etc. ) that can give me the right image. Is there any method that can do this for me in Matlab?
-
1I doubt there is a single method or function in matlab for that. – Marcin Aug 07 '13 at 04:56
-
@Marcin: what about any method that can do this? or any paper – Sam Aug 07 '13 at 04:59
-
Sorry, cannot think of any now. – Marcin Aug 07 '13 at 05:10
-
what about `watershed segmentation` and `h-maxima transform`? – fpe Aug 07 '13 at 07:14
-
@fpe: Can they do such a operation? Because I don't want to segment my image – Sam Aug 07 '13 at 15:10
1 Answers
A series of dilation and erosion operations (called "closing") might suffice depending on your needs. You can combine the imdilate
and imerode
operations, performing them in sequence as imclose
, or "manually" as in this example:
se=strel('ball',4,4);
im_er = imdilate(im,se);
im_er = imerode(im_er,se);
The imdilate
operation increases regions of high valued pixels, the second shrinks them. There are various shapes of object with which to perform the erosion/dilation, you might need to experiment or read up on which is most useful for your scenario.
In your particular case it looks like the RGB colorspace was ok for performing the morphological operations. I got the result (right frame) with your image (left frame) after rendering the red circles blue (middle frame), using the above operations (two dilations and one erosion):
Clearly this does not remove some of the unwanted features, but it seems to fix most of them. There are residual white pixels in some parts where the image was dilated, working with only one of the channels or in a different colorspace (for instance HSV) might be a workaround for that.
Finally, it also looks like you would want to limit the operations to the "regions of interest" (ROI) enclosed by the red circles, for that you should check other Q&A posts on SO, for instance here or here (search for "matlab roi").
edit
For the OPs new image applying the following morphing:
se=strel('ball',4,4);
im_er = imdilate(im,se);
im_er = imdilate(im_er,se);
im_er = imerode(im_er,se);
se=strel('ball',3,3);
im_er = imerode(im_er,se);
results in this image:
Note: to get better results use the roi functions!

- 1
- 1

- 5,024
- 2
- 17
- 27
-
tnx for your answer. Actually I just used those red circles to show the improvement and they are not part of the image! If you need, I can upload the original image separately – Sam Aug 07 '13 at 15:11
-
You can do that, I can take a quick look and see if there is anything I can add. – Buck Thorn Aug 07 '13 at 15:13
-
-