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

1 visualización (últimos 30 días)
M
M el 27 de Dic. de 2013
Comentada: M el 27 de Dic. de 2013
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

Respuesta aceptada

Image Analyst
Image Analyst el 27 de Dic. de 2013
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 comentario
M
M el 27 de Dic. de 2013
THANK YOU VERY MUCH
IMG0 was defined earlier in the code, the problem was in its normalization line, it worked after fixing it

Iniciar sesión para comentar.

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