# Extracting a Mathematica approximation of a curve from an image

Suppose I have an image like the following: and suppose Mathematica knows the correct scale of the image. Is there a way I could get Mathematica to approximate this with, say, a Bezier curve? Similarly if I drew a red point on here, could Mathematica extract the coordinates of the point?

• Are you willing to extract points along the line manually or must this be done by code? Aug 13, 2020 at 18:25
• Ideally Mathematica would do this. I really only need loops in the same homotopy class, so I could draw some other loop manually and just parameterise that loop to get points. However, I already have several pictures like the above with loops already drawn so if I could extract points automatically, it might be a time saver.
– math
Aug 13, 2020 at 18:49
• If manually ok, you can show Drawing Tools in Mathematica. And then use the Get Coordinates Tool. Also see mathematica.stackexchange.com/questions/1524/… Aug 14, 2020 at 3:54

If I understand your question right, you could identify pixels with different colors and extract the points.

Try bild="copy of the image" (sorry don't know how to show this code in simple form)

detect the dominant colors

dc = @DominantColors[bild]


get the points

points = Map[ PixelValuePositions[bild, #, .1 (*Colordistance*)] &, dc ]


#3 is the right one

ListPlot[point[]] points[] might be taken to get beziercurve-approximation