Applying changes to an image, but it's not working, no error yet!

1 回表示 (過去 30 日間)
M
M 2013 年 12 月 27 日
コメント済み: M 2013 年 12 月 27 日
Here's my code:
File_XX = fopen('..\Data\AA.DAT');
IMG = fread(File_XX, '*float');
fclose(File_XX);
IMG = reshape(IMG,256,256,50);
MX = max(max(max(IMG)));
IMG = IMG/MX;
for i = 1 : 256
for j = 1 : 256
for k = 1 : 50
if(IMG0(i,j,k) == 2)
IMG(i,j,k) = 10;
end
end
end
end
File_IMG = fopen('Out2\Masked_AA', 'w');
fwrite(File_IMG, IMG, '*float');
fclose(File_IMG);
imshow(IMG0(:,:,iii)); title('FCM C_p Mask');
figure, imshow(IMG(:,:,iii)); title('AA Masked')
It displays the image unaltered, I don't know where's the problem
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 12 月 27 日
Can you give more details?
Walter Roberson
Walter Roberson 2013 年 12 月 27 日
IMG0 is not defined.

サインインしてコメントする。

採用された回答

Image Analyst
Image Analyst 2013 年 12 月 27 日
The whole triple for loop can be replaces by these two lines:
binaryImage = IMG0 == 2;
IMG(binaryImage) = 10;
But of course you must have defined IMG0 first. If the image is unaltered then either (1) the binary image is false everywhere meaning IMG0 never equals 2 anywhere, or (2) IMG was already 10 in the locations where IMG0 equaled 2 (actually which can't be true because you normalized IMG).
By the way, iii is never defined either. So I'm pretty sure this is not the code you ran .
I suspect the problem is that you normalized IMG0 just like you did IMG and so it will never equal 2 and so IMG will never get changed to 10.
  1 件のコメント
M
M 2013 年 12 月 27 日
THANK YOU VERY MUCH
IMG0 was defined earlier in the code, the problem was in its normalization line, it worked after fixing it

サインインしてコメントする。

その他の回答 (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