对此 MATLAB 代码片段的解释
考虑一下:
%# load a grayscale image
img = imread('coins.png');
%# display the image
figure
imshow(img,[]);
%# false-color
colormap('hot')
上面的代码来自这里:
但我不明白 figure
(有/没有它有什么区别?)和 colormap
(它如何影响已经显示的图像?) 工作?
Consider:
%# load a grayscale image
img = imread('coins.png');
%# display the image
figure
imshow(img,[]);
%# false-color
colormap('hot')
The above code is from here:
Infrared image processing in Matlab
But I don't understand how figure
(what's the difference with/without it?) and colormap
(how does it affect the already shown image?) work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
figure
不是必需的,imshow
只是在上面显示img
。如果figure
尚未打开,imshow
就会创建一个新的。colormap
为图像的强度着色。hot
将颜色值映射为黑色、红色、黄色和白热,强度逐渐增加。另一种流行的颜色图是jet
,它有许多有趣的颜色。假色
因此您想要看到的矩阵具有可以具有任何值范围的强度。为了更好的可视化,强度以一系列颜色或一组假色显示。通常,灰度图像将显示灰色阴影的图像,其中白色最大,黑色最小。假色是该概念的延伸,具有介于两者之间的几种颜色(例如
jet
)以及金属在hot
中加热的效果。像素级别的颜色图
假设您有一个像素值范围为
[cmin xmax]
的矩阵。现在,对值进行标准化,使范围为 [0,1]。另外,假设您有一个颜色映射,将一系列颜色映射到从 0 到 1 的某些值(例如 0.5 映射到 RGB(100,200,100)),然后您可以通过查找最接近的强度来获得假颜色映射。映射并显示相应的颜色。有关颜色图的更多信息,请参阅 MATLAB 文档。我在这里包含了该链接中的一些图片:
Jet
(来源:mathworks.com)
骨骼
替代文本 http://www.mathworks .com/access/helpdesk/help/techdoc/ref/bone_spine.gif
figure
is not required,imshow
just displaysimg
on it. If afigure
hadn't been opened,imshow
would've created a new one.The
colormap
colors the intensities of the image. Thehot
map colors values in increasing intensity with black, red, yellow, and white-hot. Another popular colormap isjet
which has a number of interesting colors.False colors
So the matrix you want to see has intensities which can have any range of values. For better visualization, the intensities are displayed in a range of colors or a set of false colors. Normally, a grayscale image will display an image is shades of grey, where white is maximum and black is minimum. False color is an extension of that concept with several colors in between (like
jet
) and an effect of metal being heated inhot
.Colormap at the pixel level
Suppose you have a matrix with pixel values ranging from
[cmin xmax]
. Now, normalize the values so that the range is [0,1]. Also, suppose you have a color map, such that a range of colors are mapped to some values from 0 to 1 (e.g. 0.5 is mapped to RGB(100,200,100))- then you get the false color mapping by finding the closest intensity in the map and display the corresponding color.More on colormap in the MATLAB documentation. I've included some picture from that link here:
Jet
(source: mathworks.com)
Bone
alt text http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bone_spine.gif