How do I get the image width and height when it doesn't use the entire axis space?

2 次查看(过去 30 天)
I have two axes of the same size in a figure:
Then I plot one image in each axis:
Now I just want to make the top image narrower, to make it as narrow as the bottom one. I also want to keep the aspect ratio of the top image (i.e., the proportion between its width and height), so I also need to change its height.
When I display the both images using imagesc it doesn't use the entire axis area, and I want to keep it like that for the bottom one. But when I use get(gca,'Position') I still get the original dimension of the AXIS and not the current dimension of the displayed IMAGE. Image objects in matlab doesn't have a 'Position' property.
Wrapping up: 1) How do I get the current 'Position' of the bottom image, since it is not using the entire area of the axis and image objects have no 'Position' property? 2) How will I change the dimension of the top image?
Thank you very much for any lights.
Ps.: I don't want to change the image spatial resolution.

回答(1 个)

Image Analyst
Image Analyst 2018-2-26
First make sure the axes are the same size by adjusting the Position property of one to match the other. Then, when you display images, the displayed image size will adjust to fit the axes, so make sure that you use imresize() to make either the width or height of one image match the other. Then they should both be displayed with the same width or height, yet maintain their original aspect ratios.

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by