How can I have impixelinfo give me pixel numbers rather than axis values?

I have a figure in a GUI I am making created with imagesc that I then apply impixelinfo to, because I need to know the pixel locations of certain features. However, since I am also applying axis ranges, for example:
imagesc(xAx,yAx,axesVideoFocus(:,:,currentSlice))
where xAx and yAx are vectors describing the x and y axes, impixelinfo is returning me the values of xAx and yAx rather than the pixel number I am hovering over. So say I am over pixel 32, 5. What I actually get out of impixelinfo are the x and y axis values at that pixel, instead of (32,5).
Thanks for any help.

 Akzeptierte Antwort

Then don't put in axis calibration factors. Just do this:
imagesc(axesVideoFocus(:,:,currentSlice))
assuming axesVideoFocus is the name of your 3D image variable.

5 Kommentare

Nicholas
Nicholas am 7 Apr. 2014
Bearbeitet: Nicholas am 7 Apr. 2014
I need to have axes on the image though with the x and y dimensions. If I don't use the axis calibration factors, the axes show up with pixel numbers. Is there a way I can have these axes without it affecting impixelinfo?
No. It only reads out in the units that the axes is configured to be using, whether it's the calibration you sent in, or image pixels (not screen pixels). Evidently it can't report out in image pixels when you've set it up for a certain x and y spatial calibration.
Is there some way I could have a set of dummy axes around the outside showing the dimensions? As in through a second transparent figure overlaying the image, that only has axes that impixelinfo can get data from? Or would you have a suggestion on how to create a custom version of modified impixelinfo to have it output this?
You can turn "axis on" which will show the tick marks in pixels, but THEN, you can redefine the tick marks to be whatever you want. So use sprintf() to create a brand new set of tick marks that displays in your custom calibrated units. Look up help on tick marks or tick labels to see how to do it.
Thanks for pointing me in the right direction, I was able to get it working.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by