how can i snap the specific data point?

I have written a GUI program. The program wants to recognize some features in the face. And first, I have initialized some original features. the next stage is that I want to adjust the position of the points by manual. therefore, I need to snap the specific point automatically.at the meanwhile, I refresh the image and show the position of these features each change. I have researched for a week now. but I cannot find the answers. so I need your comments.thank you.

2 Comments

I am not sure what you mean by "I need to snap the specific point automatically", but I suspect you want to do Image Registration https://www.mathworks.com/discovery/image-registration.html
like the image attached, I want to adjust the point manually. surely, I require the mouse to snap the marker automatically.

Sign in to comment.

 Accepted Answer

12 Comments

like the image attached, I want to adjust the point manually. surely, I require the mouse to snap the marker automatically.
The only supported method to change the cursor position is to use the Java Robot class.
There are some methods that can be used with Tooltips to move position, but you are not using Tooltips .
There are some unsupported methods involving setting a current position property, but users have difficulty accessing those (or finding out anything about them.)
thanks for your suggestions. And i have checked it just now. It moves the mouse based on the screen axis, but i want to locate the mouse position to the figure axis. Seemingly, the two axes have two different coordinate system. so how can fix the coordinate problem? wish your comments.thank you.
Set the figure Units property to Pixels and then get its Position property in order to get the screen coordinates. Just be careful about whether the Java Robot coordinates have (0,0) at the upper left corner or at the lower left corner
I think it is so difficult for me. because the axes in the figure have also a coordinate. the coordinate together with the coordinate in figure and screen axis are very different. and it is very difficult to transfer their coordinate system to the normalized system. do you have any other methods to achieve the function abovementioned? please give some suggestion. thank you.
I think the most problem is that the three coordinate systems(screen, figure, and image in axes) have the different pixel-to-pixel distance. therefore, the normalized uniformity is difficult.
I have reviewed the link file clearly, and it hasn't already supported the version after Matlab 2014.
Change line 124 of the jmouseemu source code to be
cmd1 = cmds(:,1);
[H,~,I] = unique(vertcat(cmd1{:}));
thank you very much. it does work. appreciate your help.
Excuse me, sir. I have met another problem. That is, before i show an image, I create an axis object. and then we show the image with the command "imshow".it leads to a problem. I don't know the axis object has the same coordinate with the image coordinate. because when I use the jmouseemu, I cant snap the point in the image. I found the snap point is based on the axis coordinate system.so, how to change the coordinate to the image system?
jmouseemu does not accept image objects for the coordinate system.
You can find the location of the image within the axes by getting the image XData and YData properties. Those values are the locations of the centers of the lower left and upper right pixels, in Data coordinates. To move to a particular pixel location you would need to get the axes XLim and YLim properties, and get the CData property so that you can figure out how many pixels wide and tall the image was, so that you can figure out the conversion the pixel width in data units and the offset needed for the center to edge. You would work with the axes InnerPosition property for the next step.
You might find it easier to use https://www.mathworks.com/matlabcentral/fileexchange/10656-data-space-to-figure-units-conversion -- but you still need to take into account that the coordinates are of centers of pixels not edges.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!