Binarizing a normalized image is not working properly

1 次查看(过去 30 天)
I have this code to binarize a normalized DTI medical image, it's not working, and I don't understand where is the problem
i
ii=24;
fname = ('SOME_PATH');
F_Name = fopen(fname);
IMG = fread(F_Name, '*float');
fclose(F_Name);
IMG = reshape(IMG,256,256,50);
MX = max(max(max(IMG)));
IMG = IMG/MX;
GM_INDX = IMG(108,148,24);
for l=1:256
for m=1:256
for n=1:50
if (IMG(l,m,n) == GM_INDX)
IMG(l,m,n)=1;
else
IMG(l,m,n)=0;
end
end
end
end
figure, imshow((IMG(:,:,iii))); title('MD.DAT');

采纳的回答

Image Analyst
Image Analyst 2014-2-2
Probably because it's floating point and there may be only 1 pixel, if any, that match. See the FAQ: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
Try this instead of the triple for loop
tolerance = 0.01; % Whatever.
IMG = IMG > GM_INDX - tolerance & IMG < GM_INDX + tolerance;

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by