I am doing some morphological image processing. I want to remove the 4 unwanted blobs from the binary object(image below)
If I axially slice the image, I can take the largest connected component and exclude others like the image below:
I have tried the following codes which results binary size mismatch issues.
ind = 1;
sz = size(bi)
final_mask = zeros(sz)
for i = 1:sz(3)
cc = bwconncomp(bi(:,:,i));
S = regionprops(cc, 'Area', 'PixelIdxList');
ax_slice = zeros(sz(1), sz(2));
numPixels = cellfun(@numel, cc.PixelIdxList);
[biggest,idx] = max(numPixels);
final_mask(:,:,i) = ax_slice;
I have shared the bi_copy.mat in the link above.
Please let me know how to deal with it.