This documentation is for scikit-learn version 0.10Other versions

Citing

If you use the software, please consider citing scikit-learn.

This page

8.7.1.5. sklearn.feature_extraction.image.PatchExtractor

class sklearn.feature_extraction.image.PatchExtractor(patch_size, max_patches=None, random_state=None)

Extracts patches from a collection of images

Parameters :

patch_size: tuple of ints (patch_height, patch_width) :

the dimensions of one patch

max_patches: integer or float, optional default is None :

The maximum number of patches per image to extract. If max_patches is a float in (0, 1), it is taken to mean a proportion of the total number of patches.

random_state: int or RandomState :

Pseudo number generator state used for random sampling.

Methods

fit(X[, y]) Do nothing and return the estimator unchanged
set_params(**params) Set the parameters of the estimator.
transform(X) Transforms the image samples in X into a matrix of patch data.
__init__(patch_size, max_patches=None, random_state=None)
fit(X, y=None)

Do nothing and return the estimator unchanged

This method is just there to implement the usual API and hence work in pipelines.

set_params(**params)

Set the parameters of the estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The former have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns :self :
transform(X)

Transforms the image samples in X into a matrix of patch data.

Parameters :

X : array, shape = (n_samples, image_height, image_width) or

(n_samples, image_height, image_width, n_channels) Array of images from which to extract patches. For color images, the last dimension specifies the channel: a RGB image would have n_channels=3.

Returns :

patches: array, shape = (n_patches, patch_height, patch_width) or :

(n_patches, patch_height, patch_width, n_channels) The collection of patches extracted from the images, where n_patches is either n_samples * max_patches or the total number of patches that can be extracted.