Пример #1
0
    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 _computeLumoNormal(self):
        A_8U = self._A_8U

        if A_8U is None:
            return

        h, w = A_8U.shape[:2]
        A_c, b_c = amg_constraints.silhouetteConstraints(A_8U)

        A_L = amg_constraints.laplacianMatrix((h, w))
        A = 3.0 * A_c + A_L
        b = 3.0 * 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)
        self._N_lumo = np.array(N_32F)
Пример #3
0
    def _computeLumoNormal(self):
        A_8U = self._A_8U

        if A_8U is None:
            return

        h, w = A_8U.shape[:2]
        A_c, b_c = amg_constraints.silhouetteConstraints(A_8U)

        A_L = amg_constraints.laplacianMatrix((h, w))
        A = 3.0 * A_c + A_L
        b = 3.0 * 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)
        self._N_lumo = np.array(N_32F)
Пример #4
0
    def _computeInitialNormal(self):
        A_8U = self._A_8U
        self._N0_32F = np.float64(silhouetteNormal(A_8U))

        return

        h, w = A_8U.shape
        A_L = laplacianMatrix((h, w), num_elements=3)
        A_sil, b_sil = silhouetteConstraints(A_8U, is_flat=True)

        A = A_L + A_sil
        b = b_sil

        N = amg_solver.solve(A, b).reshape(-1, 3)
        computeNz(N)
        N = normalizeVectors(N)
        N_32F = N.reshape(h, w, 3)
        self._N0_32F = N_32F
Пример #5
0
    def _computeInitialNormal(self):
        A_8U = self._A_8U
        self._N0_32F = np.float64(silhouetteNormal(A_8U))

        return

        h, w = A_8U.shape
        A_L = laplacianMatrix((h, w), num_elements=3)
        A_sil, b_sil = silhouetteConstraints(A_8U, is_flat=True)

        A = A_L + A_sil
        b = b_sil

        N = amg_solver.solve(A, b).reshape(-1, 3)
        computeNz(N)
        N = normalizeVectors(N)
        N_32F = N.reshape(h, w, 3)
        self._N0_32F = N_32F
    def _runImp(self):
        normal_data = loadNormal(self._data_file)

        if normal_data is None:
            return

        N0_32F, A_8U = normal_data

        h, w = A_8U.shape[:2]
        A_c, b_c = amg_constraints.silhouetteConstraints(A_8U, is_flat=True)

        A_L = amg_constraints.laplacianMatrix((h, w), num_elements=3)
        A = A_c + A_L
        b = b_c

        N = amg_solver.solve(A, b).reshape(-1, 3)
        N = computeNz(N)
        N = normalizeVectors(N)
        N_32F = N.reshape(h, w, 3)

        file_path = self.resultFile(self._data_file_name)
        saveNormal(file_path, N_32F, A_8U)
    def _runImp(self):
        normal_data = loadNormal(self._data_file)

        if normal_data is None:
            return

        N0_32F, A_8U = normal_data

        h, w = A_8U.shape[:2]
        A_c, b_c = amg_constraints.silhouetteConstraints(A_8U, is_flat=True)

        A_L = amg_constraints.laplacianMatrix((h, w), num_elements=3)
        A = A_c + A_L
        b = b_c

        N = amg_solver.solve(A, b).reshape(-1, 3)
        N = computeNz(N)
        N = normalizeVectors(N)
        N_32F = N.reshape(h, w, 3)

        file_path = self.resultFile(self._data_file_name)
        saveNormal(file_path, N_32F, A_8U)