简体   繁体   English

计算两个图像Matlab之间的平均绝对误差

[英]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: 我想在Matlab中计算两个图像之间的平均绝对误差,并将其命名为MAE,代码如下:

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)

There's no need to evaluate the min() , max() , mean() for the first image in order to evaluate the MAE. 无需评估第一张图像的min()max()mean()即可评估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是两个图像xy相应像素之间的(L1-范数)差之和(除以像素数),因此您可以简单地将其评估为:

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

where numel() is a function that returns the number of elements in its argument. 其中numel()是一个函数,该函数返回其参数中的元素数。 In your case since x and y have the same number of elements you can either put numel(x) or numel(y) . 在您的情况下,由于xy具有相同数量的元素,因此可以放置numel(x)numel(y)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM