示例#1
0
    def interpolate_simple(self, parameters):
        dN1 = self._N1 - self._center
        dN2 = self._N2 - self._center

        dNs = np.array([(1.0 - t) * dN1 + t * dN2 for t in parameters])

        normals = self._center + dNs
        normals = normalizeVectors(normals)

        return normals
示例#2
0
def lumoNormal(A_8U):
    h, w = A_8U.shape
    N0_32F = silhouetteNormal(A_8U)
    A, b = normalConstraints(A_8U, N0_32F)

    N_flat = solveMG(A, b)
    N_flat = normalizeVectors(N_flat)
    N_32F = N_flat.reshape(h, w, 3)

    return N_32F
示例#3
0
def computeTangents(points):
    t1 = np.array(points, dtype=np.float)
    t2 = np.array(points, dtype=np.float)

    t1[1:] = points[1:] - points[:-1]
    t2[:-1] = points[1:] - points[:-1]
    t1[0] = t1[1]
    t2[-1] = t2[-2]

    t = t1

    t = normalizeVectors(t)
    t[:, 1] = - t[:, 1]

    return t
示例#4
0
def projectNormals(L, I, tangents_3D, normals):
    normals_smooth = np.array(normals)
    num_points = len(normals)

    for i in range(num_points):
        T = tangents_3D[i]
        N = normals[i]

        NdL = np.dot(N, L)

        dN_L = (I - NdL) * L

        NdT = np.dot(N, T)
        dN_T = - NdT * T

        normals_smooth[i] = N + dN_L + dN_T
    normals_smooth = normalizeVectors(normals_smooth)
    return normals_smooth
def estimatePhi(N_sil, I_sil):
    num_bins = 16
    I_ids = luminanceClusters(I_sil, num_bins)

    N_centers = np.zeros((num_bins, 3))
    hist = np.zeros((num_bins))

    for ni, I_id in enumerate(I_ids):
        N_centers[I_id] += N_sil[ni]
        hist[I_id] += 1.0

    hist_positive = hist > 0.0

    N_centers[hist_positive] = normalizeVectors(N_centers[hist_positive])

    I_id_max = np.max(np.where(hist_positive))
    L = N_centers[I_id_max]
    L[2] = 0.0
    L = normalizeVector(L)
    return L
示例#6
0
def smoothing3DVectors(vectors_3D, parameters):
    vectors_3D = smoothing(vectors_3D, parameters, smooth=0.01)
    vectors_3D = normalizeVectors(vectors_3D)
    return vectors_3D
示例#7
0
def normalizeImage(N_32F):
    N_flat = N_32F.reshape((-1, 3))
    N_flat_normalized = normalizeVectors(N_flat)

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