I have a number of images to be marked with certain fixed number of points. (object tracking)
I am using impoint to make the points on the image and then plot to connect them to each other in a logical way. So far so good. Next, I hit next (on my MATLAB GUI developed using GUIDE) and the new image loads in the axis and the information is lost (the point).

How can I retain the plotted impoint for my next image?

How can I make sure that when I move the impoint, the plotted lines also move?

What I still have to work around is:

That I am already using the addNewPositionCallback for the updation of the position of the point. This callback when written: addNewPositionCallback(H, @fnc); it issues a function call something like fnc(pos)

My problem is that this call back does not provide a handle.

Hence without the handles information I can not address the right element in the code. any ideas. I have as of now done it so that I have written 18 ones line functions for the fixed number of 18 points that I need to mark on the image. these functions call the same function updatestructure(position, 'point_name', handles) which is called right after the creation of impoints to plot the link between them on the image. But here too I have no information on handles. What I tried is:

This surely generated an error as the handles information was not transferred. I tried vargin to define what it should do when less argument call is set. In that I would still need handles from somewhere.

This statement above passes the handles that I wanted as per my original question and also allows me to pass some additional variables. The (p) is for the default callback of this function as movepointname(p);. It is for the current position of the point.

Note that number of actual points when you update your plot does not need to be the same: you can first plot 3 points and then update the plot handle to show 33 points.

Also in the initialization function of your GUI you can create empty plot with

hPlot = plot( [], [], '*-' );

to plot actually nothing, but the handle will be available for further updates.
Same thing should work with images as well, but you may have issues with axes limits update when you update the image to another one with different number of rows/columns. To solve this you can update the image like this:

EDIT: Ok, above will solve your first problem.
To update your lines when you move impoint, you have to look for the impoint reference and more specifically the addNewPositionCallback function.
Then you have to define call-back function that updates lines (it could be even a normal plot handle like the hPlot above) with new coordinates.

That you for your detailed response. i could not add more information here because of character limit. have added the information in the question decription to exaplin the problem in more detail.
–
TomarMay 17 '13 at 15:19

I guess I found the solution. Will post complete solution in detail once it works. Still working on it. back after a short holiday, little rusty.
–
TomarMay 21 '13 at 10:23

This somehow does not work. I get a error saying: ??? Reference to non-existent field 'hPlot'. when I try to set the values using set(handles.hPlot, 'XData', x, 'YData', y,'Color','w','LineWidth',1);. Any Suggestions?
–
TomarMay 22 '13 at 14:11

Seems that there is no hPlot in the handles structure. Make sure you store the modified handles structure at the end of each callback function that modified it with guidata(hObject, handles);.
–
anandrMay 22 '13 at 19:28