PMXBOT Log file Viewer

Help | Karma | Search:

#pil logs for Wednesday the 19th of February, 2014

(Back to #pil overview) (Back to channel listing) (Animate logs)
[19:43:45] <matt___> Hello again, I have a question about comparing two images.
[19:44:24] <matt___> I am doing:
[19:45:40] <wiredfool> hey matt___
[19:47:28] <matt___> def compare (img1, img2):
[19:47:28] <matt___> pixels1 = img1.getdata()
[19:47:28] <matt___> pixels2 = img2.getdata()
[19:47:28] <matt___> diff = 0
[19:47:28] <matt___> for p1, p2 in zip(pixels1, pixels):
[19:47:29] <matt___> diff = diff + abs(p1[0] - p2[0])
[19:47:30] <matt___> diff = diff + abs(p1[1] - p2[2])
[19:47:33] <matt___> diff = diff + abs(p1[2] - p2[2])
[19:47:35] <matt___> return diff
[19:48:36] <matt___> How's it going wiredfool?
[19:49:31] <wiredfool> things are good
[19:50:51] <wiredfool> what's not working in your compare
[19:51:22] <wiredfool> you might look at this one: https://github.com/python-imaging/Pillow/blob/master/Tests/tester.py#L187
[19:52:00] <matt___> Oh, its working. I was just wondering if there is a faster way. I was doing some profiling and 80% of the time is spent in that function.
[19:52:13] <wiredfool> hmm.
[19:52:30] <wiredfool> It's possible imagemath might help
[19:59:10] <matt___> Cool, I'll take a look at those.
[20:00:21] <matt___> Thanks!
[20:31:24] <matt___> So comparing using tobytes() is about twice as fast at getdata().
[20:32:02] <matt___> On python3000, where I do not need to convert using ord() to do maths with the bytes.
[20:41:41] <wiredfool> cool
[20:42:45] <wiredfool> if you can get a difference image, then you might be able to count the differences by doing a dot product on the histogram
[21:29:07] <matt___> That might be quicker, I was thing of using the image difference, but doing that and reducing down seemed to take just as long.
[21:29:22] <matt___> I think numbpy as a quick dot product.
[21:29:56] <wiredfool> numpy might be overall faster anyway, once you do the copy to it's data format
[21:30:04] <wiredfool> and as long as it's already a dependency
[21:40:34] <matt___> Does numpy ship with python 3 standardly these days?
[21:40:55] <matt___> If not I must install it first thing 'cause its on all my machines,
[21:42:10] <matt___> numpy is not a dependency of Pillow?
[21:43:27] <wiredfool> nope, numpy is separate
[21:43:54] <wiredfool> pillow only does fromarray/toarray
[21:44:07] <wiredfool> it doesn't depend on it for anything else