Hello,
I have some code that is programmed to identify the largest blob within a stack of binary images and delete all surrounding blobs, exporting the new image files.
I want to edit to code to identify nth largest blobs and delete everything else. I will probably go as high as 3rd to 5th largest blobs.
Currently the code looks like this:
for i=0:num_of_filesCC(:,i+1) = bwconncomp(BW(:,:,i+1),26);endn1 =zeros(1023,997,11);for i = 0:num_of_files newimage=zeros(1023,997);[~, maxcell(i+1)] = max(cellfun(@numel, CC(i+1).PixelIdxList));newimage(CC(i+1).PixelIdxList{1,maxcell(i+1)}) = 255;n1 (:,:,i+1)= newimage;imwrite(newimage,sprintf('%s%d.%s', name_of_output, i, file_type));
How can I edit to take highest 3 blobs into account in each image slice?
Regards, R.
Best Answer