对此 MATLAB 代码片段的解释

发布于 2024-08-28 07:54:02 字数 429 浏览 5 评论 0原文

考虑一下:

%# load a grayscale image
img = imread('coins.png');

%# display the image
figure
imshow(img,[]);

%# false-color
colormap('hot')

上面的代码来自这里:

Matlab 中的红外图像处理< /a>

但我不明白 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠佳期 2024-09-04 07:54:02

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 displays img on it. If a figure hadn't been opened, imshow would've created a new one.

The colormap colors the intensities of the image. The hot map colors values in increasing intensity with black, red, yellow, and white-hot. Another popular colormap is jet 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 in hot.

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

alt text
(source: mathworks.com)

Bone

alt text http://www.mathworks.com/access/helpdesk/help/techdoc/ref/bone_spine.gif

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文