Esempio n. 1
0
                        for im in subject_images], axis=2))

    # Choose the third image as the reconstruction candidate
    intensity_image = subject_images[sfs_index].as_greyscale()
    # The first image is the only landmarked one
    intensity_image.landmarks = subject_images[0].landmarks

    # Pass landmarks to all ground truth images
    ground_truth_images.landmarks['PTS'] = intensity_image.landmarks['PTS']

    # Label with correct labels
    labeller([ground_truth_images, intensity_image],
             'PTS', ibug_68_closed_mouth)

    # Constrain to mask
    ground_truth_images.constrain_mask_to_landmarks(
        group='ibug_68_closed_mouth', label='all')
    intensity_image.constrain_mask_to_landmarks(
        group='ibug_68_closed_mouth', label='all')
    intensity_image.crop_to_landmarks(group='ibug_68_closed_mouth',
                                      label='all', boundary=2)
    ground_truth_images.crop_to_landmarks(group='ibug_68_closed_mouth',
                                          label='all', boundary=2)

    temp_texture = subject_images[sfs_index]

    # Perform Photometric Stereo
    ground_truth_normals, ground_truth_albedo = ps(ground_truth_images, lights)
    ground_truth_depth = frankotchellappa(-ground_truth_normals.pixels[:, :, 0],
                                          ground_truth_normals.pixels[:, :, 1])
    ground_truth_depth_image = DepthImage((ground_truth_depth - np.min(ground_truth_depth)) / 2,
                                          texture=temp_texture)
Esempio n. 2
0
        np.concatenate([im.pixels
                        for im in subject_images], axis=2))

    # Choose the first image as the reconstruction candidate
    # (frontal illumination)
    intensity_image = deepcopy(subject_images[0])

    # Pass landmarks to all ground truth images
    ground_truth_images.landmarks['PTS'] = intensity_image.landmarks['PTS']

    # Label with correct labels
    labeller([ground_truth_images, intensity_image],
             'PTS', ibug_68_closed_mouth)

    # Constrain to mask
    ground_truth_images.constrain_mask_to_landmarks(
        group='ibug_68_closed_mouth', label='all')
    intensity_image.constrain_mask_to_landmarks(
        group='ibug_68_closed_mouth', label='all')

    temp_texture = RGBImage(np.dstack([subject_images[0].pixels] * 3))

    # Perform Photometric Stereo
    ground_truth_normals, ground_truth_albedo = ps(ground_truth_images, lights)
    ground_truth_depth = frankotchellappa(ground_truth_normals.pixels[:, :, 0],
                                          ground_truth_normals.pixels[:, :, 1])
    ground_truth_depth_image = DepthImage((ground_truth_depth - np.min(ground_truth_depth)),
                                          texture=temp_texture,
                                          mask=intensity_image.mask)
    normals[subject_id]['ground_truth'] = ground_truth_normals

    # TODO: save images