Fill a polygon

Hi everyone.

I have an array of pixels which can be black or white (values 0 or 1).
This array represent an image with a very complex polygon border (the white pixels). What I have to do is to fill this polygon with 1 values, so I have to identify which pixels are inside the polygon and change their value from 0 to 1.

I found this example (http://www.alienryderflex.com/polygon/ ) but I dont't know how to recognize the corners of the polygon (which are thousands I guess).

Is there something useful function in Boost libraries?
Or do you have any other idea?

Thanks in advance!
Last edited on
I haven't used it myself so far, but Boost.Polygon will likely help you:
http://www.boost.org/doc/libs/1_46_1/libs/polygon/doc/index.htm
I don't know how to recognise the corners of the polygon
Check the neighbours. You are doing a scanline, if the neighbours of the pixel are both at the same side (or on), then you don't need to change the colour.

[edit] This only apply to the original neighbours, before filling the interior. You could do it with two passes [/edit]
Last edited on
Topic archived. No new replies allowed.