MATLAB: Difficulty finding euclidean distance to match

eucledian distanceimage processingImage Processing ToolboxWavelet Toolbox

I have one query image and 9 images in the MATLAB database–I have to find the Euclidean distance between two images and represent them in a matrix. I have done the following:
G=imread('pout.tif');
H = adapthisteq(G,'clipLimit',0.01,'Distribution','rayleigh');
[c1,s1]=wavedec2(H,1,'db1');
disp(c1);
X=c1;
figure,imshow(G);
figure,imshow(H);
fileFolder=fullfile(matlabroot,'toolbox','images','imdemos');
dirOutput=dir(fullfile(fileFolder,'*.tif'));
fileNames={dirOutput.name}
n=numel(fileNames);
for k = 12 : 20(dirOutput)
fileNames1=strcat('fullfile(fileFolder)',fileNames(k))
I = imread(fileNames{k});
J = adapthisteq(I,'clipLimit',0.01,'Distribution','rayleigh');
[c2,s2]=wavedec2(J,1,'db1');
disp(c2);
Y=c2;
E_distance = sqrt(sum((H-J).^2));
figure,imshow(I);
figure,imshow(J);
end
But I get the following error:
??? Error using ==> unknown
Matrix dimensions must agree.
Error in ==> pihu at 20
E_distance = sqrt(sum((H-J).^2));

Best Answer

What you're calling the Euclidean distance is the RMS difference in intensity between the two images. And that (and PSNR and MSE) is not such a great way to compare images anymore, unless you're looking for a fairly exact match - like you know for a fact that the test image is definitely one of the database images. You'll probably find SSIM is used more often: http://en.wikipedia.org/wiki/SSIM. But I can't run your code because I don't have the Wavelet Toolbox. I've added it to the product list to alert anyone else who might try to run your code.