MATLAB: Is this how to calculate Mean Square Error for two images

brisqueImage Processing Toolboxmsemultissimniqenoise metricspiqepsnrssim

I have two images: lena (the original) and image_new (the reconstructed image). I would like to calculate the MSE. My code below is not working – any idea why? Matlab keeps saying there are not enough input arguments.
function MSE= MSE(lena, image_new);
[M, N] = size(lena);
error = lena - (image_new);
MSE = sum(sum(error .* error)) / (M * N);
disp(MSE);
end

Best Answer

I tried out your code and it works fine.
Are you sure that you are not using the run (F5) to test your function?
Your code works fine with
mse = MSE (img1, img2);
in the command line or within a script.
Related Question