Binarizing a normalized image is not working properly

1 vue (au cours des 30 derniers jours)
M
M le 2 Fév 2014
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');

Réponse acceptée

Image Analyst
Image Analyst le 2 Fév 2014
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;

Plus de réponses (0)

Catégories

En savoir plus sur Convert Image Type dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by