2

I have the following image which I have obtained after a segmentation process.

enter image description here

Which function or algorithm should I use to remove the small regions (marked by red circles) that are connected to the main segmented region by a very small number of pixels? I know of bwareaopen, but that can only be used to remove regions that are not connected at all.

Dev-iL
  • 23,742
  • 7
  • 57
  • 99
Likhon
  • 21
  • 1

1 Answers1

0
im = imread('image.jpg');
BW=rgb2gray(im);
BW=imbinarize(BW);
se = strel('disk',7);
imshow(bwmorph(imclose(BW,se),'thin',10));

This code produces closest result enter image description here

After that you can appy different morphological process to get rid of undesired lines.