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 Kommentare

Walter Roberson
Walter Roberson am 21 Jun. 2018
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
min hao
min hao am 22 Jun. 2018
like the image attached, I want to adjust the point manually. surely, I require the mouse to snap the marker automatically.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 22 Jun. 2018

1 Stimme

12 Kommentare

min hao
min hao am 22 Jun. 2018
like the image attached, I want to adjust the point manually. surely, I require the mouse to snap the marker automatically.
Walter Roberson
Walter Roberson am 24 Jun. 2018
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.)
min hao
min hao am 25 Jun. 2018
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.
Walter Roberson
Walter Roberson am 25 Jun. 2018
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
min hao
min hao am 25 Jun. 2018
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.
min hao
min hao am 25 Jun. 2018
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.
min hao
min hao am 26 Jun. 2018
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{:}));
min hao
min hao am 26 Jun. 2018
thank you very much. it does work. appreciate your help.
min hao
min hao am 27 Jun. 2018
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?
Walter Roberson
Walter Roberson am 27 Jun. 2018
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.

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