Hey guys,
So, for those of you out there who are inclined towards programming, I have a particular problem.
I have a 2 dimensional image array in memory and a set of points (x, y) which define an abritrary well behaved polygon in this array. This is not a pathological polygon, ie, it doesn't cross itself or anything ugly like that. Rather; it's a simple shape that encloses a single continuous area.
So, my question is, what's an efficient way to take this list of vertices, and use this to grab all of the information in the area that is enclosed? The operation I need to do is add this area in one array to another array with identical dimensions, on the same locations. Graphically, you can just think of me adding values in a section of an image to another identically sized image.
Does anyone have any algorithms in mind that work well for this, or am I going to have to just grind through this along each edge of the polygon?
If anyone has any experience using IDL with FITS files, that's what I'm using right now.
Posts
I'm not going to put in the effort to actually solve the problem, but it seems like it wouldn't be too bad to loop row by row and figure left-right boundaries. Especially if you separated the boundary finding from the pixel checking.
That's probably how I'd do it. Just find the two intercepts per row and grab all the pixels between them. It should be really easy, provided that it's convex and you sort your points first.
If it can be concave, split it into two or more convex shapes and do them separate.
While I'll probably implement the above tomorrow, I'm still going to check out these algorithms that people mentioned, just to see what there is that's out there in terms of speed and robustness.
Thanks for the help everyone!