2 Fixed some grammatical errors. And added additional comment at the end.
source | link

Okay, I found a solution to my problem that allows me to create a parametric plot with same coordinates as the image, like the B spline function that kglr posted, while still being able to retrieve the parametric equations needed to integrate. I'm posting what I did here for future reference or in case someone else finds this useful. Basically since the size or scale of the objects in the image are the same I just created a program that would perform a horizontal shift on the original parametric equations based on information I got from the B-spline function. Although I was unable to retrieve the equations I was able to plug in points and create a table of values for it. From there I found a way to find the minimum values for each objectsobject from that table. After that I found the minimum values for the objects in the original parametric plot and then setup some equations to perform the appropriate horizontal shift on the original equations, which gave it the correct coordinates. Here is a break down of the code.

This creates a list of parametric equations for the x components and y components which can be accessed individually later.

And finally, this calculates the new set of parametric equations that have the correct coordinates and plots them.

There are probably better ways to do this but this was the only thing I could think of that actually works.

Okay, I found a solution to my problem that allows me to create a parametric plot with same coordinates as the image, like the B spline function that kglr posted, while still being able to retrieve the parametric equations needed to integrate. I'm posting what I did here for future reference or in case someone else finds this useful. Basically since the size or scale of the objects in the image are the same I just created a program that would perform a horizontal shift on the original parametric equations based on information I got from the B-spline function. Although I was unable to retrieve the equations I was able to plug in points and create a table of values for it. From there I found a way to find the minimum values for each objects from that table. After that I found the minimum values for the objects in the original parametric plot and then setup some equations to perform the appropriate horizontal shift on the original equations, which gave it the correct coordinates. Here is a break down of the code.

This a list of parametric equations for the x components and y components which can be accessed individually later.

And finally, this calculates the new set of parametric equations that have the correct coordinates and plots them.

Okay, I found a solution to my problem that allows me to create a parametric plot with same coordinates as the image, like the B spline function that kglr posted, while still being able to retrieve the parametric equations needed to integrate. I'm posting what I did here for future reference or in case someone else finds this useful. Basically since the size or scale of the objects in the image are the same I just created a program that would perform a horizontal shift on the original parametric equations based on information I got from the B-spline function. Although I was unable to retrieve the equations I was able to plug in points and create a table of values for it. From there I found a way to find the minimum values for each object from that table. After that I found the minimum values for the objects in the original parametric plot and then setup some equations to perform the appropriate horizontal shift on the original equations. Here is a break down of the code.

This creates a list of parametric equations for the x components and y components which can be accessed individually later.

And finally, this calculates the new set of parametric equations that have the correct coordinates and plots them.

There are probably better ways to do this but this was the only thing I could think of that actually works.

1
source | link

Okay, I found a solution to my problem that allows me to create a parametric plot with same coordinates as the image, like the B spline function that kglr posted, while still being able to retrieve the parametric equations needed to integrate. I'm posting what I did here for future reference or in case someone else finds this useful. Basically since the size or scale of the objects in the image are the same I just created a program that would perform a horizontal shift on the original parametric equations based on information I got from the B-spline function. Although I was unable to retrieve the equations I was able to plug in points and create a table of values for it. From there I found a way to find the minimum values for each objects from that table. After that I found the minimum values for the objects in the original parametric plot and then setup some equations to perform the appropriate horizontal shift on the original equations, which gave it the correct coordinates. Here is a break down of the code.

param[x_, m_, t_] := 
 Module[{f, n = Length[x], nf}, 
  f = Chop[Fourier[x]][[;; Ceiling[Length[x]/2]]];
  nf = Length[f];
  Total[Rationalize[
 2 Abs[f]/Sqrt[n] Sin[
   Pi/2 - Arg[f] + 2. Pi Range[0, nf - 1] t], .01][[;; 
 Min[m, nf]]]]]
tocurve[Line[data_], m_, t_] := param[#, m, t] & /@ Transpose[data]
SetDirectory["/home/jacobh/WORKING/Pictures"]
Import["Coronal Holes.jpg"]
img = Binarize[img~ColorConvert~"Grayscale"];
lines = Cases[
Normal@ListContourPlot[Reverse@ImageData[img], 
 Contours -> {0.5}], _Line, -1];

ParametricPlot[
Evaluate[tocurve[#, 100000000, t] & /@ lines], {t, 0, 1}, 
Frame -> True, Axes -> False, ImageSize -> Large]
ParametricEquations = Evaluate[tocurve[#, 100000000, t] & /@ lines]
n = Length[ParametricEquations]
img2 = Binarize[img~ColorConvert~"Grayscale"];

bsFs = Cases[
Normal@ListContourPlot[Reverse@ImageData[img2], Contours -> {0.5}],
Line[x_] :> BSplineFunction[x], All];

ParametricPlot[Evaluate[Through@bsFs@t], {t, 0, 1}, Frame -> True, 
Axes -> False, ImageSize -> Large, Axes -> false, Frame -> True]

This is just code I originally posted above along with kglr's B spline method. Also I included ParametricEquations = Evaluate[tocurve[#, 100000000, t] & /@ lines] and n = Length[ParametricEquations]because I'll be working with multiple images with a different number of objects in the image. This will be needed to make the code more dynamic.

stepsize = 0.001
list = Table[
N[Evaluate[Through@bsFs@t] /. t -> i], {t, 0, 1, stepsize}]
xmatrix = 
Table[Table[list[[i, j, 1]], {i, 1, (1/stepsize) + 1}], {j, 1, n}]
ymatrix = 
Table[Table[list[[i, j, 2]], {i, 1, (1/stepsize) + 1}], {j, 1, n}]

This is where I begin plugging values in the parameter and create a table of values for the spline function. From there I create two tables of tables, one with the x values and one with the y values. I did this so I could access the x and y values for each object individually. I also did this so I could create n number of tables based on the number of objects in the image.

Minx = Table[xmatrix[[i, Ordering[xmatrix[[i]], 1]]], {i, 1, n}]
Miny = Table[ymatrix[[i, Ordering[ymatrix[[i]], 1]]], {i, 1, n}]

This creates a list of minimum x values and y values for each of objects in the B spline plot, which will be accessed individually later.

x = Table[ParametricEquations[[i, 1]], {i, 1, n}]
y = Table[ParametricEquations[[i, 2]], {i, 1, n}]

This a list of parametric equations for the x components and y components which can be accessed individually later.

Mx = Table[NMinValue[{x[[i]], 0 <= t <= 1}, t], {i, 1, n}]
My = Table[NMinValue[{y[[i]], 0 <= t <= 1}, t], {i, 1, n}]

This creates two lists of minimum x and y values which will be accessed individually later.

NewParametricEquations = 
Table[{x[[i]] - (Mx[[i]] - Minx[[i]]), 
y[[i]] - (My[[i]] - Miny[[i]])}, {i, 1, n}]
ParametricPlot[NewParametricEquations, {t, 0, 1}, ImageSize -> Large, 
Axes -> False, Frame -> True]

And finally, this calculates the new set of parametric equations that have the correct coordinates and plots them.