Applying changes to an image, but it's not working, no error yet!
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponse acceptée
Image Analyst
le 27 Déc 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.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Convert Image Type dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!