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).
0 个评论
采纳的回答
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Red 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!