diff --git a/bob/pad/face/utils/patch_utils.py b/bob/pad/face/utils/patch_utils.py index cd14ec1e6c70a0c28c47d825bb2cca296d3cc3c5..13ac2aa24cfa4124ebbbd3070eb44b6ddac3c4e1 100644 --- a/bob/pad/face/utils/patch_utils.py +++ b/bob/pad/face/utils/patch_utils.py @@ -45,16 +45,10 @@ def reshape_flat_patches(patches, patch_reshape_parameters = None): if patch_reshape_parameters is not None: - if len(patch_reshape_parameters)==2: + # The dimensionality of the reshaped patch: + new_shape = [np.int(len(patch)/(patch_reshape_parameters[-2]*patch_reshape_parameters[-1]))] + list(patch_reshape_parameters[-2:]) - patch = patch.reshape(patch_reshape_parameters[0], - patch_reshape_parameters[1]) # reshape the patch - - elif len(patch_reshape_parameters)==3: - - patch = patch.reshape(patch_reshape_parameters[0], - patch_reshape_parameters[1], - patch_reshape_parameters[2]) # reshape the patch + patch = np.squeeze(patch.reshape(new_shape)) patches_3d.append(patch)