Normalize image from -0.5 - 1.3 to 0 - 1
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
fresta peng
le 29 Mar 2020
Commenté : Image Analyst
le 29 Mar 2020
Hello,I am processing an image through some filters and get the image with min value =-0.5014 and max=1.38. I would like to normalize it between 0-1 for comparative analysis using SSIM PSNR. The mat2gray function distorts the image. Please suggest how to work around this problem.
Thanks
0 commentaires
Réponse acceptée
Ameer Hamza
le 29 Mar 2020
Try this
im_nrom = (im - min_val)./(max_val - min_val)
6 commentaires
Image Analyst
le 29 Mar 2020
How is that a solution? Why do you want to clip your values? Is there any physical justification for doing that? Why not just use the original values and learn how to display things properly? How did you get values in that range anyway? Anyway, what things look like when they're displayed has no bearing on what image analysis you do. You could make the same image look like ANY brightness and contrast depending on what you put into imshow() between the brackets: imshow(grayImage, [lowValue, highValue]). It will map lowValue and darker of your image to pure black, and highValue and brighter to pure white. Values of your image in between lowValue and highValue will be linearly scaled in brightness between black (0) and white (255). You can do lots of things to make your image look better or pretty but that doesn't mean you need to, or should, change the underlying actual values. I recommend you don't change/clip the values unless there is some physical meaning/reason for doing so.
Plus de réponses (1)
Image Analyst
le 29 Mar 2020
Modifié(e) : Image Analyst
le 29 Mar 2020
mat2gray() does NOT distort the image spatially. I'd have to see proof of that (but I'm sure you won't be able to provide it). It just rescales the intensities. These codes will show the same image
subplot(1, 2, 1);
imshow(doubleImage, []);
subplot(1, 2, 2);
imshow(uint8Image, []);
even though the intensity ranges are different. In your imshow() you did not put a range in there, like [], so for the floating point image everything below 0 was clipped to 0 and everything above 1 was clipped to 1 (white) so it had more apparent contrast than the uint8 image.
Another function that doesn't require the Image Processing Toolbox is rescale
grayImage = rescale(grayImage, 0, 1);
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!