# How to highlight the feature edge of an image with draggable select lasso?

As shown in the picture, i want to know if it is possible to:

1) recognize the feature edge like face,nose,eyes,mouse,etc.

2) highlight the feature edge with draggable select lasso,

3) return the coordinates of each pixel lies on the lasso after the user finish dragging some of the lasso points.

Put the first part aside, Suppose i've got the points along the feature edge, how can I get a lasso selection connecting all the points together? And if I drag some of the points,leaving others fixed, how can I get all the new coordinates?

Any help would be greatly appreciated.

In Version 9, the second part of your question can be done using the FrontEnd ImageEditor tools which includes a Lasso Selection Tool.

img = ExampleData[{"TestImage", "Lena"}]


Copy the selected part:

and Paste in new cell:

You can also use the GetCoordinates tool available on the right-click menu:

Ctrl+V to paste:

• (+1) As I understand, you have re-created the contour of the selection by the GetCoordinates tool for copying the coordinates. Is it possible to copy the coordinates of the original lasso selection? Sep 27, 2014 at 16:35
• @Alexey, good question; i can't think of a way off the top of my head. Lasso selection tool does display coordinates, pixel values and indices, but it seems that copying works only for the selected image part. So to get the coordinates/indices/pixel values i had to use GetCoordinates; but then the draggable lasso selection is lost.
– kglr
Sep 27, 2014 at 17:05
• I think it should be possible because the lasso selection (at least in v10) persists even after deselecting the image: selecting the image again and choosing the lasso selection tool shows the previous selection. Initially I expected that right-clicking on the selection and choosing GetCoordinates should allow to copy the coordinates of the selection, but currently it does not do this. Sep 27, 2014 at 18:01
• Maybe I did not clearly describe my demand. Suppose i've got the points along the feature edge, how can I get a lasso selection connecting all the points together? And if I drag some of the points,leaving others fixed, how can I get all the new coordinates? Sep 28, 2014 at 15:48
• @xibinke, you question is clear enough:) I don't know if part 3 of your question can be done within the functionality exposed in the two interactive tools. Maybe you can use DrawingTools (also available in the right-click menu) which has a free-hand tool similar to the lasso selection tool. It allows access to individual points to drag them around; but i could not figure out know how delete selected points from a collection.
– kglr
Sep 28, 2014 at 16:15

This is the "first part" of a programmatic lasso selection. At the click of the mouse, it Selects a contiguous region of a color given by the mouse position (within a selectable tolerance).

Not a serious implementation, just an experiment.

i = ImageResize[ExampleData[{"TestImage", "Lena"}], 250];

mask[i_, pt_] := If[pt == {0, 0}, Image[0 ImageData[i]],
ReplacePixelValue[Image[0 ImageData[i]], pt -> RGBColor[1, 1, 1]]]
DynamicModule[{pt = {0, 0}, x = 0.5},
Column@
{Row@{ "Tolerance ", Slider[Dynamic[x]], Dynamic@x,
Button["Reset", pt = {0, 0}]},
ClickPane[