评估步骤中的无限值

时间:2017-04-08 11:33:08

标签: matlab relative evaluation depth infinity

我使用机器学习估计了深度图,我想评估我的结果(使用matlab)。深度图和深度为真是具有8位的图像(在评估之前归一化为[0 1])。我使用了relative,rmse和log 10错误来执行评估步骤。

function result = evaluate(estimated,depthTrue,number)
  if(number == 1)
     result = relative(estimated,depthTrue);
  end
  if (number == 2)
      result = log10error(estimated,depthTrue);
  end
  if(number ==3)
      result = rmse(estimated,depthTrue);
  end
end




function result = relative(estimated,depthTrue)
  result = mean(mean(abs(estimated - depthTrue)./depthTrue));
end

function result = log10error(estimated,depthTrue)
  result = mean(mean(abs(log10(estimated) - log10(depthTrue))));
end

function result = rmse(estimated,depthTrue)
  result = sqrt(mean(mean(abs(estimated - depthTrue).^2)));
end

当我尝试使用图像进行评估时,我得到了无穷大值(只有log10error和相对值)。搜索之后,我发现depthTrue和估计值可以有0个值。

log10(0)

ans =

  -Inf
5/0

ans =

   Inf

那么,我该怎么办?

1 个答案:

答案 0 :(得分:0)

我可以想到几种方法来克服这个问题,取决于最适合您需求的方法。你可以忽略inf或者只是用其他值替换它们。例如:

depthTrue = rand(4);
estimated = rand(4);
estimated(1,1) = 0;
% 1) ignore infs
absdiff = abs(log10(estimated(:)) - log10(depthTrue(:)));
result1 = mean( absdiff(~isinf(absdiff)) )
% 2) subtitute infs
veryHighNumber = 1e5;
absdiff(isinf(absdiff)) = veryHighNumber; 
result2 = mean( absdiff )
% 3) subtitute zeros
verySmallNumber = 1e-5;
depthTrue(depthTrue == 0) = verySmallNumber;
estimated(estimated == 0) = verySmallNumber;
absdiff = abs(log10(estimated(:)) - log10(depthTrue(:)));
result3 = mean( absdiff )