Using imread and plot grayscale image
6 views (last 30 days)
I'm following a tutorial about image processing and there is a following code:
img = imread('tire.tif');
size(img) % 205x232
In the tutoria, picture that is shown is grayscale (black/white), but in my case the picture looks like shown in the attachment. What would a reason for this difference?
The actual picture is attached.
I use online Matlab (latest version).
DGM on 18 May 2022
Edited: DGM on 18 May 2022
Tools like imshow(), image(), imagesc() will display single-channel (grayscale) images with the current colormap. In your case, that colormap is parula().
If you want it to be displayed in grayscale, you can change the colormap. After you display the image, use
If all you want to display is the image, that should suffice.
Alternatively, you can convert the image to a gray RGB image so that imshow() doesn't apply a colormap anymore.
imagesc(repmat(img,[1 1 3]))
This method is useful if you want to do something like overlay a contour plot or some other colormapped graphics object in the same axes. Since the image no longer uses the axes colormap, you can avoid the problem of needing two different colormaps.