image - matlab中image和imagesc有什么区别

标签 image matlab image-scaling imshow

我想知道imagesc和image在matlab中的区别

我用这个例子试图找出两者之间的区别,但我自己无法解释输出图像的区别;你能帮我吗?

I = rand(256,256);
for i=1:256

for j=1:256
    I(i,j) = j;


 end
end
figure('Name','Comparison between image et imagesc')
subplot(2,1,1);image(I);title('using image(I)');
subplot(2,1,2);imagesc(I);title('using imagesc(I)');
figure('Name','gray level of image');
image(I);colormap('gray');
figure('Name','gray level of imagesc');
 imagesc(I);colormap('gray');

最佳答案

image将输入数组显示为图像。当该输入是矩阵时,默认情况下 imageCDataMapping 属性设置为 'direct'。这意味着输入的每个值都被直接解释为 颜色图中颜色的索引,超出范围的值将被剪掉:

image(C) [...] When C is a 2-dimensional MxN matrix, the elements of C are used as indices into the current colormap to determine the color. The value of the image object's CDataMapping property determines the method used to select a colormap entry. For 'direct' CDataMapping (the default), values in C are treated as colormap indices (1-based if double, 0-based if uint8 or uint16).

由于 Matlab 颜色图 默认情况下有 64 种颜色,在您的情况下,这会产生超过 64 种颜色的值被剪裁的效果。这就是您在 image 图表中看到的内容。

具体来说,在第一个图中,颜色图是默认的 parula,有 64 种颜色;在第二张图中,colormap('gray') 应用了 64 个灰度级的灰色颜色图。例如,如果您在此图中尝试 colormap(gray(256)),图像范围将匹配颜色的数量,并且您将获得与 imagesc 相同的结果.

imagesc类似于 image 但应用自动缩放,以便图像范围跨越整个颜色图:

imagesc(...) is the same as image(...) except the data is scaled to use the full colormap.

具体来说,imagesc 对应于 imageCDataMapping 属性设置为 'scaled':

image(C) [...] For 'scaled' CDataMapping, values in C are first scaled according to the axes CLim and then the result is treated as a colormap index.

这就是为什么您在 imagesc 中看不到任何裁剪的原因。

关于image - matlab中image和imagesc有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33793034/

相关文章:

JavaFX HTMLEditor - 插入图片功能

java - 在 Spring MVC Controller 中从 Blob 提供图像文件的正确方法是什么?

python - uint16 图像的重新缩放/规范化混淆?

image-scaling - Chrome 正在拉伸(stretch)我的最大宽度图像的高度

java - 如何使用 openGL (JGL) 缩放图像?

c++ - 如何从 Qt 中的文件加载图像?

C# ListView 图像在运行时不显示

c++ - 使用 Matlab Coder 结合 matlab 代码和 mex 函数的 c/c++ 代码

matlab - 在 Matlab 图中更新图像对象的快速方法

matlab - 使用 matlab 从图像中选择随机补丁