|
DCMTK Version 3.7.1
OFFIS DICOM Toolkit
|
Class supporting color space conversions from and to CIELab. More...
Static Public Member Functions | |
| static void | dicomLab2RGB (double &R, double &G, double &B, double LDicom, double aDicom, double bDicom) |
| Convert CIELab color representation as found in DICOM to sRGB value representation. | |
| static void | dicomLab2RGB (Uint8 &R, Uint8 &G, Uint8 &B, Uint16 LDicom, Uint16 aDicom, Uint16 bDicom) |
| Convert CIELab color representation as found in DICOM to 8 bit sRGB value representation. | |
| static void | rgb2DicomLab (double &LDicom, double &aDicom, double &bDicom, double R, double G, double B) |
| Convert sRGB color representation to CIELab color representation as found in DICOM. | |
| static void | rgb2DicomLab (Uint16 &LDicom, Uint16 &aDicom, Uint16 &bDicom, Uint8 R, Uint8 G, Uint8 B) |
| Convert 8 bit sRGB color representation to CIELab color representation as found in DICOM. | |
| static void | dicomlab2Lab (double &L, double &a, double &b, double LDicom, double aDicom, double bDicom) |
| Convert CIELab color representation as found in DICOM to CIELab representation. | |
| static void | lab2DicomLab (double &LDicom, double &aDicom, double &bDicom, double L, double a, double b) |
| Convert CIELab color representation to CIELab color representation found in DICOM. | |
| static void | rgb2Lab (double &L, double &a, double &b, double R, double G, double B) |
| Convert sRGB color representation to CIELab representation (relative to the D50 white point, i.e. | |
| static void | rgb2Xyz (double &X, double &Y, double &Z, double R, double G, double B) |
| Convert sRGB color representation to CIE XYZ representation relative to the D50 white point (ICC PCS XYZ), i.e. | |
| static void | xyz2Lab (double &L, double &a, double &b, double X, double Y, double Z) |
| Convert CIE XYZ color representation (relative to D50) to CIELab representation (relative to D50). | |
| static void | lab2Rgb (double &R, double &G, double &B, double L, double a, double b) |
| Convert CIELab color representation (relative to D50) to sRGB representation. | |
| static void | lab2Xyz (double &X, double &Y, double &Z, double L, double a, double b) |
| Convert CIELab color representation (relative to D50) to CIE XYZ representation (relative to D50). | |
| static void | xyz2Rgb (double &R, double &G, double &B, double X, double Y, double Z) |
| Convert CIE XYZ color representation (relative to D50, ICC PCS XYZ) to sRGB representation, i.e. | |
Static Protected Member Functions | |
| static double | gammaCorrection (double n) |
| Perform sRGB gamma encoding, transforms linear R to R'. | |
| static double | invGammaCorrection (double n) |
| Perform inverse sRGB gamma encoding, transforms R' to linear R. | |
| static double | labf (double n) |
| CIE L*a*b* f function (used to convert XYZ to L*a*b*). | |
| static double | labfInv (double n) |
| CIE L*a*b* inverse f function. | |
| static double | clamp01 (double n) |
| Clamp a value to the range 0 <= value <= 1. | |
| static double | roundClamp (double n, double max) |
| Round a value to the nearest integer and clamp it to the range 0 <= value <= max. | |
Class supporting color space conversions from and to CIELab.
In some IODs DICOM stores CIELab color values (e.g. Recommended Display CIELab Value) which must often be converted to RGB for display or other purposes. This is supported by the functions dicomLab2RGB() and rgb2DicomLab(). The CIELab value range in DICOM is [0,65535] for all three values. The RGB value range in this class is [0,1] (or [0,255] for the 8 bit integer variants). Further functions are available in order to convert between RGB, "normal" CIELab value range as well as CIEXYZ. The class uses double floating point precision for calculations.
DICOM (part 3, C.10.7.1.1) encodes CIELab values in the same way as the ICC Profile Connection Space (PCS), i.e. the CIELab values are relative to the D50 illuminant. The RGB values handled by this class are sRGB values, whose native white point is D65. This class therefore converts sRGB to linear RGB, to CIEXYZ (D65), chromatically adapts the CIEXYZ values to D50 using the linear Bradford transform, and finally computes CIELab relative to the D50 white point (and vice versa). All CIEXYZ values exposed by this class are D50 (PCS) values. The matrices and constants used are those of the CSS Color Module Level 4 sample code (https://www.w3.org/TR/css-color-4/#color-conversion-code), so that results are consistent with other DICOM implementations following the same approach.
Note that up to and including DCMTK 3.7.0 the CIELab values computed by this class were relative to D65, i.e. no chromatic adaptation to the PCS illuminant took place. For neutral (gray) colors the results are the same, for chromatic colors the a* and b* values differ slightly.
|
staticprotected |
Clamp a value to the range 0 <= value <= 1.
| n | The value to clamp |
|
static |
Convert CIELab color representation as found in DICOM to CIELab representation.
See DICOM part 3 for details.
| L | Output CIELab luminance component with 0 <= L <= 100 |
| a | Output CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Output CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
| LDicom | Input CIELab luminance component with 0 <= L <= 65535 as found in DICOM |
| aDicom | Input CIELab "a" component (red<->green) with 0 <= a <= 65535 as found in DICOM |
| bDicom | Input CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 as found in DICOM |
|
static |
Convert CIELab color representation as found in DICOM to sRGB value representation.
See DICOM part 3 for details. Colors outside the sRGB gamut are clipped, i.e. the resulting R, G and B values are always within the range 0 <= value <= 1.
| R | Output sRGB "R" component (red) with 0 <= R <= 1 |
| G | Output sRGB "G" component (green) with 0 <= G <= 1 |
| B | Output sRGB "B" component (blue) with 0 <= B <= 1 |
| LDicom | Input DICOM CIELab luminance component with 0 <= L <= 65535 |
| aDicom | Input DICOM CIELab "a" component (red<->green) with 0 <= a <= 65535 |
| bDicom | Input DICOM CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 |
|
static |
Convert CIELab color representation as found in DICOM to 8 bit sRGB value representation.
This is a convenience variant of dicomLab2RGB(double&, double&, double&, double, double, double) that rounds the result to the nearest integer and clamps it to the range 0 <= value <= 255.
| R | Output sRGB "R" component (red) with 0 <= R <= 255 |
| G | Output sRGB "G" component (green) with 0 <= G <= 255 |
| B | Output sRGB "B" component (blue) with 0 <= B <= 255 |
| LDicom | Input DICOM CIELab luminance component with 0 <= L <= 65535 |
| aDicom | Input DICOM CIELab "a" component (red<->green) with 0 <= a <= 65535 |
| bDicom | Input DICOM CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 |
|
staticprotected |
Perform sRGB gamma encoding, transforms linear R to R'.
| n | The value to encode, 0 <= n <= 1 |
|
staticprotected |
Perform inverse sRGB gamma encoding, transforms R' to linear R.
| n | The value to decode, 0 <= n <= 1 |
|
static |
Convert CIELab color representation to CIELab color representation found in DICOM.
See DICOM part 3 for details.
| LDicom | Output CIELab luminance component with 0 <= L <= 65535 as found in DICOM |
| aDicom | Output CIELab "a" component (red<->green) with 0 <= a <= 65535 as found in DICOM |
| bDicom | Output CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 as found in DICOM |
| L | Input CIELab luminance component with 0 <= L <= 100 |
| a | Input CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Input CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
|
static |
Convert CIELab color representation (relative to D50) to sRGB representation.
Colors outside the sRGB gamut are clipped, i.e. the resulting R, G and B values are always within the range 0 <= value <= 1.
| R | Output sRGB "R" component (red) with 0 <= R <= 1 |
| G | Output sRGB "G" component (green) with 0 <= G <= 1 |
| B | Output sRGB "B" component (blue) with 0 <= B <= 1 |
| L | Input CIELab luminance component with 0 <= L <= 100 |
| a | Input CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Input CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
|
static |
Convert CIELab color representation (relative to D50) to CIE XYZ representation (relative to D50).
| X | Output CIE XYZ "X" component with 0 <= X <= D50_WHITEPOINT_X |
| Y | Output CIE XYZ "Y" component with 0 <= Y <= 1 |
| Z | Output CIE XYZ "Z" component with 0 <= Z <= D50_WHITEPOINT_Z |
| L | Input CIELab luminance component with 0 <= L <= 100 |
| a | Input CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Input CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
|
staticprotected |
CIE L*a*b* f function (used to convert XYZ to L*a*b*).
| n | value to convert |
|
staticprotected |
CIE L*a*b* inverse f function.
| n | The value to compute the inverse for |
|
static |
Convert sRGB color representation to CIELab color representation as found in DICOM.
See DICOM part 3 for details.
| LDicom | Output CIELab luminance component with 0 <= L <= 65535 as found in DICOM |
| aDicom | Output CIELab "a" component (red<->green) with 0 <= a <= 65535 as found in DICOM |
| bDicom | Output CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 as found in DICOM |
| R | Input sRGB "R" component (red) with 0 <= R <= 1 |
| G | Input sRGB "G" component (green) with 0 <= G <= 1 |
| B | Input sRGB "B" component (blue) with 0 <= B <= 1 |
|
static |
Convert 8 bit sRGB color representation to CIELab color representation as found in DICOM.
This is a convenience variant of rgb2DicomLab(double&, double&, double&, double, double, double) that rounds the result to the nearest integer and clamps it to the range 0 <= value <= 65535.
| LDicom | Output CIELab luminance component with 0 <= L <= 65535 as found in DICOM |
| aDicom | Output CIELab "a" component (red<->green) with 0 <= a <= 65535 as found in DICOM |
| bDicom | Output CIELab "b" component (blue<->yellow) with 0 <= b <= 65535 as found in DICOM |
| R | Input sRGB "R" component (red) with 0 <= R <= 255 |
| G | Input sRGB "G" component (green) with 0 <= G <= 255 |
| B | Input sRGB "B" component (blue) with 0 <= B <= 255 |
|
static |
Convert sRGB color representation to CIELab representation (relative to the D50 white point, i.e.
ICC PCS CIELab)
| L | Output CIELab luminance component with 0 <= L <= 100 |
| a | Output CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Output CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
| R | Input sRGB "R" component (red) with 0 <= R <= 1 |
| G | Input sRGB "G" component (green) with 0 <= G <= 1 |
| B | Input sRGB "B" component (blue) with 0 <= B <= 1 |
|
static |
Convert sRGB color representation to CIE XYZ representation relative to the D50 white point (ICC PCS XYZ), i.e.
the sRGB values are linearized, converted to CIE XYZ (D65) and then chromatically adapted to D50 using the linear Bradford transform.
| X | Output CIE XYZ "X" component with 0 <= X <= D50_WHITEPOINT_X |
| Y | Output CIE XYZ "Y" component with 0 <= Y <= 1 |
| Z | Output CIE XYZ "Z" component with 0 <= Z <= D50_WHITEPOINT_Z |
| R | Input sRGB "R" component (red) with 0 <= R <= 1 |
| G | Input sRGB "G" component (green) with 0 <= G <= 1 |
| B | Input sRGB "B" component (blue) with 0 <= B <= 1 |
|
staticprotected |
Round a value to the nearest integer and clamp it to the range 0 <= value <= max.
| n | The value to round and clamp |
| max | The maximum permitted value |
|
static |
Convert CIE XYZ color representation (relative to D50) to CIELab representation (relative to D50).
| L | Output CIELab luminance component with 0 <= L <= 100 |
| a | Output CIELab "a" component (red<->green) with -128 <= a <= 127 |
| b | Output CIELab "b" component (blue<->yellow) with -128 <= b <= 127 |
| X | Input CIE XYZ "X" component with 0 <= X <= D50_WHITEPOINT_X |
| Y | Input CIE XYZ "Y" component with 0 <= Y <= 1 |
| Z | Input CIE XYZ "Z" component with 0 <= Z <= D50_WHITEPOINT_Z |
|
static |
Convert CIE XYZ color representation (relative to D50, ICC PCS XYZ) to sRGB representation, i.e.
the XYZ values are chromatically adapted from D50 to D65 using the linear Bradford transform, converted to linear RGB and finally gamma-encoded. Colors outside the sRGB gamut are clipped, i.e. the resulting R, G and B values are always within the range 0 <= value <= 1.
| R | Output sRGB "R" component (red) with 0 <= R <= 1 |
| G | Output sRGB "G" component (green) with 0 <= G <= 1 |
| B | Output sRGB "B" component (blue) with 0 <= B <= 1 |
| X | Input CIE XYZ "X" component with 0 <= X <= D50_WHITEPOINT_X |
| Y | Input CIE XYZ "Y" component with 0 <= Y <= 1 |
| Z | Input CIE XYZ "Z" component with 0 <= Z <= D50_WHITEPOINT_Z |