n : float nu value l : float lambda value Returns ------- B : numpy.ndarray The 3 x P matrix of pesudonormals """ g = np.eye(3) g[2, 0] = m g[2, 1] = n g[2, 2] = l B = np.dot(np.linalg.inv(g).T, B) return B if __name__ == "__main__": I, L_0, s = loadData() B, L = estimatePseudonormalsUncalibrated(I) B = enforceIntegrability(B, s, 3) B = bas_relief(B, 0, 0, 2) albedos, normals = estimateAlbedosNormals(B) albedoIm, normalIm = displayAlbedosNormals(albedos, normals, s) print(L) print(L_0) surface = estimateShape(normals, s) plotSurface(surface)
I, realL, s = I, L, s = loadData() B, L = estimatePseudonormalsUncalibrated(I) print(L) print(realL) _, normalsBad = estimateAlbedosNormals(B) BI = enforceIntegrability(B, s) # albedos, normals = estimateAlbedosNormals(BI) # displayAlbedosNormals(albedos, normals, s) # surf1 = estimateShape(normalsBad, s) # surf2 = estimateShape(normals, s) # plotSurface(np.clip(surf1, -1000, 1000)) # plotSurface(surf2) G = np.eye(3) G[2, 2] = 0 G[2, :] = [10, 0, .7] Ginv = np.linalg.inv(G) Bnew = Ginv.T @ BI _, normals = estimateAlbedosNormals(Bnew) surf = estimateShape(normals, s) plotSurface(surf)
albedos_img, normals_img = displayAlbedosNormals(albedos, normals, shapes) for itr in range(6): lightning_estimated[itr, :] = lightning_estimated[ itr, :] / np.linalg.norm(lightning_estimated, axis=1)[itr] print("ground truth lighting\n", lighting.T) print("estimated lightning\n", lightning_estimated) #2d normals_reshape = np.zeros((3, shapes[0] * shapes[1])) normals_reshape[0, :] = normals_img[:, :, 0].reshape(-1) normals_reshape[1, :] = normals_img[:, :, 1].reshape(-1) normals_reshape[2, :] = normals_img[:, :, 2].reshape(-1) surface_1 = estimateShape(normals_reshape, shapes) plotSurface(surface_1) #2e enforced_pseudo_normals = enforceIntegrability(pseudo_normals, shapes) lamb = 1 v = 0.01 #increases v will decrease the difference along lateral axis mu = 0.01 #increase mu will decrease the depth difference among the faces G = np.asarray([[1, 0, 0], [0, 1, 0], [mu, v, lamb]]) enforced_pseudo_normals = G.T @ enforced_pseudo_normals albedos, normals = estimateAlbedosNormals(enforced_pseudo_normals) albedos_img, normals_img = displayAlbedosNormals(albedos, normals, shapes) normals_reshape = np.zeros((3, shapes[0] * shapes[1]))
plt.show() plt.figure() plt.imshow(normnormalIm, cmap = 'rainbow') plt.show() #2c plt.figure() plt.imshow(L, cmap = 'hot') plt.figure() plt.imshow(Lest, cmap = 'hot') plt.show() #2d surface = estimateShape(normals, s) plotSurface(surface) # #2e Bt = enforceIntegrability(B, s) albedost, normalst = estimateAlbedosNormals(Bt) surfacet = estimateShape(normalst, s) # plotSurface(surfacet) #2f #Bas Relief mu = 0 v = 0 l = 0.000001 G = np.array([[1,0,0],[0,1,0],[mu,v,l]])