Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outline your hand with splines (Matlab)

I'm trying to write a script so that one can put his hand on the screen, click a few points with ginput, and have matlab generate an outline of the persons hand using splines. However, I'm quite unsure how you can have splines connect points that result from your clicks, as they of course are described by some sort of parametrization. How can you use the spline command built into matlab when the points aren't supposed to be connected 'from left to right'?

The code I have so far is not much, it just makes a box and lets you click some points

FigHandle = figure('Position', [15,15, 1500, 1500]);
rectangle('Position',[0,0,40,40])
daspect([1,1,1])
[x,y] = ginput;

So I suppose my question is really what to do with x and y so that you can spline them in such a way that they are connected 'chronologically'. (And, in the end, connecting the last one to the first one)

like image 374
user129412 Avatar asked Feb 14 '23 12:02

user129412


1 Answers

look into function cscvn

curve = cscvn(points) 

returns a parametric variational, or natural, cubic spline curve (in ppform) passing through the given sequence points(:j), j = 1:end.

An excellent example here: http://www.mathworks.com/help/curvefit/examples/constructing-spline-curves-in-2d-and-3d.html

like image 91
Cici Avatar answered Feb 19 '23 02:02

Cici