educelab.imgproc.pca

Wrapper functions for calculating and applying Principal Component Analysis on multichannel images.

See: sklearn.decomposition.PCA

educelab.imgproc.pca.apply_transform(x, pca) ndarray

Apply precomputed PCA transforms to a multichannel image.

Parameters:
  • x – Multichannel input image.

  • pca – PCA instance returned by fit().

Returns:

The transformed image.

educelab.imgproc.pca.fit(x, components: int = None, incremental: bool = False, batch_size: int = None, roi=None)

Calculate the first N principal components transforms for x.

Parameters:
  • x – Multichannel image of shape (C, H, W).

  • components – Number of components to compute. Must be in the range 1 < components <= C.

  • incremental – If True, use Incremental PCA. Faster for large datasets at the expense of a slight decrease in accuracy.

  • batch_size – Size of the input batch when using Incremental PCA.

  • roi – If provided, only fit to the given region-of-interest.

Returns:

The fitted PCA instance.