improc.transform package

Submodules

improc.transform.color module

improc.transform.color.convert_colorspace(A, mode=None, drange=None, todrange=False, verbose=False)[source]

convert color sapce

Valid color spaces are: ‘RGB’, ‘HSV’, ‘RGB CIE’, ‘XYZ’, ‘YUV’, ‘YIQ’, ‘YPbPr’, ‘YCbCr’, ‘YDbDr’

Parameters:
  • A ({ndarray}) – The image (\(H×W×C\)) to convert, if \(C=1\), then do nothing; if \(C=3\), do convertion; if \(C>3\), only the first three channels are processed.
  • mode ({str}) – If you want to convert color from space X to Y, just specify mode to 'X2Y', where, X, Y can be any color spaces mentioned above. (default, do nothing)
  • drange ({list or tuple}) – the dynamic range of the pixel-values (typically this is \(2 ^{\# \text { bits per pixel }}-1\).)
  • todrange ({bool}) – If True then convert the convert colorspace image to the range of drange.
  • verbose ({bool}) – If True then show log information.
Returns:

The converted image.

Return type:

ndarray

improc.transform.normal module

improc.transform.normal.normalize(X, mean=None, std=None, axis=None, ver=False)[source]

normalization

\[\bar{X} = \frac{X-\mu}{\sigma} \]
Parameters:
  • X ({numpy ndarray}) – data to be normalized,
  • mean ({list or None}, optional) – mean value (the default is None, which auto computed)
  • std ({list or None}, optional) – standard deviation (the default is None, which auto computed)
  • axis ({bool}, optional) – specify the axis for computing mean value (the default is None, which all elements)
  • axis – if True, also return the mean and std (the default is False, which all elements)

improc.transform.preprocessing module

Functions for pre-processing images.

Functions used by improc functions:

improc.transform.preprocessing.denormalization(X, mod, meanX=None, stdX=None, minX=None, maxX=None)[source]
improc.transform.preprocessing.imgdtype(arr, tdtype=None, isscale=False)[source]

Converts an numpy array to an image data type.

Parameters:
  • arr (numpy array) – Numpy array that you want to converted.
  • dtype (str or None) – The target data type, if not given, does not change. Supports dtype: ‘uint8’, ‘uint16’, ‘uint32’, ‘uint64’, ‘int64’, ‘int32’, ‘int16’, ‘int8’, ‘float’, ‘float64’, ‘float32’, ‘float16’. Note: if float, arr will be scaled to [0, 1]
  • isscale (bool, or None) –

    Specifies whether to scale data into the target dtype range, If not given, or False, does not scale arr data. This is helpfull when some elements in arr are beyond the target dtype range, sets isscale to True, will scale data to target dtype range; sets False or None, will truncate arr into target dtype range. e.g. If target dtype: uint8, and isscale=True,

    then -1 -> 0, 256 -> 255
Returns:

arr – Numpy array with target dtype.

Return type:

numpy array

improc.transform.preprocessing.normalization(X, mod, scalefrom=None, scaleto=None)[source]

data normalization

Parameters:
  • {data to be normalized} -- [data to be normalized] (X) –
  • {[type]} -- 'zscore', 'minmax' (mod) –
Keyword Arguments:
 
  • {[type]} -- [description] (default (scaleto) – {None})
  • {[type]} -- [description] (default – {None})
improc.transform.preprocessing.scalearr(X, scaleto=[0, 1], scalefrom=None, istrunc=True, rich=False)[source]

Scale data.

\[x \in [a, b] \rightarrow y \in [c, d] \]
\[y = (d-c)*(x-a) / (b-a) + c. \]
Parameters:
  • X (array_like) – The data to be scaled.
  • scaleto (tuple, list, optional) – Specifies the range of data after beening scaled. Default [0, 1].
  • scalefrom (tuple, list, optional) – Specifies the range of data. Default [min(X), max(X)].
  • istrunc (bool) – Specifies wether to truncate the data to [a, b], For example, If scalefrom == [a, b] and ‘istrunc’ is true, then X[X < a] == a and X[X > b] == b.
  • rich (bool) – If you want to see what the data is scaled from and scaled to, then you should set it to true
Returns:

  • out (ndarray) – Scaled data array.
  • scalefrom, scaleto (list or tuple) – If rich is true, they will also be returned

Module contents