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

4 visualizaciones (últimos 30 días)
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.

Respuestas (1)

Image Analyst
Image Analyst el 26 de Feb. de 2018
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.

Categorías

Más información sobre Images en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by