Using imread and plot grayscale image

54 次查看(过去 30 天)
Hello,
I'm following a tutorial about image processing and there is a following code:
img = imread('tire.tif');
size(img) % 205x232
imagesc(img)
title('Tire.tif')
xlabel('columns')
ylabel('rows')
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?
Thank you!
The actual picture is attached.
I use online Matlab (latest version).

采纳的回答

DGM
DGM 2022-5-18
编辑:DGM 2022-5-18
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
colormap(gray(256))
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by