How do I scale the units of a displayed image?

6 ビュー (過去 30 日間)
Tom Repetti
Tom Repetti 2021 年 4 月 23 日
回答済み: Image Analyst 2021 年 4 月 26 日
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 Center および File ExchangeData Exploration についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by