Reputation: 445
I have this image. And it consists of lots of irregular polygons.
First, I would like to calculate the minimum distance between two polygons. The way i think it can be achieved is by first extracting the location of boundary pixels of each polygon and storing it in arrays say B1 and B2. Then calculating the distance of each point in B1 to each point in B2 and then finding the minimum of that. And then i want to repeat this for each polygon in the figure with every other.
So, what i want to know is
Also, as the polygons are highly irregular, i think smoothing them a little might also save a lot of time. But again i don't know how?
I found this function is the FEX that does what i want provided i have the boundary point of the polygons, but i found it quite complex due to its general nature. I think a simpler code can do the job much faster.
Upvotes: 0
Views: 720
Reputation: 727
It may be worth looking into structures like quadtrees or b-trees. Representing your image by a quadtree may help you achieve whatever you are trying to do. At least you can "smooth" by prunning the tree at higher level.
Try reading this: http://www.cs.ubc.ca/~pcarbo/cs251/welcome.html
Upvotes: 0
Reputation: 125
I am almost sure (you will have to check) that always exists X and Y two points were the distance realices ( I mean, Dist(Polyg1,Polyg2)=Dist(X,Y) and X belongs to P1 and Y belongs to P2), and one of them is a vertex of a polygon. With that computer efficency will improve. You won't have to check B1 against B2 only Vertex of B1 against B2 and vertex of B2 against B1.
Upvotes: 0