Module: color

skimage.color.combine_stains(stains, conv_matrix) Stain to RGB color space conversion.
skimage.color.convert_colorspace(arr, ...) Convert an image array to a new color space.
skimage.color.deltaE_cie76(lab1, lab2) Euclidean distance between two points in Lab color space
skimage.color.deltaE_ciede2000(lab1, lab2[, ...]) Color difference as given by the CIEDE 2000 standard.
skimage.color.deltaE_ciede94(lab1, lab2[, ...]) Color difference according to CIEDE 94 standard
skimage.color.deltaE_cmc(lab1, lab2[, kL, kC]) Color difference from the CMC l:c standard.
skimage.color.gray2rgb(image) Create an RGB representation of a gray-level image.
skimage.color.guess_spatial_dimensions(image) Make an educated guess about whether an image has a channels dimension.
skimage.color.hed2rgb(hed) Haematoxylin-Eosin-DAB (HED) to RGB color space conversion.
skimage.color.hsv2rgb(hsv) HSV to RGB color space conversion.
skimage.color.lab2lch(lab) CIE-LAB to CIE-LCH color space conversion.
skimage.color.lab2rgb(lab) Lab to RGB color space conversion.
skimage.color.lab2xyz(lab) CIE-LAB to XYZcolor space conversion.
skimage.color.label2rgb(label[, image, ...]) Return an RGB image where color-coded labels are painted over the image.
skimage.color.lch2lab(lch) CIE-LCH to CIE-LAB color space conversion.
skimage.color.luv2rgb(luv) Luv to RGB color space conversion.
skimage.color.luv2xyz(luv) CIE-Luv to XYZ color space conversion.
skimage.color.rgb2gray(rgb) Compute luminance of an RGB image.
skimage.color.rgb2grey(rgb) Compute luminance of an RGB image.
skimage.color.rgb2hed(rgb) RGB to Haematoxylin-Eosin-DAB (HED) color space conversion.
skimage.color.rgb2hsv(rgb) RGB to HSV color space conversion.
skimage.color.rgb2lab(rgb) RGB to lab color space conversion.
skimage.color.rgb2luv(rgb) RGB to CIE-Luv color space conversion.
skimage.color.rgb2rgbcie(rgb) RGB to RGB CIE color space conversion.
skimage.color.rgb2xyz(rgb) RGB to XYZ color space conversion.
skimage.color.rgbcie2rgb(rgbcie) RGB CIE to RGB color space conversion.
skimage.color.separate_stains(rgb, conv_matrix) RGB to stain color space conversion.
skimage.color.xyz2lab(xyz) XYZ to CIE-LAB color space conversion.
skimage.color.xyz2luv(xyz) XYZ to CIE-Luv color space conversion.
skimage.color.xyz2rgb(xyz) XYZ to RGB color space conversion.

combine_stains

skimage.color.combine_stains(stains, conv_matrix)

Stain to RGB color space conversion.

Parameters:

stains : array_like

The image in stain color space, in a 3-D array of shape (.., .., 3).

conv_matrix: ndarray :

The stain separation matrix as described by G. Landini [R31].

Returns:

out : ndarray

The image in RGB format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If stains is not a 3-D array of shape (.., .., 3).

Notes

Stain combination matrices available in the color module and their respective colorspace:

  • rgb_from_hed: Hematoxylin + Eosin + DAB
  • rgb_from_hdx: Hematoxylin + DAB
  • rgb_from_fgx: Feulgen + Light Green
  • rgb_from_bex: Giemsa stain : Methyl Blue + Eosin
  • rgb_from_rbd: FastRed + FastBlue + DAB
  • rgb_from_gdx: Methyl Green + DAB
  • rgb_from_hax: Hematoxylin + AEC
  • rgb_from_bro: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G
  • rgb_from_bpx: Methyl Blue + Ponceau Fuchsin
  • rgb_from_ahx: Alcian Blue + Hematoxylin
  • rgb_from_hpx: Hematoxylin + PAS

References

[R31](1, 2) http://www.dentistry.bham.ac.uk/landinig/software/cdeconv/cdeconv.html

