Example #1
0
    def _computeInitialNormal(self):
        A_8U = self._A_8U
        h, w = A_8U.shape
        N0_32F = silhouetteNormal(A_8U)
        A, b = normalConstraints(A_8U, N0_32F)

        N_flat = amg_solver.solve(A, b)
        N_flat = normalizeVectors(N_flat)
        N_32F = N_flat.reshape(h, w, 3)
        self._N0_32F = N_32F
Example #2
0
    def _computeInitialNormal(self):
        A_8U = self._A_8U
        h, w = A_8U.shape
        N0_32F = silhouetteNormal(A_8U)
        A, b = normalConstraints(A_8U, N0_32F)

        N_flat = amg_solver.solve(A, b)
        N_flat = normalizeVectors(N_flat)
        N_32F = N_flat.reshape(h, w, 3)
        self._N0_32F = N_32F
Example #3
0
def estimateNormal(A_8U):
    h, w = A_8U.shape
    N0_32F = silhouetteNormal(A_8U)
    A, b = normalConstraints(A_8U, N0_32F)

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

    return N0_32F, N_32F
Example #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
Example #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)
Example #8
0
    def _projectBrightness(self):
        I_32F = self._I_32F
        h, w = I_32F.shape[:2]
        I = I_32F.reshape(h * w)

        L = self._L
        N0_32F = self._N0_32F
        N0 = N0_32F.reshape(-1, 3)

        NL = np.dot(N0, L)
        NL_min, NL_max = np.min(NL), np.max(NL)

        I_min, I_max = np.min(I), np.max(I)

        I = NL_min + (NL_max - NL_min) * (I - I_min) / (I_max - I_min)

        dI = I - NL

        N = np.zeros(N0.shape)
        for i in range(3):
            N[:, i] = N0[:, i] + L[i] * dI

        N = normalizeVectors(N)
        self._N_32F = N.reshape(h, w, 3)
Example #9
0
    def _projectBrightness(self):
        I_32F = self._I_32F
        h, w = I_32F.shape[:2]
        I = I_32F.reshape(h * w)

        L = self._L
        N0_32F = self._N0_32F
        N0 = N0_32F.reshape(-1, 3)

        NL = np.dot(N0, L)
        NL_min, NL_max = np.min(NL), np.max(NL)

        I_min, I_max = np.min(I), np.max(I)

        I = NL_min + (NL_max - NL_min) * (I - I_min) / (I_max - I_min)

        dI = I - NL

        N = np.zeros(N0.shape)
        for i in range(3):
            N[:, i] = N0[:, i] + L[i] * dI

        N = normalizeVectors(N)
        self._N_32F = N.reshape(h, w, 3)
Example #10
0
def normalizeImage(N_32F, th=0.0):
    N_flat = N_32F.reshape((-1, 3))
    N_flat_normalized = normalizeVectors(N_flat, th=th)

    N_32F_normalized = N_flat_normalized.reshape(N_32F.shape)
    return N_32F_normalized