function [ dist ] = imgdist( im1, im2 )
%imgdist Calculates the histogram difference between two images

[rc1, rx1] = imhist(im1(:,:,1));
[rc2, rx2] = imhist(im2(:,:,1));

[gc1, gx1] = imhist(im1(:,:,2));
[gc2, gx2] = imhist(im2(:,:,2));

[bc1, bx1] = imhist(im1(:,:,3));
[bc2, bx2] = imhist(im2(:,:,3));

rdist = rc1 - rc2;
gdist = gc1 - gc2;
bdist = bc1 - bc2;

dist = sum(rdist .* rdist + gdist .* gdist + bdist .* bdist);

end












