【问题标题】:Axes set-up with matlab imshow使用 matlab imshow 设置轴
【发布时间】:2017-06-26 09:05:44
【问题描述】:

我有两个图像(I1 和 I2),我想通过子图绘制如下。为简单起见,我创建了两个大小为 512x512 像素的假图像。

I1 = randn(512);
I2 = randn(512);
% display 
f1 = figure();
axis on;
subplot(1,2,1), imshow(uint8(I1));
subplot(1,2,2), imshow(uint8(I2));

我希望 Y 轴仅显示以下刻度:0 100 200 300 400 500。因此与 X 轴完全相同,因此很明显图像尺寸也大于 500 像素。我该怎么做?非常感谢!

【问题讨论】:

  • 如果你只有灰度图像并且需要显示刻度,我真的建议使用imageimagescimshow 意味着不显示刻度,因为它将图像显示为图片。
  • @VaheTshitoyan 问题是使用 image 或 imagesc 我无法保留真实的图像颜色

标签: image matlab imshow


【解决方案1】:

您应该将轴移动到脚本的末尾并指定 XTick 和 XTickLabel 属性。

I1 = randn(512);
I2 = randn(512);
% display 
f1 = figure();

s1=subplot(1,2,1);
imshow(uint8(I1));
set(s1,'XTick',0:100:500);
set(s1,'XTickLabel',0:100:500);
axis on;

s2=subplot(1,2,2);
imshow(uint8(I2));
set(s2,'XTick',0:100:500);
set(s2,'XTickLabel',0:100:500);
axis on;

【讨论】:

  • 我试过你的脚本,Y轴显示的是0 50 100 150等等...
  • 看起来这与窗口大小有关。缩小窗口将显示正确的坐标轴。
  • 简单地将 XTick 和 XTickLabel 替换为对应的 Y 参数,效果很好。我以前没有意识到这一点!非常感谢!
猜你喜欢
  • 1970-01-01
  • 2015-06-04
  • 2019-02-11
  • 2019-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-31
  • 2017-06-05
相关资源
最近更新 更多