Binarizing a normalized image is not working properly

1 回表示 (過去 30 日間)
M
M 2014 年 2 月 2 日
編集済み: Walter Roberson 2014 年 2 月 2 日
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 Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by