Examples

>>> from skimage import data
>>> from skimage.color import (separate_stains, combine_stains,
...                            hdx_from_rgb, rgb_from_hdx)
>>> ihc = data.immunohistochemistry()
>>> ihc_hdx = separate_stains(ihc, hdx_from_rgb)
>>> ihc_rgb = combine_stains(ihc_hdx, rgb_from_hdx)

convert_colorspace

skimage.color.convert_colorspace(arr, fromspace, tospace)

Convert an image array to a new color space.

Parameters:

arr : array_like

The image to convert.

fromspace : str

The color space to convert from. Valid color space strings are ['RGB', 'HSV', 'RGB CIE', 'XYZ']. Value may also be specified as lower case.

tospace : str

The color space to convert to. Valid color space strings are ['RGB', 'HSV', 'RGB CIE', 'XYZ']. Value may also be specified as lower case.

Returns:

newarr : ndarray

The converted image.

Notes

Conversion occurs through the “central” RGB color space, i.e. conversion from XYZ to HSV is implemented as XYZ -> RGB -> HSV instead of directly.

Examples

>>> from skimage import data
>>> lena = data.lena()
>>> lena_hsv = convert_colorspace(lena, 'RGB', 'HSV')

deltaE_cie76

skimage.color.deltaE_cie76(lab1, lab2)

Euclidean distance between two points in Lab color space

Parameters:

lab1 : array_like

reference color (Lab colorspace)

lab2 : array_like

comparison color (Lab colorspace)

Returns:

dE : array_like

distance between colors lab1 and lab2

References

[R32]http://en.wikipedia.org/wiki/Color_difference
[R33]A. R. Robertson, “The CIE 1976 color-difference formulae,” Color Res. Appl. 2, 7-11 (1977).

deltaE_ciede2000

skimage.color.deltaE_ciede2000(lab1, lab2, kL=1, kC=1, kH=1)

Color difference as given by the CIEDE 2000 standard.

CIEDE 2000 is a major revision of CIDE94. The perceptual calibration is largely based on experience with automotive paint on smooth surfaces.

Parameters:

lab1 : array_like

reference color (Lab colorspace)

lab2 : array_like

comparison color (Lab colorspace)

kL : float (range), optional

lightness scale factor, 1 for “acceptably close”; 2 for “imperceptible” see deltaE_cmc

kC : float (range), optional

chroma scale factor, usually 1

kH : float (range), optional

hue scale factor, usually 1

Returns:

deltaE : array_like

The distance between lab1 and lab2

Notes

CIEDE 2000 assumes parametric weighting factors for the lightness, chroma, and hue (kL, kC, kH respectively). These default to 1.

References

[R34]http://en.wikipedia.org/wiki/Color_difference
[R35]http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf (doi:10.1364/AO.33.008069)
[R36]M. Melgosa, J. Quesada, and E. Hita, “Uniformity of some recent color metrics tested with an accurate color-difference tolerance dataset,” Appl. Opt. 33, 8069-8077 (1994).

deltaE_ciede94

skimage.color.deltaE_ciede94(lab1, lab2, kH=1, kC=1, kL=1, k1=0.045, k2=0.015)

Color difference according to CIEDE 94 standard

Accommodates perceptual non-uniformities through the use of application specific scale factors (kH, kC, kL, k1, and k2).

Parameters:

lab1 : array_like

reference color (Lab colorspace)

lab2 : array_like

comparison color (Lab colorspace)

kH : float, optional

Hue scale

kC : float, optional

Chroma scale

kL : float, optional

Lightness scale

k1 : float, optional

first scale parameter

k2 : float, optional

second scale parameter

Returns:

dE : array_like

color difference between lab1 and lab2

Notes

deltaE_ciede94 is not symmetric with respect to lab1 and lab2. CIEDE94 defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently, the first color should be regarded as the “reference” color.

kL, k1, k2 depend on the application and default to the values suggested for graphic arts

Parameter Graphic Arts Textiles
kL 1.000 2.000
k1 0.045 0.048
k2 0.015 0.014

References

[R37]http://en.wikipedia.org/wiki/Color_difference
[R38]http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html

deltaE_cmc

skimage.color.deltaE_cmc(lab1, lab2, kL=1, kC=1)

Color difference from the CMC l:c standard.

This color difference was developed by the Colour Measurement Committee (CMC) of the Society of Dyers and Colourists (United Kingdom). It is intended for use in the textile industry.

The scale factors kL, kC set the weight given to differences in lightness and chroma relative to differences in hue. The usual values are kL=2, kC=1 for “acceptability” and kL=1, kC=1 for “imperceptibility”. Colors with dE > 1 are “different” for the given scale factors.

Parameters:

lab1 : array_like

reference color (Lab colorspace)

lab2 : array_like

comparison color (Lab colorspace)

Returns:

dE : array_like

distance between colors lab1 and lab2

Notes

deltaE_cmc the defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently deltaE_cmc(lab1, lab2) != deltaE_cmc(lab2, lab1)

References

[R39]http://en.wikipedia.org/wiki/Color_difference
[R40]http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html
[R41]F. J. J. Clarke, R. McDonald, and B. Rigg, “Modification to the JPC79 colour-difference formula,” J. Soc. Dyers Colour. 100, 128-132 (1984).

gray2rgb

skimage.color.gray2rgb(image)

Create an RGB representation of a gray-level image.

Parameters:

image : array_like

Input image of shape (M, N [, P]).

Returns:

rgb : ndarray

RGB image of shape (M, N, [, P], 3).

Raises:

ValueError :

If the input is not a 2- or 3-dimensional image.

guess_spatial_dimensions

skimage.color.guess_spatial_dimensions(image)

Make an educated guess about whether an image has a channels dimension.

Parameters:

image : ndarray

The input image.

Returns:

spatial_dims : int or None

The number of spatial dimensions of image. If ambiguous, the value is None.

Raises:

ValueError :

If the image array has less than two or more than four dimensions.

hed2rgb

skimage.color.hed2rgb(hed)

Haematoxylin-Eosin-DAB (HED) to RGB color space conversion.

Parameters:

hed : array_like

The image in the HED color space, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If hed is not a 3-D array of shape (.., .., 3).

References

[R42]A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001.

Examples

>>> from skimage import data
>>> from skimage.color import rgb2hed, hed2rgb
>>> ihc = data.immunohistochemistry()
>>> ihc_hed = rgb2hed(ihc)
>>> ihc_rgb = hed2rgb(ihc_hed)

hsv2rgb

skimage.color.hsv2rgb(hsv)

HSV to RGB color space conversion.

Parameters:

hsv : array_like

The image in HSV format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If hsv is not a 3-D array of shape (.., .., 3).

Notes

The conversion assumes an input data range of [0, 1] for all color components.

Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [R43].

References

[R43](1, 2) http://en.wikipedia.org/wiki/HSL_and_HSV

Examples

>>> from skimage import data
>>> lena = data.lena()
>>> lena_hsv = rgb2hsv(lena)
>>> lena_rgb = hsv2rgb(lena_hsv)

lab2lch

skimage.color.lab2lch(lab)

CIE-LAB to CIE-LCH color space conversion.

LCH is the cylindrical representation of the LAB (Cartesian) colorspace

Parameters:

lab : array_like

The N-D image in CIE-LAB format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied.

Returns:

out : ndarray

The image in LCH format, in a N-D array with same shape as input lab.

Raises:

ValueError :

If lch does not have at least 3 color channels (i.e. l, a, b).

Notes

The Hue is expressed as an angle between (0, 2*pi)

Examples

>>> from skimage import data
>>> from skimage.color import rgb2lab, lab2lch
>>> lena = data.lena()
>>> lena_lab = rgb2lab(lena)
>>> lena_lch = lab2lch(lena_lab)

lab2rgb

skimage.color.lab2rgb(lab)

Lab to RGB color space conversion.

Parameters:

lab : array_like

The image in Lab format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If lab is not a 3-D array of shape (.., .., 3).

Notes

This function uses lab2xyz and xyz2rgb.

lab2xyz

skimage.color.lab2xyz(lab)

CIE-LAB to XYZcolor space conversion.

Parameters:

lab : array_like

The image in lab format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in XYZ format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If lab is not a 3-D array of shape (.., .., 3).

Notes

Observer = 2A, Illuminant = D65 CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883

References

[R44]http://www.easyrgb.com/index.php?X=MATH&H=07#text7
[R45]http://en.wikipedia.org/wiki/Lab_color_space

label2rgb

skimage.color.label2rgb(label, image=None, colors=None, alpha=0.3, bg_label=-1, bg_color=None, image_alpha=1)

Return an RGB image where color-coded labels are painted over the image.

Parameters:

label : array

Integer array of labels with the same shape as image.

image : array

Image used as underlay for labels. If the input is an RGB image, it’s converted to grayscale before coloring.

colors : list

List of colors. If the number of labels exceeds the number of colors, then the colors are cycled.

alpha : float [0, 1]

Opacity of colorized labels. Ignored if image is None.

bg_label : int

Label that’s treated as the background.

bg_color : str or array

Background color. Must be a name in color_dict or RGB float values between [0, 1].

image_alpha : float [0, 1]

Opacity of the image.

lch2lab

skimage.color.lch2lab(lch)

CIE-LCH to CIE-LAB color space conversion.

LCH is the cylindrical representation of the LAB (Cartesian) colorspace

Parameters:

lch : array_like

The N-D image in CIE-LCH format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied.

Returns:

out : ndarray

The image in LAB format, with same shape as input lch.

Raises:

ValueError :

If lch does not have at least 3 color channels (i.e. l, c, h).

Examples

>>> from skimage import data
>>> from skimage.color import rgb2lab, lch2lab
>>> lena = data.lena()
>>> lena_lab = rgb2lab(lena)
>>> lena_lch = lab2lch(lena_lab)
>>> lena_lab2 = lch2lab(lena_lch)

luv2rgb

skimage.color.luv2rgb(luv)

Luv to RGB color space conversion.

Parameters:

luv : (M, N, [P,] 3) array_like

The 3 or 4 dimensional image in CIE Luv format. Final dimension denotes channels.

Returns:

out : (M, N, [P,] 3) ndarray

The image in RGB format. Same dimensions as input.

Raises:

ValueError :

If luv is not a 3-D or 4-D array of shape (M, N, [P,] 3).

Notes

This function uses luv2xyz and xyz2rgb.

luv2xyz

skimage.color.luv2xyz(luv)

CIE-Luv to XYZ color space conversion.

Parameters:

luv : (M, N, [P,] 3) array_like

The 3 or 4 dimensional image in CIE-Luv format. Final dimension denotes channels.

Returns:

out : (M, N, [P,] 3) ndarray

The image in XYZ format. Same dimensions as input.

Raises:

ValueError :

If luv is not a 3-D or 4-D array of shape (M, N, [P,] 3).

Notes

XYZ conversion weights use Observer = 2A. Reference whitepoint for D65 Illuminant, with XYZ tristimulus values of (95.047, 100., 108.883).

References

[R46]http://www.easyrgb.com/index.php?X=MATH&H=16#text16
[R47]http://en.wikipedia.org/wiki/CIELUV

rgb2gray

skimage.color.rgb2gray(rgb)

Compute luminance of an RGB image.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3), or in RGBA format with shape (.., .., 4).

Returns:

out : ndarray

The luminance image, a 2-D array.

Raises:

ValueError :

If rgb2gray is not a 3-D array of shape (.., .., 3) or (.., .., 4).

Notes

The weights used in this conversion are calibrated for contemporary CRT phosphors:

Y = 0.2125 R + 0.7154 G + 0.0721 B

If there is an alpha channel present, it is ignored.

References

[R48]http://www.poynton.com/PDFs/ColorFAQ.pdf

Examples

>>> from skimage.color import rgb2gray
>>> from skimage import data
>>> lena = data.lena()
>>> lena_gray = rgb2gray(lena)

rgb2grey

skimage.color.rgb2grey(rgb)

Compute luminance of an RGB image.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3), or in RGBA format with shape (.., .., 4).

