def _interpolateNormalAMG(self, N0_32F, W_32F, A_8U): h, w = N0_32F.shape[:2] A_c, b_c = normalConstraints(W_32F, N0_32F) A_8U = None if self._image.shape[2] == 4: A_8U = to8U(alpha(self._image)) A_sil, b_sil = silhouetteConstraints(A_8U) A_L = laplacianMatrix((h, w)) A = 10.0 * A_c + A_L + A_sil b = 10.0 * b_c + b_sil N_32F = amg_solver.solve(A, b).reshape(h, w, 3) N_32F = normalizeImage(N_32F) return N_32F
def _computeDetailNormal(self, N0_32F): h, w = N0_32F.shape[:2] W_32F = np.zeros((h, w)) # sigma_d = 2.0 * np.max(N0_32F[:, :, 2]) # W_32F = 1.0 - np.exp( - (N0_32F[:, :, 2] ** 2) / (sigma_d ** 2)) W_32F = 1.0 - N0_32F[:, :, 2] W_32F *= 1.0 / np.max(W_32F) W_32F = W_32F ** 1.5 A_c, b_c = amg_constraints.normalConstraints(W_32F, N0_32F) A_L = amg_constraints.laplacianMatrix((h, w)) lambda_d = 2.0 A = A_c + lambda_d * A_L b = b_c N_32F = amg_solver.solve(A, b).reshape(h, w, 3) N_32F = computeNz(N_32F.reshape(-1, 3)).reshape(h, w, 3) N_32F = normalizeImage(N_32F) return N_32F
def _computeDetailNormal(self, N0_32F): h, w = N0_32F.shape[:2] W_32F = np.zeros((h, w)) # sigma_d = 2.0 * np.max(N0_32F[:, :, 2]) # W_32F = 1.0 - np.exp( - (N0_32F[:, :, 2] ** 2) / (sigma_d ** 2)) W_32F = 1.0 - N0_32F[:, :, 2] W_32F *= 1.0 / np.max(W_32F) W_32F = W_32F**1.5 A_c, b_c = amg_constraints.normalConstraints(W_32F, N0_32F) A_L = amg_constraints.laplacianMatrix((h, w)) lambda_d = 2.0 A = A_c + lambda_d * A_L b = b_c N_32F = amg_solver.solve(A, b).reshape(h, w, 3) N_32F = computeNz(N_32F.reshape(-1, 3)).reshape(h, w, 3) N_32F = normalizeImage(N_32F) return N_32F