How do i create a draggable object on an image and have ot show up automatically at the beginning?

I want create a draggable skeleton made up of connected line segments on an image, then drag the points to the desired location. I've been using imline, but this only shows one line and i have to create it myself.
I would like the lines to show up on the image and then drag the points to where i want them.
In the end i am looking for the resulting endpoints of each line segments which i can get using getPosition.
Any suggestions...

Antworten (1)

If by skeleton you mean a closed figure, the you can use imfreehand. Creates a draggable & resizable figure. More specifically for connected line segments you can use imrect or impoly. The addNewPositionCallback function will give the latest position values at any instant.

5 Kommentare

It's not a polygon. here is an example of what i mean http://i.imgur.com/sHdQqyA.jpg
I am not sure about how to make the whole skeleton show up atuomatically for any picture, so i don't have to redraw it again.
I've been playing around with imline function, but that just gives me one line.
is there anyway i can have the lines show up automatically at a predefined location and drag it to a new location?
Yes, you can pass in starting endpoints for the line segment.
So i tried this. but position variable still shows [0,1500;0,1300] which is my predefined location not the one I dragged to in the image. How can I get that.
figure,imshow(outIm);
l = imline;
setPosition(l,[0 0],[1500 1300]);
postion = l.getPosition();

Melden Sie sich an, um zu kommentieren.

Gefragt:

am 29 Okt. 2013

Kommentiert:

am 29 Okt. 2013

Community Treasure Hunt

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

Start Hunting!

Translated by