0
|
8346 Views
|
2 Replies
|
0 Total Likes
View groups...
Share

# Finding the nearest point on a curve

Posted 11 years ago
 So I have a program that recognizes leaves, but I want to try and make it more accurate, so I used a image processing function to extract the convex hull in the form of vertices.  Now I want to generate functions that will be similar to the different standard classifications of leaves, and compare the convex hull to those.  Here is the problem: the convex hull is in the form of vertices while the mathematical function needs parameters to be diffined and the program doesn't know what those parameters have to be to minimize the distance.So I though that this might work but it doesn't return anything (this is trying to find where to nearest point is on a circle):verts = (ComponentMeasurements[,     "ConvexVertices"][[1, 2]]);Minimize[{Sin[t], Cos[t]} - Rescale[verts][], t]  --ThanksChris
2 Replies
Sort By:
Posted 11 years ago
 Actually I figured it out.  What I was trying to do is find the distance between a point and the nearst point on a line.  Here is the code that does it:Minimize[Norm[{Sin[t], Cos[t]} - Rescale[verts][]], t]-Chris
Posted 11 years ago
 Hi over there, I'm not sure about your point, but let's discuss this:If one takes a picture of a single leave of a lime ("lindenblatt.png") as an example, the following happens:In:= SetDirectory[NotebookDirectory[] <> "\\test"]Out= "N:\\Udo\\Abt_N\\test"In:= pofl = Import["lindenblatt.png"]In:= Clearverts = ComponentMeasurements[pofl, "ConvexVertices"][[1, 2]];In:= vertsOut= {{0., 536.}, {0., 0.}, {664., 0.}, {664., 536.}}this is just a rectangle. In:= Minimize[{Sin, Cos} - Rescale[], t]Out= Minimize[{0. + Sin, -0.807229 + Cos}, t]This did not work because Minimize[] minimizes a scalar-valued function, not a vector-valued function. One might use the Dot[] to get a scalar out of itIn:= Minimize[({Sin, Cos} - Rescale[]).({Sin, Cos} - Rescale[]), t]Out= {0.0371607, {t -> -6.87155*10^-20}}But what usage can you make out of it??GreetingsUdo.