# Extra Curves When Generating From Image

Using the method in this post I'm trying to generate a curve for this image: I've gone ahead and imported it and I'm using img=Binarize[img~Blur~3] to blur it a bit, which gives me: So now I use this 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]

lines = Cases[Normal@ListContourPlot[Reverse@ImageData[img], Contours -> {0.5}], _Line, -1];
ParametricPlot[Evaluate[tocurve[#, 25, t] & /@ lines], {t, 0, 1}, Frame -> True, Axes -> False]


This finally gives me these curves: I can see the outline of Buzz pretty clearly in the center, which is what I want. What's all the extra garbage all over the image and how can I get rid of it in my curves? I'd ideally like the equation generating just the outline of Buzz.

The process is quite complicated as you can see. The code creates a set of parametric equation which can give you set of discrete plots. You can choose few of them which might work (At least worked in this case).

mess = 1;
ParametricPlot[
Evaluate[tocurve[#, 25, t] & /@ lines[[1 ;; mess]]], {t, 0, 1},
Frame -> True, Axes -> False]


gives Increase the mess and you will see more extra things.

In general those small things are supposed to give the inner structure (like the face in a portrait). I think those extra curves are supposed to be Buzz's body part (eyes, helmet, ..) which are dismantled because he is moving at the speed of light.

• Fantastic, thanks! – David M Apr 16 '16 at 15:53