1
$\begingroup$

i am new to Mathematica. I have generated the contours of this image with the following code enter image description here

img = Import["https://upload.wikimedia.org/wikipedia/it/archive/0/09/20160903181541%21Twitter_bird_logo.png"];`

mesh = ImageMesh@img;
midpoints = Midpoint /@ MeshPrimitives[mesh, 1];
Graphics[{Thick, Darker[Red], 
  BSplineCurve[midpoints, SplineClosed -> False]}]

My question is: is there a way to get from Mathematica the vector of control points,the vector of knots,the vector of weights of control points and degree of this B-Spline/NURBS curve?

$\endgroup$
4
  • $\begingroup$ Do you mean export to Matlab or Mathematica ? Can you check the title of your post ? $\endgroup$
    – Dunlop
    Commented Jun 17, 2020 at 13:02
  • $\begingroup$ I mean how can i export from mathematica to matlab $\endgroup$ Commented Jun 17, 2020 at 13:26
  • $\begingroup$ By the way, the reason for the bad spline is because if you look closely, there is a small black dot and another dot above it. You can fix it with this code: imgFixed = ColorReplace[FillingTransform[Binarize[img], 1], { White -> RGBColor[{0., 0.6745, 0.9294}], Black -> RGBColor[{0, 0, 0, 0}]}] $\endgroup$
    – flinty
    Commented Jun 17, 2020 at 13:38
  • $\begingroup$ Use bsf=BSplineFunction[midpoints] , then bsf["ControlPoints"] bsf["Knots"], and bsf["Degree"] to get them. bsf["Weights"] just seems to return Automatic. I don't know about how you want them exported to Matlab though. $\endgroup$
    – flinty
    Commented Jun 17, 2020 at 13:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.