开发者

How does Photoshop's magnetic lasso work?

开发者 https://www.devze.com 2023-01-27 14:26 出处:网络
Seems like GIMP\'s intelligent scissor is based on a paper from SIGGRAPH \'95 on \"Intelligent Scissors for Im开发者_运维问答age Composition\", as seen in one of the comments in the source.

Seems like GIMP's intelligent scissor is based on a paper from SIGGRAPH '95 on "Intelligent Scissors for Im开发者_运维问答age 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?


One algorithm you can look into is Marching Squares.


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'.


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.


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 :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号