I am making a tile based game.

And now I can find all the connected area using the Connected Component Labeling algorithm.

But now the problem I am having is how to calculate the poly vertices of each connected area.

For example: enter image description here

As you can see all the YELLOW tiles are of the same AREA and with the help of Connected Component Labeling algorithm I know all the (x, y) info of each tile.

And now I want is the generate a poly vertices array for the YELLOW AREA POLY (clockwise).

enter image description here

Is there any good algorithm for this ?

Any suggestion will be appreciated, thanks :)


1 Answer 1


After doing some more research I finally find a solution based on this post: java-merge-adiacent-rectangles-into-a-polygon

Here is my solution process sequence in general:

  • Extract all edges from the tiles into a EdgeArray
  • Remove all the edges that has a duplicated one in the EdgeArray this will leaving only the Edges of the merged poly contour I want
  • Connect all edges from head to tail , head to tail ...
  • Pick up all the vertices point from the edges

and that's the finally clockwise PolyVerticesArray I want.

enter image description here

  • \$\begingroup\$ Suggest you accept (checkmark) your own answer when you re-visit this site, so that this question doesn't keep appearing as unanswered / getting bumped by @Community. \$\endgroup\$
    – Engineer
    Commented Apr 24, 2017 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .