FireStats is not installed in the database
Laryngitis homøopatiske midler køb propecia edderkop bid retsmidler

Unsigned Image Comparison in Matlab

Author:nick @ March 10th, 2009 Comments Off

I was recently doing something like the following in Matlab:

im1 = imread(‘im1.jpg’);

im2 = imread(‘im2.jpg’);

if sum((im1(:)-im2(:)).^2) < 1e-5, disp(‘Image 1 and 2 are duplicates!!!’), end

So the point of these three lines of code is to compare image 1 and image 2, and if they are sufficiently close (exactly or nearly exactly), call them duplicates.

The preceding code has an interesting non-obvious bug:  For integer-valued jpgs, Matlab loads them as type uint8. The above test will be passed not only if all pixels are the same, but also if every pixel in im2 is brighter than every pixel in im1. This is because, with unsigned integers, 1-2 = 0.

So I had a very washed out image in my image set that was testing as a duplicate of many images, just because nearly all pixels in the saturated image were 255, and x-255=0 for all unsigned x.