How to remove thin lines which are connected to bigger objects

4 views (last 30 days)
So far i got this binary image:
-
Now i would like to remove the thin lines which are connected to the bigger "round" objects. To get something like this:
How is this possible?
thanks

Answers (1)

Image Analyst
Image Analyst on 27 Feb 2015
You could try imopen() - a morphological opening. It may change the boundary of the round blobs slightly though.
  2 Comments
matlab3000
matlab3000 on 27 Feb 2015
Thanks for your answer. I'm proccesing the images from an webcam stream with this code so far:
if true
cam = webcam(1);
while(1)
img = snapshot(cam);
img = rgb2gray(img);
background = imopen(img,strel('disk',20));
diff_im = imsubtract(img,background);
diff_im = medfilt2(diff_im, [3 3]);
diff_im = im2bw(diff_im,0.20);
bw = bwlabel(diff_im);
end
end
i've tried now with bwmorph(img,'open'); and bwmorph(img,'thin'); but that doesn't work (think i can't do it with imopen() when i get the image directly form the wecam). Or isn't that what you meant?
Image Analyst
Image Analyst on 27 Feb 2015
No. I was talking about the binary image which you showed first, not doing it on a gray level image and subtracting and doing a median filter and then thresholding. Maybe you can upload the original gray level image.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!