I have a set of closed curves described by the (x,y) coordinates of the approximating polygon.
My task is to cover the area enclosed by each curve with square pixel whose side is input.
No piece of the area must be left uncovered. That implies the squares covering the curve rim will lie partially inside and partially outside the curve.
In the following I describe what I have done.
- Generate a square grid of points inside or on the edge of the curve
- Generate new points lying outside the closed curve by subtracting the pixel side in the x or in the y direction
- Use Matlab function "rectangle" to build the square pixel.
- Eventually I will store to a file the coordinates of each pixel in the form X_min X_max Y_min Y_max
My problem is that some points, generated outside the closed curve, give rise to pixels that are completely outside the closed area. They do not intersect it.
I am attaching my script "Pixelize_Collimator_Aperture.m", my function "CollimatorGrid.m", and a zipped file containing the pictures of the resulting pixelized closed areas
I am pretty sure there are smarter ways to address this task. I would appreciate any suggestion and/or comment.
Thank you in advance.