Message Boards Message Boards

Finding the nearest point on a curve

Posted 12 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[<picture of leaf>,
    "ConvexVertices"][[1, 2]]);

Minimize[{Sin[t], Cos[t]} - Rescale[verts][[1]], t]
  

--Thanks
Chris
2 Replies
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][[1]]], t]



-Chris
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[37]:= SetDirectory[NotebookDirectory[] <> "\\test"]
Out[37]= "N:\\Udo\\Abt_N\\test"

In[43]:= pofl = Import["lindenblatt.png"]

In[44]:= Clear
verts = ComponentMeasurements[pofl, "ConvexVertices"][[1, 2]];

In[47]:= verts
Out[47]= {{0., 536.}, {0., 0.}, {664., 0.}, {664., 536.}}

this is just a rectangle. 

In[50]:= Minimize[{Sin, Cos} - Rescale[[1]], t]
Out[50]= 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 it

In[52]:= Minimize[({Sin, Cos} - Rescale[[1]]).({Sin, Cos} - Rescale[[1]]), t]
Out[52]= {0.0371607, {t -> -6.87155*10^-20}}

But what usage can you make out of it??

Greetings
Udo.
POSTED BY: Udo Krause
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract