MATLAB: How to convert 0-255 scale to 30-170 scale in a grayscale Image

contrast stretchimage processingImage Processing Toolboxrescale

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?

Best Answer

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.