Returns:

out : ndarray

The luminance image, a 2-D array.

Raises:

ValueError :

If rgb2gray is not a 3-D array of shape (.., .., 3) or (.., .., 4).

Notes

The weights used in this conversion are calibrated for contemporary CRT phosphors:

Y = 0.2125 R + 0.7154 G + 0.0721 B

If there is an alpha channel present, it is ignored.

References

[R49]http://www.poynton.com/PDFs/ColorFAQ.pdf

Examples

>>> from skimage.color import rgb2gray
>>> from skimage import data
>>> lena = data.lena()
>>> lena_gray = rgb2gray(lena)

rgb2hed

skimage.color.rgb2hed(rgb)

RGB to Haematoxylin-Eosin-DAB (HED) color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in HED format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If rgb is not a 3-D array of shape (.., .., 3).

References

[R50]A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001.

Examples

>>> from skimage import data
>>> from skimage.color import rgb2hed
>>> ihc = data.immunohistochemistry()
>>> ihc_hed = rgb2hed(ihc)

rgb2hsv

skimage.color.rgb2hsv(rgb)

RGB to HSV color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in HSV format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If rgb is not a 3-D array of shape (.., .., 3).

Notes

The conversion assumes an input data range of [0, 1] for all color components.

Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [R51].

References

[R51](1, 2) http://en.wikipedia.org/wiki/HSL_and_HSV

Examples

>>> from skimage import color
>>> from skimage import data
>>> lena = data.lena()
>>> lena_hsv = color.rgb2hsv(lena)

rgb2lab

skimage.color.rgb2lab(rgb)

RGB to lab color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Returns:

out : ndarray

The image in Lab format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Raises:

ValueError :

If rgb is not a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Notes

This function uses rgb2xyz and xyz2lab.

rgb2luv

skimage.color.rgb2luv(rgb)

RGB to CIE-Luv color space conversion.

Parameters:

rgb : (M, N, [P,] 3) array_like

The 3 or 4 dimensional image in RGB format. Final dimension denotes channels.

Returns:

out : (M, N, [P,] 3) ndarray

The image in CIE Luv format. Same dimensions as input.

Raises:

ValueError :

If rgb is not a 3-D or 4-D array of shape (M, N, [P,] 3).

Notes

This function uses rgb2xyz and xyz2luv.

rgb2rgbcie

skimage.color.rgb2rgbcie(rgb)

RGB to RGB CIE color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB CIE format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If rgb is not a 3-D array of shape (.., .., 3).

References

[R52]http://en.wikipedia.org/wiki/CIE_1931_color_space

Examples

>>> from skimage import data
>>> from skimage.color import rgb2rgbcie
>>> lena = data.lena()
>>> lena_rgbcie = rgb2rgbcie(lena)

rgb2xyz

skimage.color.rgb2xyz(rgb)

RGB to XYZ color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Returns:

out : ndarray

The image in XYZ format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Raises:

ValueError :

If rgb is not a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Notes

The CIE XYZ color space is derived from the CIE RGB color space. Note however that this function converts from sRGB.

References

[R53]http://en.wikipedia.org/wiki/CIE_1931_color_space

Examples

>>> from skimage import data
>>> lena = data.lena()
>>> lena_xyz = rgb2xyz(lena)

rgbcie2rgb

skimage.color.rgbcie2rgb(rgbcie)

RGB CIE to RGB color space conversion.

Parameters:

rgbcie : array_like

The image in RGB CIE format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If rgbcie is not a 3-D array of shape (.., .., 3).

References

[R54]http://en.wikipedia.org/wiki/CIE_1931_color_space

Examples

>>> from skimage import data
>>> from skimage.color import rgb2rgbcie, rgbcie2rgb
>>> lena = data.lena()
>>> lena_rgbcie = rgb2rgbcie(lena)
>>> lena_rgb = rgbcie2rgb(lena_rgbcie)

separate_stains

skimage.color.separate_stains(rgb, conv_matrix)

RGB to stain color space conversion.

Parameters:

rgb : array_like

The image in RGB format, in a 3-D array of shape (.., .., 3).

