示例#1
0
    def expmap(self, sd_vectors):
        if len(sd_vectors.shape) < 3:
            sd_vectors = sd_vectors[None, ...]

        gx = sd_vectors[..., 0]
        gy = sd_vectors[..., 1]
        gz = sd_vectors[..., 2]
        sgz = sd_vectors[..., 3]

        gzsgz = np.sqrt(gz**2 + sgz**2)

        gxgy = np.sqrt(gx**2 + gy**2)

        gx = gx / gxgy
        gy = gy / gxgy
        gz = gz / gzsgz
        sgz = sgz / gzsgz

        phi = np.arctan2(gy, gx)
        theta = np.arctan2(sgz, gz)

        cart = sph2cart(phi, theta, np.ones_like(phi), theta_origin='z')
        cart[np.isnan(cart)] = 0.0

        return cart
示例#2
0
    def expmap(self, sd_vectors):
        if len(sd_vectors.shape) < 3:
            sd_vectors = sd_vectors[None, ...]

        gx = sd_vectors[..., 0]
        gy = sd_vectors[..., 1]
        gz = sd_vectors[..., 2]
        sgz = sd_vectors[..., 3]

        gzsgz = np.sqrt(gz ** 2 + sgz ** 2)

        gxgy = np.sqrt(gx ** 2 + gy ** 2)

        gx = gx / gxgy
        gy = gy / gxgy
        gz = gz / gzsgz
        sgz = sgz / gzsgz

        phi = np.arctan2(gy, gx)
        theta = np.arctan2(sgz, gz)

        cart = sph2cart(phi, theta, np.ones_like(phi), theta_origin='z')
        cart[np.isnan(cart)] = 0.0

        return cart
示例#3
0
    def expmap(self, tangent_vectors):
        # If we've been passed a single vector to map, then add the extra axis
        # Number of sample first
        if len(tangent_vectors.shape) < 3:
            tangent_vectors = tangent_vectors[None, ...]

        eps = np.spacing(1)

        rho = np.sqrt(tangent_vectors[..., 0]**2 + tangent_vectors[..., 1]**2)
        Z = np.exp(
            np.arctan2(tangent_vectors[..., 1], tangent_vectors[..., 0]) * 1j)
        V1 = rho * np.real(Z)
        V2 = rho * np.imag(Z)

        # To prevent divide by 0 warnings when rho is 0
        ir = rho == 0
        rho[ir] = eps
        c = rho

        c[ir] = eps

        Y = np.real(
            np.arcsin(
                np.cos(c) * np.sin(self.long0lat1[..., 1]) +
                np.cos(self.long0lat1[..., 1]) * np.sin(c) * V2 / rho))
        X = np.real(self.long0lat1[..., 0] + np.arctan2(
            V1 * np.sin(c),
            np.cos(self.long0lat1[..., 1]) * np.cos(c) * rho -
            np.sin(self.long0lat1[..., 1]) * V2 * np.sin(c)))

        ns = sph2cart(X - np.pi, Y, np.ones_like(Y))
        # Swap x and y axes
        ns[..., [0, 1]] = ns[..., [1, 0]]
        ns[..., 1] = -ns[..., 1]

        return ns
示例#4
0
文件: aep.py 项目: patricksnape/sfs
    def expmap(self, tangent_vectors):
        # If we've been passed a single vector to map, then add the extra axis
        # Number of sample first
        if len(tangent_vectors.shape) < 3:
            tangent_vectors = tangent_vectors[None, ...]

        eps = np.spacing(1)

        rho = np.sqrt(tangent_vectors[..., 0] ** 2 +
                      tangent_vectors[..., 1] ** 2)
        Z = np.exp(np.arctan2(tangent_vectors[..., 1],
                              tangent_vectors[..., 0]) * 1j)
        V1 = rho * np.real(Z)
        V2 = rho * np.imag(Z)

        # To prevent divide by 0 warnings when rho is 0
        ir = rho == 0
        rho[ir] = eps
        c = rho

        c[ir] = eps

        Y = np.real(np.arcsin(np.cos(c) * np.sin(self.long0lat1[..., 1]) +
                              np.cos(self.long0lat1[..., 1]) *
                              np.sin(c) * V2 / rho))
        X = np.real(self.long0lat1[..., 0] +
                    np.arctan2(V1 * np.sin(c), np.cos(self.long0lat1[..., 1]) *
                    np.cos(c) * rho - np.sin(self.long0lat1[..., 1]) *
                    V2 * np.sin(c)))

        ns = sph2cart(X - np.pi, Y, np.ones_like(Y))
        # Swap x and y axes
        ns[..., [0, 1]] = ns[..., [1, 0]]
        ns[..., 1] = -ns[..., 1]

        return ns
示例#5
0
yaleb_path = '/mnt/atlas/databases/yaleb'
yaleb_subjects = ['yaleB01', 'yaleB02', 'yaleB03', 'yaleB04', 'yaleB05',
                  'yaleB06', 'yaleB07', 'yaleB08', 'yaleB09', 'yaleB10']
feature_spaces = ['aep', 'cosine', 'normal', 'pga', 'spherical']

# Create the tuples of images to use for photometric stereo and build the
# lights
image_light_paths = [('{0}_P00A+000E+00.pgm', 0.0, 0.0),
                     ('{0}_P00A+000E-20.pgm', 0.0, -20.0),
                     ('{0}_P00A+020E-40.pgm', 20.0, -40.0),
                     ('{0}_P00A-020E-40.pgm', -20.0, -40.0),
                     ('{0}_P00A+035E+40.pgm', 35.0, 40.0),
                     ('{0}_P00A-035E+15.pgm', -35.0, 40.0)]
azimuths = np.asarray([np.radians(light[1]) for light in image_light_paths])
elevations = np.asarray([np.radians(light[2]) for light in image_light_paths])
lights = sph2cart(azimuths, elevations, np.ones(azimuths.shape[0]),
                  theta_origin='z')
lights[:, [0, 1]] = lights[:, [1, 0]]
sfs_light = lights[0, :]

# (Subject, Feature space) - Alphabetical order
mean_depth_error_results = np.zeros([len(yaleb_subjects),
                                     len(feature_spaces)])
mean_angular_error_results = np.zeros([len(yaleb_subjects),
                                       len(feature_spaces)])

# (Subject, Feature space) - Alphabetical order
std_depth_error_results = np.zeros([len(yaleb_subjects),
                                    len(feature_spaces)])
std_angular_error_results = np.zeros([len(yaleb_subjects),
                                      len(feature_spaces)])