简体   繁体   English

Matlab图像的位置和大小

[英]matlab image position and size

We are using MATLAB to display an image with specific position and size using this code: 我们正在使用MATLAB通过以下代码显示具有特定位置和大小的图像:

type1 = imread('20.jpg', 'jpg');
image(type1,[10,10,10,10])

Produces Mtalab error: 产生Mtalab错误:

Error using image 使用图片时出错
Incorrect number of arguments specified 指定的参数数量不正确

How can I fix this? 我怎样才能解决这个问题?

I think what you are after is this: 我认为您所追求的是:

type1 = imread('20.jpg','jpg')
figure('Position', [10,10,10,10])
image(type1)

I don't think image() can take a position argument. 我认为image()不能接受位置参数。

If you want to adjust the position of the image within the axes you will need to specify the XData and YData which are the X and Y extents of the image. 如果要在axes内调整图像的位置,则需要指定XDataYData ,它们是图像的X和Y范围。

image(type1, 'XData', [10 20], 'YData', [10 20])

The other options are to create a figure the size you want and then set the parent axes to take up the entire figure. 其他选项是创建所需大小的图形,然后将父轴设置为占据整个图形。

hfig = figure('Position', [10 10 10 10]);
hax = axes('Parent', hfig, 'Position', [0 0 1 1]);
image(type1, 'Parent', hax);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM