ReinhardNormalizer¶
- class ReinhardNormalizer[source]¶
Reinhard colour normalizer.
Normalize a patch colour to the target image using the method of:
Reinhard, Erik, et al. “Color transfer between images.” IEEE Computer graphics and applications 21.5 (2001): 34-41.
This class contains code inspired by StainTools [https://github.com/Peter554/StainTools] written by Peter Byfield.
Examples
>>> from tiatoolbox.tools.stainnorm import ReinhardNormalizer >>> norm = ReinhardNormalizer() >>> norm.fit(target_img) >>> norm_img = norm.transform(src_img)
Methods
Fit to a target image.
Get mean and standard deviation of each channel.
Convert from RGB uint8 to LAB and split into channels.
Take seperate LAB channels and merge back to give RGB uint8.
Transform an image.
- fit(target)[source]¶
Fit to a target image.
- Parameters
target (
numpy.ndarrayof typenumpy.uint8) – target image.
- get_mean_std(img)[source]¶
Get mean and standard deviation of each channel.
- Parameters
img (
numpy.ndarrayof typenumpy.uint8) – Input image.- Returns
mean values for each RGB channel. stds (float): standard deviation for each RGB channel.
- Return type
means (float)
- static lab_split(img)[source]¶
Convert from RGB uint8 to LAB and split into channels.
- Parameters
img (
numpy.ndarrayof typenumpy.uint8) – Input image.- Returns
L. chan2 (float): A. chan3 (float): B.
- Return type
chan1 (float)
- static merge_back(chan1, chan2, chan3)[source]¶
Take seperate LAB channels and merge back to give RGB uint8.
- transform(img)[source]¶
Transform an image.
- Parameters
img (
numpy.ndarrayof typenumpy.uint8) – Input image.- Returns
- colour normalized RGB
image.
- Return type
numpy.ndarrayof typenumpy.float