function mse = edgeerror(A, B) % The function takes two equal images and calculates the mean square % difference inbetween the two. % Usage: MSE = MSERROR(A, B, NSIZE); % where A: first image % B: second image % NSIZE: size of the images a=length(find(A>0)); b=length(find(B>0)); A=double(A); B=double(B); diff = abs(A - B); % difference mse=sum(sum(diff))/max(a,b);