1

I am using MATLAB to analyze some features on a grayscale image through thresholding. I have the following code snippet which is able to identify most of the features of interest (an example is attached). However, imfill is unable to fully fill larger features and thus creates an issue later on when I try to measure feature characteristics. I tried using a higher connectivity value like 8 but that did not help. Any ideas on how to get around this issue is greatly appreciated.Attached example

filename = 'test.tif';
I = imread(filename);
bw = imbinarize(I,'adaptive','ForegroundPolarity','dark','Sensitivity',0.7);
bw = bwareaopen(bw,20);
se = strel('disk',3);
bw = imclose(bw,se);
bw = imfill(bw,'holes');
imshowpair(bw,I,'montage');
t = title('bw vs. original');
Ari
  • 35
  • 3
  • The issue is that the large feature is not connected, as you can clearly see from your image. You can always `imdilate` and `imerode` your image to fill those gaps, but you'll lose some sharpness – Ander Biguri Jun 01 '22 at 09:05

0 Answers0