immse

Mean-squared error

Syntax

err = immse(X,Y)

Description

example

err = immse(X,Y) calculates the mean-squared error (MSE) between the arrays X and Y. X and Y can be arrays of any dimension, but must be of the same size and class.

Examples

collapse all

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

Input Arguments

collapse all

Input array, specified as a nonsparse, numeric array.

Example: err = immse(I,I2);

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Input arrays, specified as a nonsparse, numeric array.

Example: err = immse(I,I2);

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32

Output Arguments

collapse all

Mean-squared error, returned as a scalar of class double. If the input arguments are of class single, err is of class single

Extended Capabilities

See Also

| | | | |

Introduced in R2014b