2017-04-08 87 views
0

我使用機器學習估計了深度圖,並且我想評估我的結果(使用matlab)。深度圖和深度真是帶有8位的圖像(在評估之前歸一化爲[0 1])。我用相對,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 

那麼,我該怎麼辦?

回答

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) 
+0

thnx先生,我發現解決方案我用米(0不存在)的值。 –