30

Seems like GIMP's intelligent scissor is based on a paper from SIGGRAPH '95 on "Intelligent Scissors for Image Composition", as seen in one of the comments in the source.

However Magnetic Lasso in Photoshop differs a lot, while GIMP's tool gives users an option to click vertices of desired figure and approximates along edges found in the image, photoshop's magnetic lasso on the other hand, gives users a way to run freehand and gives something between computerized approximation and what the user desired to draw.

Looking at this behavior its quite obvious that Magnetic Lasso style selection would quite cool for selection in touch based interfaces. Any pointers on how magnetic lasso differs from the GIMP's tool? Any specific papers/algorithms to look into?

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
Abhishek Mishra
  • 5,002
  • 8
  • 36
  • 38
  • ~ Are you able to say what language or platform you'ld be writing this for? Will this be for an iPhone or Android or ... Depending on the available languages and APIs it might be easier or more difficult – jcolebrand Dec 03 '10 at 04:35
  • I am targeting iPads, the idea is to try creating it with canvas/svg+javascript, if that becomes computationally infeasible or too tough to do with them, then probably with DrawKit's vector support as a native app. – Abhishek Mishra Dec 03 '10 at 19:04

4 Answers4

8

One algorithm you can look into is Marching Squares.

ejohansson
  • 2,832
  • 1
  • 23
  • 30
4

The Magnetic Lasso tool is especially useful for quickly selecting objects with complex edges set against high-contrast backgrounds.

  1. Detect the edges in the picture using an edge detection algorithm.
  2. Wait for the left mouse click event.
  3. Snap to the nearest detected edge and begin a line segment.

    3A. Track mouse movement, snapping to detected edges.

    3B. If the left mouse button is clicked begin a line segment from the end of the previous one or finish the current one.

    3C. If a line segment was created, conform the line to the detected edges in the area.

    3D. If the ESC key or right mouse button is clicked, enclose the detected area by creating a line segment from the first point to the last point.

Voilà, you have a 'magnetic lasso'.

Espo
  • 41,399
  • 21
  • 132
  • 159
Voilà
  • 41
  • 1
  • He's targeting iPads ... not much call for a left mouse button, etc. How do you know for sure which edge to highlight on a narrow item? But the idea is sound. – jcolebrand Dec 07 '10 at 14:58
  • 1
    Sounds nice, but what if you have a soft contour 10 pixels from pointer and strong contour 20 pixels from pointer? To which contour should you snap? There are many other unanswered questions in this approach ... – Ivan Kuckir Apr 18 '14 at 17:36
4

Seems like GIMP's intelligent scissor is based on a paper from SIGGRAPH '95 on "Intelligent Scissors for Image Composition", as seen in one of the comments in the source.

However Magnetic Lasso in Photoshop differs a lot,

The document with the algorithm for Intelligent Scissors is here

Regarding the relation between algorithms, this article says

Software company Adobe, which has long had a relationship with BYU's computer scientists, helped fund the research for development of Live Surface. An earlier software, developed by Barrett and his students under the name Intelligent Scissors, was renamed Magnetic Lasso and is now incorporated into 5.0 Adobe PhotoShop, where it quickly yanks two-dimensional objects out of images.

Community
  • 1
  • 1
3

I have successfully implemented Magnetic Lasso using the article that you mentioned - Intelligent Scissors for Image Composition. I also implemented iterative extending of searched area and "path cooling".

You can see my implementation at www.Photopea.com (drag and drop your own image, roll over lasso, choose Magnetic Lasso). So it is possible and not that hard to implement :)

Ivan Kuckir
  • 2,327
  • 3
  • 27
  • 46