conv_matrix: ndarray :

The stain separation matrix as described by G. Landini [R55].

Returns:

out : ndarray

The image in stain color space, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If rgb is not a 3-D array of shape (.., .., 3).

Notes

Stain separation matrices available in the color module and their respective colorspace:

  • hed_from_rgb: Hematoxylin + Eosin + DAB
  • hdx_from_rgb: Hematoxylin + DAB
  • fgx_from_rgb: Feulgen + Light Green
  • bex_from_rgb: Giemsa stain : Methyl Blue + Eosin
  • rbd_from_rgb: FastRed + FastBlue + DAB
  • gdx_from_rgb: Methyl Green + DAB
  • hax_from_rgb: Hematoxylin + AEC
  • bro_from_rgb: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G
  • bpx_from_rgb: Methyl Blue + Ponceau Fuchsin
  • ahx_from_rgb: Alcian Blue + Hematoxylin
  • hpx_from_rgb: Hematoxylin + PAS

References

[R55](1, 2) http://www.dentistry.bham.ac.uk/landinig/software/cdeconv/cdeconv.html

Examples

>>> from skimage import data
>>> from skimage.color import separate_stains, hdx_from_rgb
>>> ihc = data.immunohistochemistry()
>>> ihc_hdx = separate_stains(ihc, hdx_from_rgb)

xyz2lab

skimage.color.xyz2lab(xyz)

XYZ to CIE-LAB color space conversion.

Parameters:

xyz : array_like

The image in XYZ format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Returns:

out : ndarray

The image in CIE-LAB format, in a 3- or 4-D array of shape (.., ..,[ ..,] 3).

Raises:

ValueError :

If xyz is not a 3-D array of shape (.., ..,[ ..,] 3).

Notes

Observer= 2A, Illuminant= D65 CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883

References

[R56]http://www.easyrgb.com/index.php?X=MATH&H=07#text7
[R57]http://en.wikipedia.org/wiki/Lab_color_space

Examples

>>> from skimage import data
>>> from skimage.color import rgb2xyz, xyz2lab
>>> lena = data.lena()
>>> lena_xyz = rgb2xyz(lena)
>>> lena_lab = xyz2lab(lena_xyz)

xyz2luv

skimage.color.xyz2luv(xyz)

XYZ to CIE-Luv color space conversion.

Parameters:

xyz : (M, N, [P,] 3) array_like

The 3 or 4 dimensional image in XYZ format. Final dimension denotes channels.

Returns:

out : (M, N, [P,] 3) ndarray

The image in CIE-Luv format. Same dimensions as input.

Raises:

ValueError :

If xyz is not a 3-D or 4-D array of shape (M, N, [P,] 3).

Notes

XYZ conversion weights use Observer = 2A. Reference whitepoint for D65 Illuminant, with XYZ tristimulus values of (95.047, 100., 108.883).

References

[R58]http://www.easyrgb.com/index.php?X=MATH&H=16#text16
[R59]http://en.wikipedia.org/wiki/CIELUV

Examples

>>> from skimage import data
>>> from skimage.color import rgb2xyz, xyz2luv
>>> lena = data.lena()
>>> lena_xyz = rgb2xyz(lena)
>>> lena_luv = xyz2luv(lena_xyz)

xyz2rgb

skimage.color.xyz2rgb(xyz)

XYZ to RGB color space conversion.

Parameters:

xyz : array_like

The image in XYZ format, in a 3-D array of shape (.., .., 3).

Returns:

out : ndarray

The image in RGB format, in a 3-D array of shape (.., .., 3).

Raises:

ValueError :

If xyz is not a 3-D array of shape (.., .., 3).

Notes

The CIE XYZ color space is derived from the CIE RGB color space. Note however that this function converts to sRGB.

References

[R60]http://en.wikipedia.org/wiki/CIE_1931_color_space

Examples

>>> from skimage import data
>>> from skimage.color import rgb2xyz, xyz2rgb
>>> lena = data.lena()
>>> lena_xyz = rgb2xyz(lena)
>>> lena_rgb = xyz2rgb(lena_xyz)