Esempio n. 1
0
 def _warp_template(self, template, group, reference_shape, scale_index,
                    prefix, verbose):
     reference_frame = build_patch_reference_frame(
         reference_shape, patch_shape=self.patch_shape[scale_index])
     shape = template.landmarks[group].lms
     return warp_images([template], [shape], reference_frame, self.transform,
                        prefix=prefix, verbose=verbose)
Esempio n. 2
0
 def _warp_template(self, template, group, reference_shape, scale_index,
                    prefix, verbose):
     reference_frame = build_patch_reference_frame(
         reference_shape, patch_shape=self.patch_shape[scale_index])
     shape = template.landmarks[group]
     return warp_images([template], [shape], reference_frame, self.transform,
                        prefix=prefix, verbose=verbose)
Esempio n. 3
0
    def _instance(self, shape_instance, template):
        landmarks = template.landmarks["source"].lms

        reference_frame = build_patch_reference_frame(shape_instance, patch_shape=self.patch_shape)

        transform = self.transform(reference_frame.landmarks["source"].lms, landmarks)

        return template.as_unmasked().warp_to_mask(reference_frame.mask, transform, warp_landmarks=True)
Esempio n. 4
0
 def _build_shape_model(self, shapes, scale_index):
     mean_aligned_shape = mean_pointcloud(align_shapes(shapes))
     self.n_landmarks = mean_aligned_shape.n_points
     self.reference_frame = build_patch_reference_frame(
         mean_aligned_shape, patch_shape=self.patch_shape[scale_index])
     dense_shapes = densify_shapes(shapes, self.reference_frame,
                                   self.transform)
     # build dense shape model
     shape_model = build_shape_model(dense_shapes)
     return shape_model
Esempio n. 5
0
 def _build_shape_model(self, shapes, scale_index):
     mean_aligned_shape = mean_pointcloud(align_shapes(shapes))
     self.n_landmarks = mean_aligned_shape.n_points
     self.reference_frame = build_patch_reference_frame(
         mean_aligned_shape, patch_shape=self.patch_shape[scale_index]
     )
     dense_shapes = densify_shapes(shapes, self.reference_frame, self.transform)
     # Build dense shape model
     max_sc = self.max_shape_components[scale_index]
     return self._shape_model_cls[scale_index](dense_shapes, max_n_components=max_sc)
Esempio n. 6
0
 def _build_shape_model(self, shapes, scale_index):
     mean_aligned_shape = mean_pointcloud(align_shapes(shapes))
     self.n_landmarks = mean_aligned_shape.n_points
     self.reference_frame = build_patch_reference_frame(
         mean_aligned_shape, patch_shape=self.patch_shape[scale_index])
     dense_shapes = densify_shapes(shapes, self.reference_frame,
                                   self.transform)
     # Build dense shape model
     max_sc = self.max_shape_components[scale_index]
     return self._shape_model_cls[scale_index](dense_shapes,
                                               max_n_components=max_sc)
Esempio n. 7
0
    def _instance(self, shape_instance, template):
        landmarks = template.landmarks['source']

        reference_frame = build_patch_reference_frame(
            shape_instance, patch_shape=self.patch_shape)

        transform = self.transform(
            reference_frame.landmarks['source'], landmarks)

        return template.as_unmasked().warp_to_mask(
            reference_frame.mask, transform, warp_landmarks=True)
Esempio n. 8
0
    def _instance(self, scale_index, shape_instance, appearance_instance):
        template = self.appearance_models[scale_index].mean()
        landmarks = template.landmarks['source'].lms

        reference_frame = build_patch_reference_frame(
            shape_instance, patch_shape=self.patch_shape[scale_index])

        transform = self.transform(
            reference_frame.landmarks['source'].lms, landmarks)

        return appearance_instance.as_unmasked().warp_to_mask(
            reference_frame.mask, transform, warp_landmarks=True)
Esempio n. 9
0
    def _instance(self, scale_index, shape_instance, appearance_instance):
        template = self.appearance_models[scale_index].mean()
        landmarks = template.landmarks['source'].lms

        reference_frame = build_patch_reference_frame(
            shape_instance, patch_shape=self.patch_shape[scale_index])

        transform = self.transform(
            reference_frame.landmarks['source'].lms, landmarks)

        return appearance_instance.as_unmasked(copy=False).warp_to_mask(
            reference_frame.mask, transform, warp_landmarks=True)
Esempio n. 10
0
 def _warp_images(self, images, shapes, reference_shape, scale_index,
                  prefix, verbose):
     reference_frame = build_patch_reference_frame(
         reference_shape, patch_shape=self.patch_shape[scale_index])
     return warp_images(images, shapes, reference_frame, self.transform,
                        prefix=prefix, verbose=verbose)
Esempio n. 11
0
 def _warp_images(self, images, shapes, reference_shape, scale_index,
                  prefix, verbose):
     reference_frame = build_patch_reference_frame(
         reference_shape, patch_shape=self.patch_shape[scale_index])
     return warp_images(images, shapes, reference_frame, self.transform,
                        prefix=prefix, verbose=verbose)