I added these codes, but the result does not changed;
for slice=1:7
if temp77(:,:,slice)==k2
biggestPart = temp77(:,:,slice)==k2;
if (slice == 1)
imwrite(squeeze(biggestPart(:,:,slice)),['biggestPart.tif'],'tif', 'WriteMode', 'overwrite','Compression', 'none');
else
imwrite(squeeze(biggestPart(:,:,slice)),['biggestPart.tif'],'tif', 'WriteMode', 'append','Compression', 'none');
end
end
end
When I look at 2D slices separately, I can see components (there are 49 connected components). However, when I run the above codes and open the saved "biggestPart.tif" image, then I saw small connected components. The above codes should give only one (the first biggest connected) component. Right ? What is the wrong in the above codes ?