color_matcher package

Submodules

color_matcher.baseclass module

class color_matcher.baseclass.MatcherBaseclass(*args, **kwargs)

Bases: object

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

validate_color_chs()

This function checks whether provided images consist of 3 color channels. An exception is thrown otherwise.

validate_img_dims()

This function validates the image dimensions. It throws an exception if the dimension are unequal to 2 or 3.

color_matcher.hist_matcher module

class color_matcher.hist_matcher.HistogramMatcher(*args, **kwargs)

Bases: color_matcher.baseclass.MatcherBaseclass

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

hist_match(src: numpy.ndarray = None, ref: numpy.ndarray = None)numpy.ndarray

This function conducts channel-wise histogram matching which is invariant of image resolutions, but requires the same number of color channels in both images.

Parameters
  • src (ndarray) – Source image that requires transfer

  • ref (ndarray) – Palette image which serves as reference

  • ref – Resulting image after the mapping

Returns

result

Return type

np.ndarray

color_matcher.io_handler module

color_matcher.io_handler.load_img_file(file_path: str = None)numpy.ndarray
color_matcher.io_handler.save_img_file(img, file_path: str = None, file_type: str = None)bool
color_matcher.io_handler.select_file(init_dir=None, title='')

get filepath from tkinter dialog

color_matcher.io_handler.suppress_user_warning(switch=None, category=None)

color_matcher.mvgd_matcher module

class color_matcher.mvgd_matcher.TransferMVGD(*args, **kwargs)

Bases: color_matcher.baseclass.MatcherBaseclass

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

analytical_solver()numpy.ndarray

An analytical solution to the linear equation system of MVGDs.

Returns

transfer_mat: Transfer matrix

Return type

np.ndarray

mkl_solver()

This function computes the transfer matrix based on the Monge-Kantorovich linearization.

Returns

transfer_mat: Transfer matrix

Return type

np.ndarray

transfer(src: numpy.ndarray = None, ref: numpy.ndarray = None, fun: function = None)numpy.ndarray

Transfer function to map colors based on for Multi-Variate Gaussian Distributions (MVGDs).

Parameters
  • src (ndarray) – Source image that requires transfer

  • ref (ndarray) – Palette image which serves as reference

  • fun – optional argument to pass a transfer function to solve for covariance matrices

  • res (ndarray) – Resulting image after the mapping

Returns

res

Return type

np.ndarray

color_matcher.normalizer module

class color_matcher.normalizer.Normalizer(data=None, min=None, max=None)

Bases: object

__init__(data=None, min=None, max=None)

Initialize self. See help(type(self)) for accurate signature.

norm_fun()

normalize image to values between 1 and 0

type_norm(data=None, min=None, max=None, new_min=None, new_max=None)

normalize numpy image array for provided data type

uint16_norm()

normalize image array to 16-bit unsigned integer

uint8_norm()

normalize image array to 8-bit unsigned integer

color_matcher.top_level module

class color_matcher.top_level.ColorMatcher(*args, **kwargs)

Bases: color_matcher.hist_matcher.HistogramMatcher, color_matcher.mvgd_matcher.TransferMVGD, color_matcher.reinhard_matcher.ReinhardMatcher

__init__(*args, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

main(method: str = None)numpy.ndarray

The main function and high-level entry point performing the mapping. Valid methods are

Parameters

method (str) – (‘default’, ‘mvgd’, ‘hm’, ‘hm-mkl-hm’, ‘reinhard’) describing how to conduct color mapping

Returns

Resulting image after color mapping

Return type

np.ndarray

Module contents