2
$\begingroup$

I want to generate a parametric equation for a closed curve, which is defined in a 2d image (such as below). The equation is {x{t}, y{t}}; t is the length of the curve from an arbitrary starting point. I want to be able to give the equation to ParametricPlot an get the same closed curve.

2D image of closed curve

A list of points {t, x(t), y(t)} are first extracted from the image in order. Then the data is used to form an InterpolatingFunction.

A single data point {t0, x(t0), y(t0)} seem to correspond to many pixels due to finite image resolution. How can I extract the desired points list?

$\endgroup$
  • $\begingroup$ Would you be fine with B-splines? $\endgroup$ – J. M. will be back soon Nov 8 '17 at 14:01
  • $\begingroup$ @J.M.I think it is ok. However, I am not familiar with B-splines. If the controlled points are sampled from the curve in the image, the generated B-spline curve will be inside the desired polygon. so it does not match the desired curve? $\endgroup$ – cmc Nov 9 '17 at 9:44
  • $\begingroup$ In the B-spline case, you can derive the set of control points needed so that the resulting curve passes through the points determined from the original image. I'll work on this later, but you can try looking for my answers in the splines tag if you're impatient. $\endgroup$ – J. M. will be back soon Nov 9 '17 at 14:10
5
$\begingroup$

Look at this post: How to create a new "person curve"? ,maybe help.

We can use the function param and tocurve in Simon Woods's answer.

dat = ImageValuePositions[
   SelectComponents[EdgeDetect@ColorNegate@Binarize@YOURPICTURE, 
    Large], 1];
ParametricPlot[
 Evaluate[tocurve[#, 100, t] & /@ {Line[
     dat[[Last[FindShortestTour[dat]]]]]}], {t, 0, 1}, Frame -> True, 
 Axes -> False]
tocurve[#, 100, t] & /@ {Line[dat[[Last[FindShortestTour[dat]]]]]}

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.