# How can I convert a shape made out of pixels to vertices

I'm trying to implement the solution to get the minimum dissection into rectangles of a rectilinear polygon.

My shape is made out of pseudo-pixels (different width/height) but for the moment let's say it's only pixels.

I need to find a way to convert my shape to a vertices loop.

for example a simple pixel of coordinate {50, 25} would give me 4 vertices (to read clockwise) as follow {{50, 25}{51, 25}{51, 26}{50, 26}}.

Imagine now a more complex filled shape with holes in it like this one of 6 pixels height and 24 pixels width.

   S
|¯¯¯¯|    |¯¯¯¯¯¯|
__|    |____|  __  |__
|              |__|    |
¯¯|    |¯¯¯¯|      |¯¯
|____|    |______|


I can't seem to find the logic to parse my shape and convert it to vertices. Only thing I know is I think I will start parsing with pixel of coordinate S which is the top-left pixel of the shape.

Thanks in advance,

• As a first start, the keyword you might be looking for is contour finding/detection. The point is finding connected curves along the black-white-discontuities in a binary image. There's a multitude of algorithms for that, but looking for that term might give you some first introductions to the problem. Jul 19, 2018 at 9:05