how to convert 0-255 scale to 30-170 scale in a grayscale Image?
4 views (last 30 days)
Show older comments
Umair Bashir
on 19 Nov 2020
Commented: Image Analyst
on 19 Nov 2020
I have a 112*112 matrix in matlab which I am plotting as a grayscale image. I am using imacesc for this purpose and the resulting image is on a normal grayscale image, 0-255. However, the results are not quite pronounced in this scale and I want to rescale my image on a scale of 30 - 170 since most of my pixel values are in this range. I am using rescale for this purpose but it is not working. Can anyone help me with this issue?
0 Comments
Accepted Answer
Image Analyst
on 19 Nov 2020
Try telling imshow() the display range:
imshow(grayImage, [30, 170]);
but rescale() should have worked also:
imshow(rescale(grayImage, 30, 170), []); % Use [] because I think rescale() returns a double.
2 Comments
Image Analyst
on 19 Nov 2020
Correct. If you actually want to change the gray scales, you'd use imadjust():
grayImage = imread('cameraman.tif');
subplot(1, 2, 1);
imshow(grayImage);
grayImage = imadjust(grayImage, [130, 170]/255, [0, 255]/255);
subplot(1, 2, 2);
imshow(grayImage);
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!