使用Shape通过积分从法线贴图计算深度贴图

问题描述

我正在尝试计算给定法线贴图的深度图。我进行了一些研究,发现可以使用Forsyth&Ponce的形状通过积分方法来完成。我尝试了一个实现,但是它不起作用,它只会返回白色图像。我不确定是否将scipy积分构造错误,或者是否想念它背后的概念。我遵循了第33-37页的this pdf。帮助将不胜感激。 这是我现在拥有的代码:

def fx(s,y,normals):
    s = int(s)
    return normals[s,0]/normals[s,2]

def fy(t,x,normals):
    t=int(t)
    return normals[x,t,1]/normals[x,2]


n_img = np.clip(np.asarray(Image.open("normal.png"),dtype=float) / 255,1)
d_img = np.zeros((n_img.shape[0],n_img.shape[1]))
h,w,d = n_img.shape

for i in range(h-1):
    for j in range(w-1):
        abc = n_img[i,j]
        #this is to reduce the number of calculations done for each integral summation
        x = 0 if i < 35 else (i-34)
        y = 0 if j < 35 else (j - 34)
        #print(i,j,y)
        inte = np.asarray(quad(fx,i,args=(j,n_img))) + np.asarray(quad(fy,args=(i,n_img)))
        #print(np.array([inte[0],inte[1]],dtype=float))
        d_img[i][j] = inte[0]

cv2.imshow("tmp",d_img)
cv2.waitKey()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...