Exemplo n.º 1
0
warped_ground_truth_image = ground_truth_images.warp_to(reference_frame.mask, tr)

warped_intensity_image = MaskedNDImage(warped_intensity_image.pixels, mask=warped_intensity_image.mask)
warped_intensity_image.view()

# <codecell>

# Use ground truth light
estimate_light = lights[sfs_index, :]
print estimate_light

# <codecell>

from photometric_stereo import photometric_stereo as ps

ground_truth_normals, ground_truth_albedo = ps(warped_ground_truth_image, lights)

# <codecell>

from pybug.image import MaskedNDImage
from scipy.ndimage.filters import gaussian_filter, median_filter
from geometric_sfs import geometric_sfs as sfs, worthington_hancock_sfs
from mapping import AEP, PGA, Spherical, ImageMapper, IdentityMapper

# mapping_object = ImageMapper(PGA(intrinsic_mean_normals.as_vector(keep_channels=True)))
mapping_object = ImageMapper(Spherical())

warped_intensity_image = MaskedNDImage(warped_intensity_image.pixels.copy(), mask=warped_intensity_image.mask)
mean_normals_image = warped_intensity_image.from_vector(mean_normals, n_channels=3)
# Normalise the image so that it has unit albedo?
warped_intensity_image.masked_pixels /= ground_truth_albedo.masked_pixels
Exemplo n.º 2
0
             '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)
    normals[subject_id]['ground_truth'] = ground_truth_normals

    # TODO: save images
    #ground_truth_depth_image.view(mode='mesh')
    #save_result_images(subject_id, 'all', 'groundtruth')

    for k, feature_space in enumerate(feature_spaces):
        print "Running {0} for {1}".format(feature_space, subject_id)
        model_path = '/vol/atlas/pts08/cvpr/frgc_spring2003_sfs_tps_{0}_{1}.pkl'.format(subject_id, feature_space)
        with open(model_path, 'rb') as f:
            model = cPickle.load(f)
Exemplo n.º 3
0
warped_intensity_image = MaskedNDImage(warped_intensity_image.pixels,
                                       mask=warped_intensity_image.mask)
warped_intensity_image.view()

# <codecell>

# Use ground truth light
estimate_light = lights[sfs_index, :]
print estimate_light

# <codecell>

from photometric_stereo import photometric_stereo as ps

ground_truth_normals, ground_truth_albedo = ps(warped_ground_truth_image,
                                               lights)

# <codecell>

from pybug.image import MaskedNDImage
from scipy.ndimage.filters import gaussian_filter, median_filter
from geometric_sfs import geometric_sfs as sfs, worthington_hancock_sfs
from mapping import AEP, PGA, Spherical, ImageMapper, IdentityMapper
# mapping_object = ImageMapper(PGA(intrinsic_mean_normals.as_vector(keep_channels=True)))
mapping_object = ImageMapper(Spherical())

warped_intensity_image = MaskedNDImage(warped_intensity_image.pixels.copy(),
                                       mask=warped_intensity_image.mask)
mean_normals_image = warped_intensity_image.from_vector(mean_normals,
                                                        n_channels=3)
# Normalise the image so that it has unit albedo?
Exemplo n.º 4
0
import numpy as np
import cv2
import os
from utils import *
from estimate_alb_nrm import estimate_alb_nrm
from check_integrability import check_integrability
from construct_surface import construct_surface
from photometric_stereo import photometric_stereo as ps

file = './photometrics_images/MonkeyGray'

nbr_images = [5, 25, 45, 65, 85, 105, 121]

for n in nbr_images:
    ps(file, n, shadow_trick=False)
Exemplo n.º 5
0
    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
    #ground_truth_depth_image.view(mode='mesh')
    #save_result_images(subject_id, 'all', 'groundtruth')

    for k, feature_space in enumerate(feature_spaces):
        print "Running {0} for {1}".format(feature_space, subject_id)
        model_path = '/vol/atlas/pts08/cvpr/frgc_spring2003_sfs_tps_{0}_{1}.pkl'.format(subject_id, feature_space)
        with open(model_path, 'rb') as f: