How to reproduce imshow display range [] ?
26 views (last 30 days)
Show older comments
Hi
having a grayscale image (f.e. "img", 512x512, double), how can one reproduce the scaling that is done by imshow(img, []) and save the result?
From the Mathworks documentation I know that ..."If you specify an empty matrix ([]), imshow uses [min(I(:)) max(I(:))]"...
I tried using imadjust as imadjust(img, [min(img(:))/255, max(img(:))/255], [0, 1]), but this didn't work as it gave a different ouput than the imshow function.
Thanks already in advance!
0 Comments
Answers (2)
Walter Roberson
on 10 Mar 2019
mat2gray() rescales between the min and max values. Not the most obvious of routine names.
Since R2017b there has also been rescale()
0 Comments
Image Analyst
on 10 Mar 2019
Why are you using imadjust()? You can just use max and min to save the display range:
displayMin = min(img(:));
displayMax = max(img(:))
% Display img:
imshow(img, []); % Will use [displayMin, displayMax]
% Display image1 using same display range as img.
imshow(image1, [displayMin, displayMax]);
% Display image2 using same display range as img.
imshow(image2, [displayMin, displayMax]);
% etc.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!