Years ago I worked with image processing and thought of writing a CLI image diff tool. I then thought meh, anyone can quickly roll their own. Turns out it seems to be something people care about. I should just start writing the CLI tools I think of, without dismissing their utility.
Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
11–20 of 66 posts
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#12What are some of the common applications for diffing an image?
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#13Why not use the GPU? This is exactly the kind of tasks GPUs were designed for. Gimp can do this in real time using the difference layer mode.
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#14I'm finding "gm compare" to be faster. $ time ./imgdiff cypress.png cypress.png Success! Images are equal. 3.22user 0.10system 0:00.50elapsed 661%CPU (0avgtext+0avgdata 478524maxresident)k 0inputs+0outputs (0major+48339minor)pagefaults 0swaps $ time gm compare -highlight-style assign -highlight-color purple -file diff.png cypress.png cypress.png 1.99user 0.21system 0:02.21elapsed 99%CPU (0avgtext+0avgdata 874948maxre…
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#15Why not use the GPU? This is exactly the kind of tasks GPUs were designed for. Gimp can do this in real time using the difference layer mode.
There's also bound to be some vector compare trick as well which falls back to pixel-by-pixel only for differences.
I think there are quite a few simple tricks you could apply here to get a bit more performance... Starting with sacrificing some memory and decoding a chunk of image at a time rather than calling .At(x,y) every time. And maybe improving local cache by dividing the image in `cpu` parts rather than having the work interleaved.
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#16I'm finding "gm compare" to be faster. $ time ./imgdiff cypress.png cypress.png Success! Images are equal. 3.22user 0.10system 0:00.50elapsed 661%CPU (0avgtext+0avgdata 478524maxresident)k 0inputs+0outputs (0major+48339minor)pagefaults 0swaps $ time gm compare -highlight-style assign -highlight-color purple -file diff.png cypress.png cypress.png 1.99user 0.21system 0:02.21elapsed 99%CPU (0avgtext+0avgdata 874948maxre…
Were you comparing two identical image? Could you try two different image?
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#17Why not use the GPU? This is exactly the kind of tasks GPUs were designed for. Gimp can do this in real time using the difference layer mode.
I would guess that the time of getting the data out to the GPU and back, is about the same as just calculating the difference on the CPU.
So, the quickest solution is probably to use the CPUs vector operations, and read ahead into the registers so you can exhaust the memory bandwidth fully.
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#18What are some of the common applications for diffing an image?
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#19Why not use the GPU? This is exactly the kind of tasks GPUs were designed for. Gimp can do this in real time using the difference layer mode.
Considering the source material is a file, that needs to be loaded up by the CPU first, and the operation itself is dead simple, the real constraint is RAM bandwidth. I would guess that the time of getting the data out to the GPU and back, is about the same as just calculating the difference on the CPU. So, the quickest solution is probably to use the CPUs vector operations, and read ahead into the registers so you c…
Re: Imgdiff: Faster than the fastest pixel-by-pixel image difference tool
#20Looks like a for loop iterating over each pixel one row at a time. What makes this fast?