paralleldomain.utilities.color_matcher¶
Contains classes for statistical matching of image color statistics. This is one of the simplest and least artifact causing image style transfer techniques. We found that properly calibrated hue transform improves performance across several tasks.
- class ColorMatcher(transformation_matrix)¶
Precomputed transform that can be applied to images to match the color distributions of two datasets.
- Parameters:
transformation_matrix (ndarray) –
- __matmul__(other)¶
Applies the color matching to a rgb/rgba image
- static from_distributions(source, target)¶
Calculates the color transform from source to target distribution
- Return type:
- Parameters:
source (GaussianColorDistribution) –
target (GaussianColorDistribution) –
- class GaussianColorDistribution¶
Tracks per channel mean and variance in LAB space
- static from_dataset(dataset, use_tqdm=True, max_samples=-1)¶
Calculates color statistics of images in a dataset
- Parameters:
- Return type:
- Returns:
The color distribution object
- static from_folder(image_folder, use_tqdm=True)¶
Calculates color statistics of all images in a folder. Note that this only works on flat folders right now
- Parameters:
- Return type:
- Returns:
The color distribution object
- static from_image_stream(image_stream, use_tqdm=True)¶
Calculates the statistics of all images in the given image stream
- Parameters:
- Return type:
- Returns:
The color distribution object
- update(x, mask=None)¶
adds the image colors to the color statistics