def test_squared_even_patches(): image = mio.import_builtin_asset('breakingbad.jpg') patch_shape = (16, 16) patches = extract_local_patches_fast(image, image.landmarks['PTS'].lms, patch_shape) print(patches.shape) assert (patches.shape == (68, ) + patch_shape + (3, ))
def test_squared_even_patches(): image = mio.import_builtin_asset('breakingbad.jpg') patch_shape = (16, 16) patches = extract_local_patches_fast( image, image.landmarks['PTS'].lms, patch_shape) print patches.shape assert(patches.shape == (68,) + patch_shape + (3,))
def features(self, image, shape): r""" Method that extracts the features for the regression, which in this case are patch based. Parameters ---------- image : :map:`MaskedImage` The current image. shape : :map:`PointCloud` The current shape. """ # extract patches patches = extract_local_patches_fast(image, shape, self.patch_shape) features = np.zeros((shape.n_points, self._feature_patch_length)) for j, patch in enumerate(patches): # build patch image patch_img = Image(patch, copy=False) # compute features features[j, ...] = compute_features( patch_img, self.regression_features).as_vector() return np.hstack((features.ravel(), 1))
def test_nonsquared_odd_patches(): image = mio.import_builtin_asset('breakingbad.jpg') patch_shape = (15, 17) patches = extract_local_patches_fast( image, image.landmarks['PTS'].lms, patch_shape) assert(patches.shape == (68,) + patch_shape + (3,))