Prev: want to some code
Next: Legendre coefficients
From: Manal on 17 Jun 2010 18:19 Hi all I have complicated case and I can't deal with hope some could give suggestions http://img687.imageshack.us/img687/7439/screenshot20100617at230.png in the picture above the border's values are stored in Matrix B ( the index x and y for each point) it is stored ordered by the value over the axis y I want to change the matrix order to be start with one point draw all the next points and end with the same point ( like drawing a circle ) its complicated :'( any ideas ??? thanks in advance
From: sscnekro on 17 Jun 2010 20:19 > I want to change the matrix order to be start with one point draw all the next points and end with the same point ( like drawing a circle ) I don't know anything on this, but .. if the points don't really have "neighbouring" coordinates, what would it help to rearrange the order? Do you want to connect them by a line or??
From: Manal on 17 Jun 2010 21:04 I'll draw a graph from these points (depending on their index) they have to be ordered sequentially starting from the head for example and finish at the same point ( the same head point) I don't know how this can be happen :(
From: ImageAnalyst on 17 Jun 2010 21:34 I don't have any idea which of the dozens of "boundary" points should be attached to the single point in the center, near the centroid. And I don't know which point of the "main" boundary should be connected to which, and how many, of the points in the small cluster near the bottom of the image. Why don't you take a step back and look at the situation so that you don't have to solve that problem. So . . . how did you get the points in the first place? Maybe you can get the boundary at that time, say with bwboundaries(), and not have to solve the problem that you initially posed.
From: someone on 17 Jun 2010 21:44
"Manal " <be.san(a)live.com> wrote in message <hvegm6$qn7$1(a)fred.mathworks.com>... > I'll draw a graph from these points (depending on their index) > they have to be ordered sequentially starting from the head for example and finish at the same point ( the same head point) > > I don't know how this can be happen :( If I understand your situation, you might try a procedure something like this: 1) Start with A = M(x1,y1) % an initial point 2) Set M(x1,y1) = [] % remove that point 3) Calculate the minimum distance (or distance squared) to every other point using d = min(sqrt((M-x1).2 + (M-y1).2)) % don't really need sqrt 4) Use find to get the index of the minimum distance. (You will have to decide what to do in case of ties.) 5) Set A = [A;M(xd,yd)] 6) Set M(xd,yd) = [] 7) Repeat steps 3 - 6 until M is empty A should be a matrix with your desired order. I'm sure there is lots of optimizing and degugging required with the above procedure, but you should get the idea. |