Hello,
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);
ax_slice(cc.PixelIdxList{idx})= 1;
final_mask(:,:,i) = ax_slice;
end
or
I have shared the bi_copy.mat in the link above.
Please let me know how to deal with it.
Thanks.