Prev: what is function or code to simulate moving average model
Next: how to optimize mixed parameters?
From: Walter Roberson on 5 Aug 2010 14:48 ImageAnalyst wrote: > It's kind of kludgy but it might work. What if he saved the diagram > as an image, then did a hole fill (to get solid triangles), then did > bwlabel and regionprops to get info on the objects, and filtered them > based on their shape to get just the triangular objects? Can you hole-fill by shape? If not, then if the diagram is a web of lines, it sounds as if hole filling would fill in all of the holes, leaving no way for bwlabel to distinguish the sections ? Instead of hole-filling, perhaps just negate the image, leaving 1's in the holes and 0's for the lines, and then bwlabel and regionprops _that_ ? Assuming, of course, that the resolution of the image is "good enough" that there are no "accidental" intersections or non-intersections that are important. Which seems to me to be a non-trivial problem if this is indeed a diagram of intersecting line segments rather than a diagram of vertices and non-intersecting connecting edges.
From: Doug Hull on 5 Aug 2010 15:04 If you only want the smallest triangles. Would a voronoi diagram help? Number of meet points that are not connected to any other meet points would be triangles.
From: Roger Stafford on 5 Aug 2010 15:07 "Faisal Ahmed" <fap87(a)yahoo.com> wrote in message <i3du01$maa$1(a)fred.mathworks.com>... > I have some co-ordinates and I have drawn a network with lines using "line" function. so there are some lines, some triangles, some quadrilaterals etc. is there any way in MATLAB that can automatically tell me only how many triangles are there and what are their vertices? tha'd be a life saver. thank you. - - - - - - - - - - I won't give a solution but rather some ideas. You haven't ruled out counting triangles that overlap. If that is the way you want it, for every pair of line segments determine whether they intersect and if so the point of their intersection. There is a simple algorithm to do that. Next for each line segment count the number of pairs of such intersection points along its length. For each such pair, that's a triangle somewhere. When you have added up all these counts, then divide by three because each triangle has been counted three times. That's very easy code to write. Of course all this assumes that no three line segments intersect at a common point. For that you would have to lay down some more specific rules of counting. Roger Stafford
From: Roger Stafford on 5 Aug 2010 16:34 "Roger Stafford" <ellieandrogerxyzzy(a)mindspring.com.invalid> wrote in message <i3f258$a98$1(a)fred.mathworks.com>... > "Faisal Ahmed" <fap87(a)yahoo.com> wrote in message <i3du01$maa$1(a)fred.mathworks.com>... > > I have some co-ordinates and I have drawn a network with lines using "line" function. so there are some lines, some triangles, some quadrilaterals etc. is there any way in MATLAB that can automatically tell me only how many triangles are there and what are their vertices? tha'd be a life saver. thank you. > - - - - - - - - - - > I won't give a solution but rather some ideas. You haven't ruled out counting triangles that overlap. If that is the way you want it, for every pair of line segments determine whether they intersect and if so the point of their intersection. There is a simple algorithm to do that. Next for each line segment count the number of pairs of such intersection points along its length. For each such pair, that's a triangle somewhere. When you have added up all these counts, then divide by three because each triangle has been counted three times. That's very easy code to write. > > Of course all this assumes that no three line segments intersect at a common point. For that you would have to lay down some more specific rules of counting. > > Roger Stafford - - - - - - - - - It has just occurred to me that I misstated things in that advice I gave. Where I said, "Next for each line segment count the number of pairs of such intersection points along its length. For each such pair, that's a triangle somewhere" I should have said the following instead. "Next, for each line segment and for each pair of such intersection points along its length determine whether the associated line segments themselves intersect (as you have actually already done.) If and when they do that forms a triangle somewhere." Roger Stafford
First
|
Prev
|
Pages: 1 2 Prev: what is function or code to simulate moving average model Next: how to optimize mixed parameters? |