Shortcuts

mmagic.models.editors.inst_colorization.color_utils

Module Contents

Functions

xyz2rgb(xyz)

Conversion images from xyz to rgb.

lab2xyz(lab)

Conversion images from lab to xyz.

lab2rgb(lab_rs, color_data_opt)

Conversion images from lab to rgb.

encode_ab_ind(data_ab, color_data_opt)

Encode ab value into an index.

rgb2xyz(rgb)

Conversion images from rgb to xyz

xyz2lab(xyz)

Conversion images from xyz to lab

rgb2lab(rgb, color_opt)

Conversion images from rgb to lab.

get_colorization_data(data_raw, color_opt[, num_points])

Conversion images from rgb to lab.

add_color_patches_rand_gt(data, color_opt[, p, ...])

Add random color points sampled from ground truth based on: Number of

mmagic.models.editors.inst_colorization.color_utils.xyz2rgb(xyz)[source]

Conversion images from xyz to rgb.

Parameters

xyz (tensor) – The images to be conversion

Returns

The converted image

Return type

out (tensor)

mmagic.models.editors.inst_colorization.color_utils.lab2xyz(lab)[source]

Conversion images from lab to xyz.

Parameters

lab (tensor) – The images to be conversion

Returns

The converted image

Return type

out (tensor)

mmagic.models.editors.inst_colorization.color_utils.lab2rgb(lab_rs, color_data_opt)[source]

Conversion images from lab to rgb.

Parameters
  • lab_rs (tensor) – The images to be conversion

  • color_data_opt (dict) – Config for image colorspace transformation. Include: l_norm, ab_norm, l_cent

Returns

The converted image

Return type

out (tensor)

mmagic.models.editors.inst_colorization.color_utils.encode_ab_ind(data_ab, color_data_opt)[source]

Encode ab value into an index.

Parameters
  • data_ab – Nx2xHxW from [-1,1]

  • color_data_opt – Config for image colorspace transformation. ab_max, ab_quant, ab_norm, ab_quant

Returns

Nx1xHxW from [0,Q)

mmagic.models.editors.inst_colorization.color_utils.rgb2xyz(rgb)[source]

Conversion images from rgb to xyz rgb from [0,1] xyz_from_rgb = np.array([[0.412453, 0.357580, 0.180423],

[0.212671, 0.715160, 0.072169], [0.019334, 0.119193, 0.950227]])

Parameters

rgb (Tensor) – image in rgb colorspace

Returns

image in xyz colorspace

Return type

xyz (Tensor)

mmagic.models.editors.inst_colorization.color_utils.xyz2lab(xyz)[source]

Conversion images from xyz to lab xyz from [0,1] factors: 0.95047, 1., 1.08883

Parameters

xyz (Tensor) – image in xyz colorspace

Returns

Image in lab colorspace

Return type

out (Tensor)

mmagic.models.editors.inst_colorization.color_utils.rgb2lab(rgb, color_opt)[source]

Conversion images from rgb to lab.

Parameters
  • data_raw (tensor) – The images to be conversion

  • color_opt (dict) – Config for image colorspace transformation. Include: ab_thresh, ab_norm, sample_PS, mask_cent

Returns

The converted image

Return type

out (tensor)

mmagic.models.editors.inst_colorization.color_utils.get_colorization_data(data_raw, color_opt, num_points=None)[source]

Conversion images from rgb to lab.

Parameters
  • data_raw (tensor) – The images to be conversion

  • color_opt (dict) – Config for image colorspace transformation. Include: ab_thresh, ab_norm, sample_PS, mask_cent

Returns

Output in add_color_patches_rand_gt

Return type

results (dict)

mmagic.models.editors.inst_colorization.color_utils.add_color_patches_rand_gt(data, color_opt, p=0.125, num_points=None, use_avg=True, samp='normal')[source]

Add random color points sampled from ground truth based on: Number of points.

  • if num_points is 0, then sample from geometric distribution,

    drawn from probability p

  • if num_points > 0, then sample that number of points

Location of points - if samp is ‘normal’, draw from N(0.5, 0.25) of image - otherwise, draw from U[0, 1] of image

Parameters
  • data (tensor) – The images to be conversion

  • color_opt (dict) – Config for image colorspace transformation Include: ab_thresh, ab_norm, sample_PS, mask_cent

  • p (float) – Sampling geometric distribution, 1.0 means no hints

  • num_points (int) – Certain number of points

  • use_avg (bool) – Whether to use the mean when add color point Default: True.

  • samp (str) – Geometric distribution or uniform distribution when sample location. Default: normal.

Returns

Result dict from :obj:mmcv.BaseDataset.

Return type

results (dict)

Read the Docs v: latest
Versions
latest
stable
0.x
Downloads
pdf
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.