|
Geometry : |
Subject: Re: [geometry] Polygons <-> image with a given ofset and reslution
From: Barend Gehrels (barend_at_[hidden])
Date: 2014-12-04 03:16:33
Hi Johan,
Op 3 dec. 2014 om 22:34 heeft Johan Doré <jdh_at_[hidden]> het volgende geschreven:
> Dear Boost Geometry,
>
> We are happy users of boost::geometry for a broad range of our image analysis algorithms.
>
Good to hear.
> In our work we often need to draw polygons in byte** images with a given offset and resolution, as well as to convert from image object back to polygons.
>
> When work with polygons their x,y coordinates are in millimeters and when we draw these polygons in an image we try to fill all pixels with a spatial center inside the polygon, and leave pixels with centers outside the polygon blank.
>
> When converting from image objects (Collection of neighboring pixels with the same value) to polygons, we do it by tracing the outer border of such objects.
> An example could be a 3x3 pixels image with the center pixels set to 1. If that image has its origin at 0,0 and the resolution is 1x1 pixel/millimeter. Then the closed clockwise polygon would become
> {-0.5, 0.5}, {0.5, 0.5}, {0.5, -0.5}, {-0.5, -0.5}, {-0.5, 0.5}.
>
> Now our functionality for drawing these polygons in images and our functionality for tracing the outline is far from optimal, and I wonder if you know of any boost functionality we could use instead?
Try to buffer all pixel centers with the half pixelsize as buffer-distance, and the square point buffer strategy. It should create a connecting polygon.
Regards, Barend
Geometry list run by mateusz at loskot.net