用matlab imshow设置轴

时间:2017-06-26 09:05:44

标签: image matlab imshow

我有两个图像(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像素。我该怎么做?非常感谢!

1 个答案:

答案 0 :(得分: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;