Read image and display it.
ref = imread('pout.tif'); imshow(ref)
Create another image by adding noise to a copy of the reference image.
A = imnoise(ref,'salt & pepper', 0.02); imshow(A)
Calculate mean-squared error between the two images.
err = immse(A, ref); fprintf('\n The mean-squared error is %0.4f\n', err);
The mean-squared error is 353.7631
X— Input array
Input array, specified as a numeric array of any dimension.
err— Mean-squared error
Mean-squared error, returned as a positive number. The data type of
double unless the input arguments are of data type
single, in which case
err is of
immse supports the generation of C
code (requires MATLAB®
Coder™). For more information, see Code Generation for Image Processing.