It seems that curves found by EdgeDetect
always persist $C^{0}$ continuity only. Consider the following example:
l = 10; r = Pi/2;
(*Create an image of a smooth curve *)
pic = Rasterize@Plot[ArcTan[x], {x, -l, l}, Filling -> Bottom, Axes -> None,
PlotRangePadding -> None,PlotRange -> r];
(* Recover data points from the image *)
data = ImageValuePositions[Thinning@EdgeDetect@Binarize@pic, 1];
(* Create a interpolating function with the points *)
{w, h} = ImageDimensions@pic;
trf = Last@FindGeometricTransform[{{0, 0}, {0, r}, {l, 0}},
{{w/2, h/2}, {w/2, h}, {w, h/2}}];
func = Interpolation[DeleteDuplicates[trf /@ data, First@# == First@#2 &]];
{{lb, rb}} = func["Domain"]
(* Check the derivatives of func *)
Plot[{ArcTan'[x], func'[x]}, {x, lb, rb}, PlotRange -> {0, 1}]
As one can see, the recovered solution is far from the analytic one, oscillating disastrously, full of noise, in a word, bad. So the question is, with what kind of postprocessing can I get a smooth ($C^{1}$ continuity, at least) and distortionless interpolating curve? I've played with GaussianFilter
and LowpassFilter
for a while but the result isn't great.
ImagePadding -> None
to yourPlot
to get the same result in Mathematica 10.2 $\endgroup$ – Niki Estner Aug 8 '15 at 16:57Axes->None
is set,ImagePadding->All
(I think this is the default setting) andImagePadding->None
gives the same result. Maybe it's worth asking another question for this? $\endgroup$ – xzczd Aug 9 '15 at 5:59ImagePadding->None
, andEdgeDetect
finds another set of edges at the bottom and at the right. Some subtle change due to the new default themes, perhaps. $\endgroup$ – Niki Estner Aug 9 '15 at 7:33