Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>A series of dilation and erosion operations (called "closing") might suffice depending on your needs. You can combine the <code>imdilate</code> and <code>imerode</code> operations, performing them in sequence as <code>imclose</code>, or "manually" as in this example:</p> <pre><code>se=strel('ball',4,4); im_er = imdilate(im,se); im_er = imerode(im_er,se); </code></pre> <p>The <code>imdilate</code> 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.</p> <p>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): </p> <p><img src="https://i.stack.imgur.com/FXOsS.png" alt="enter image description here"></p> <p>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.</p> <p>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&amp;A posts on SO, for instance <a href="https://stackoverflow.com/questions/13529236/selecting-a-roi-manually-in-matlab">here</a> or <a href="https://stackoverflow.com/questions/4850816/using-roi-in-matlab/4852002#4852002">here</a> (search for "matlab roi").</p> <p><strong>edit</strong></p> <p>For the OPs new image applying the following morphing:</p> <pre><code>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); </code></pre> <p>results in this image:</p> <p><img src="https://i.stack.imgur.com/Cd3cY.png" alt="enter image description here"></p> <p>Note: to get better results use the roi functions!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload