How do I scale the units of a displayed image?

6 次查看(过去 30 天)
Some of the images I display have real-world pixels sizes of, say, 0.5m, and some have sizes of, say, 2m. When I display the image, I'd like the x and y axes to scale appropriately and show units of meters instead of pixels.
I can get the XTickLabel and YTickLabel arrays for both axes and multiply them by the appropriate scaling factor (after converting the cell arrays to doubles, then converting back to cell arrays afterwards). But when I interact with the image (using the pan or zoom tools), the tick mark labels get screwed up.
For example - at left is my full image after scaling the axes tick marks to show size in meters. The actual image is 2347x2174, but since they're 0.5m pixels, the axes limits are half that. At right is the image afer zooming in on the large feature in the middle. The tick mark labels are incorrect.
It seems that Matlab is taking my manually-set Tick Labels and applying them to the image in 1-N order, no matter what tick marks correspond to the current pan and zoom levels of the image. Is this a bug, or is there something I'm not doing to keep the manual Tick Labels dynamic?
Thanks.
  1 个评论
Tom Repetti
Tom Repetti 2021-4-26
Ah. Discovered the xticks and xticklabels functions (and even the ones for the y and z axes). Nice. Would be even nicer if there was a global scale factor one could apply to tick labels so that one could zoom and pan an image and let the tick marks stay auto-determined but the tick labels remain scaled, but you can't have everything.

请先登录,再进行评论。

采纳的回答

Image Analyst
Image Analyst 2021-4-26
You can put in the axes limits into imshow() with the 'XData', and 'YData' options.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Data Exploration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by