I don't think we need a whole package for this, because it's only a handful of
lines. If you want, we could add a @test_images_approx_eq_eps macro to
Images.jl. Or we could add it to ImageView and, in cases where they differ,
make it pop up a window that displays the two images :-).
Here's a demo:
# Get set up
using Images, TestImages
img1 = testimage("mandrill")
# Let's make img2 a single-pixel circular shift of img1
img2 = shareproperties(img1, img1[:,[size(img1,2);1:size(img1,2)-1]])
# Here's the calculation
img1f = float32(img1) # to make sure Ufixed8 doesn't overflow
img2f = float32(img2)
imgdiff = img1f - img2f
imgblur = imfilter_gaussian(imgdiff, [1,1]) # gaussian with sigma=1pixel
err = sum(abs, imgblur)
pow = (sum(abs, img1f) + sum(abs, img2f))/2
if err > 0.001*pow
error("img1 and img2 differ")
end
This example gives a 6% difference, which is over your threshold. If you blur
by sigma=2pixels, the error drops to 2.6%.
The idea behind blurring is that shifts result in adjacent negative and
positive values, which cancel when you blur.
--Tim