Abdelrahman Shalata
Abdelrahman Shalata

Reputation: 47

Compute the mean absolute error between two image matlab

I want to Compute the mean absolute error between two image in Matlab and named it MAE there is the code:

x=imread('duck.jpg');
imshow(x)
xmin=min(x);
xmax = max(x);
xmean=mean(x);
I = double(x) / 255;
v = var(I(:));
y = imnoise(x, 'gaussian', 0, v / 10);
y = double(y) / 255;
imshow(y)

Upvotes: 0

Views: 5991

Answers (1)

AlessioX
AlessioX

Reputation: 3177

There's no need to evaluate the min(), max(), mean() for the first image in order to evaluate the MAE.
Since the MAE is the sum of the (L1-norm) differences between corresponding pixels in your two images x and y (divided by the number of pixels), you can simply evaluate it as:

MAE=sum(abs(x(:)-y(:)))/numel(x);

where numel() is a function that returns the number of elements in its argument. In your case since x and y have the same number of elements you can either put numel(x) or numel(y).

Upvotes: 4

Related Questions