Data cursor accuracy with imagesc

Hello everybody,
I need to increase the number of digits displaying by the data cursor when using it with imagesc. It's normally easy and can be done by editing the callback function by clicking "Edit Text Update Function" (see there for example : https://stackoverflow.com/questions/5961034/how-can-i-display-numbers-with-higher-precision-in-a-matlab-data-cursor ).
The issue is that, after changing this function, I obtain now only the values of X and Y and I have totally lost the values of "Index" and "RGB" normally displayed by the data cursor. Indeed, in the function that we change in "Edit Text Update Function", never "Index" or "RGB" appear. Do you now where the command that normally displays "Index" and "RGB" values is ? And, therefore, do you know how to solve my problem ? (ie: increasing the accuracy of X or Y without loosing the information "Index" and "RGB" normally showed by the data cursor).
I thank you in advance,
Best,
Alexandre
PS : Hereafter you can find a result of my data cursor before change and after change (I change the accuracy for displaying 6 digits instead of 4 for X and Y)

5 Comments

Adam
Adam on 15 Jul 2019
Edited: Adam on 15 Jul 2019
The event_obj argument that you get for your UpdateFcn contains the X, Y information and the target, which is your image object. You can index into the CData of this to get either index or RGB information, potentially interpolating if you wish, depending if you are viewing a greyscale indexed image or a true RGB image. If the former you can further map your greyscale index onto the current colourmap to get the RGB data.
Ok thank you I'm going to try. But do you know if there is a easier way than just define again all the display ? The display of "index" and "RGB" is surely implemented somewhere in Matlab and it seems easier to directly understand where in order to keep them when changing the data cursor callback function.
PS : I'm just using imagesc to display a 2D array. Thus, the index values are simply the values of the point (X,Y) of my array.
I'm afraid I don't know where the default functionality is. I wouldn't have a clue what the function is called to even search for it. It's one of those graphics based things, like creating a toolbar with only a subset of the usual buttons on, that I am not aware how to do without having to reprogram all the functionality myself. Someone else might know.
Actually, it is possible to find the function names used by using the profiler, but the function where I assume this code is - DataCursorManager.createDatatip is in a p-code file so is not viewable code.
Ok ok no problem. Thank you very much. I'm going to try to work on that this evening by creating my own display thanks to your first answer. Have a nice day !

Sign in to comment.

Answers (0)

Products

Release

R2018a

Asked:

on 15 Jul 2019

Commented:

on 15 Jul 2019

Community Treasure Hunt

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

Start Hunting!