我想计算两个3D表面网格X和Y之间的PSNR,我想知道PSNR=20*log(bounding box diagonal/RMSE)
RMSE=max((d(X,Y),d(Y,X))
和d(X,Y)=sqrt (1/area(x))*integral(d(x,Y)^2 dx))
。
你能告诉我我的代码是否正确,因为它给出了异常的负值。
//distance between two points
function d = distance(p,p2 )
diffx=p(1)-p2(1);
diffy=p(2)-p2(2);
diffz=p(3)-p2(3);
d=sqrt(diffx^2+diffy^2+diffz^2);
// Distance point-surface :
function min = min_distance(p,v )
m=1000000;
for i=1:size(v,1)% v has n rows and 3 columns (x,y,z)
point=v(i,:);
d=distance(p,point);
if (d<m)
m=d;
end
end
min=m;
end
//Distance surface-surface
function s= som_min_dist(v1,v2)
s=0;
for i=1: size(v1,1);
p=v1(i,:);
s=s+min_distance(p,v2)^2;
end
end
//RMSE: Root mean square error = max (Drmse(Q,R),Drmse(Q,R))
[volume1,area1]=volume_area_3D(v1)// this function is already verified
[volume2,area2]=volume_area_3D(v2)
d1=som_min_dist(v1,v2)
d2=som_min_dist(v2,v1)
rmse1= sqrt((1/area1)*d1)
rmse2= sqrt((1/area2)*d2)
rmse=max(rmse1,rmse2)
psnr=20*log(bounding_box_diagonal/rmse)//bounding_box is alreay calculated