PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Monday the 28th of April, 2014

(Back to #pil overview) (Back to channel listing) (Animate logs)
[18:28:12] <chris11> what is the algorithm used in ImageDraw.polygon(xy, fill=None, outline=None) ?
[18:29:35] <wiredfool> It's in Draw.c. It's pixel by pixel.
[18:29:58] <wiredfool> It's also under revision/discussion. https://github.com/python-imaging/Pillow/pull/610
[18:30:01] <chris11> Thanks.
[18:32:26] <chris11> Thanks, this is really useful.
[18:34:11] <chris11> I was getting some unexplained problems with drawing a polygon on a raster image. Some pixels were being marked as inside said polygon when they were clearly out. And since each cell in the DEM was one pixel by one pixel it was very noticable.
[18:34:35] <chris11> This gives me some more stuff to go through.
[18:35:20] <wiredfool> Cool. As you can see in the PR, there's stuff in the current code that doesn't appear to be well specified or consistent.
[18:36:21] <chris11> Yeah, I noticed the code seemed to be in draw.c, but I'm still trying to wrap my head around it.
[18:36:47] <wiredfool> It's ancient. and very very pixel oriented
[18:37:05] <wiredfool> And honestly, looks a lot like slightly updated direct vga drawing code
[18:38:50] <chris11> That is what I was assuming. It looked it was using something similiar to Bresenham's line algorithm. The polygon rasterization seems to be non-overlapping in the test images I've produced.
[18:39:14] <wiredfool> Bresenham's is in there somewhere. The name even.
[18:39:53] <chris11> You are right.
[18:40:02] <chris11> I'm surprised I missed that.
[18:40:49] <wiredfool> it happens.
[18:48:09] <chris11> So basically it looks like the draw.c code has a few problems with accuracy on the pixel level. I'm currently trying to use it to mask and clip a raster with a polygon to decide which raster cells to analyze. This might be introducing some unexpected results.
[18:48:37] <wiredfool> I'd agree.
[19:03:56] <chris11> Anyway, thanks a lot for the help. I went through my image processing code this weekend to see if I understood what was going on. And now I think I have a better grasp on what is happening.
[19:04:07] <wiredfool> Glad to help