Binarizing a normalized image is not working properly

1 visualización (últimos 30 días)
M
M el 2 de Feb. de 2014
Editada: Walter Roberson el 2 de Feb. de 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');

Respuesta aceptada

Image Analyst
Image Analyst el 2 de Feb. de 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;

Más respuestas (0)

Categorías

Más información sobre Convert Image Type en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by