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)
Initialize
ReinhardNormalizer.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 separate 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.self (ReinhardNormalizer)
- Return type:
None
- get_mean_std(img)[source]¶
Get mean and standard deviation of each channel.
- Parameters:
img (
numpy.ndarrayof typenumpy.uint8) – Input image.self (ReinhardNormalizer)
- Returns:
- Return type:
- static lab_split(img)[source]¶
Convert from RGB uint8 to LAB and split into channels.
- Parameters:
img (
numpy.ndarrayof typenumpy.uint8) – Input image.- Returns:
- Return type:
- static merge_back(chan1, chan2, chan3)[source]¶
Take separate LAB channels and merge back to give RGB uint8.
- Parameters:
- Returns:
Merged image.
- Return type:
- transform(img)[source]¶
Transform an image.
- Parameters:
img (
numpy.ndarrayof typenumpy.uint8) – Input image.self (ReinhardNormalizer)
- Returns:
Colour normalized RGB image.
- Return type:
numpy.ndarrayof typenumpy.float