简体   繁体   中英

matlab image position and size

We are using MATLAB to display an image with specific position and size using this code:

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

Produces Mtalab error:

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.

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.

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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