Applying changes to an image, but it's not working, no error yet!
조회 수: 1 (최근 30일)
이전 댓글 표시
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
채택된 답변
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.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Convert Image Type에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!