Main Content

deltaE

Color difference based on CIE76 standard

Since R2020b

Description

dE = deltaE(I1,I2) calculates the color difference between two color images, a color image and a reference color, or two sets of colors, using the CIE76 standard. By default, the function expects the colors to be in the sRGB color space.

example

dE = deltaE(I1,I2,isInputLab=isLab) also specifies whether the colors are in the sRGB color space or the L*a*b* color space.

example

Examples

collapse all

Specify two RGB color values.

pureRed = uint8([255 0 0]);
darkRed = uint8([255 10 50]);

Calculate the color difference of the colors.

dE = deltaE(pureRed,darkRed)
dE = single

18.6206

Read a color image into the workspace.

I1 = imread('peppers.png');
imshow(I1)

Figure contains an axes object. The hidden axes object contains an object of type image.

Alter the local color contrast in the image.

I2 = localcontrast(I1);
imshow(I2)

Figure contains an axes object. The hidden axes object contains an object of type image.

Calculate the color difference of the images.

dE = deltaE(I1,I2);

Display the color difference as an image. The maximum value of dE exceeds the range [0, 1] expected of images of data type single, so display the image using the full display range of the data. Bright pixels indicate a large color difference and therefore a larger amount of contrast enhancement.

imshow(dE,[])

Figure contains an axes object. The hidden axes object contains an object of type image.

Read and display an image of tissue stained with hematoxylin and eosin (H&E).

he = imread("hestain.png");
imshow(he)

Figure contains an axes object. The hidden axes object contains an object of type image.

Convert the image to the L*a*b* color space.

lab = rgb2lab(he);

Make a copy of the image, then increase the signal of the a* channel. Red tones in the image become more saturated while the image overall brightness and the blue tones are unchanged.

lab2 = lab;
scaleFactor = 1.2;
lab2(:,:,2) = scaleFactor*lab(:,:,2);

Calculate the color difference of the original and enhanced image in the L*a*b* color space.

dE = deltaE(lab,lab2,isInputLab=true);

Display the color difference as an image. Scale the display range to match the range of pixel values in dE. Bright regions indicate the greatest color difference and correspond with the pink regions of tissue.

imshow(dE,[])

Figure contains an axes object. The hidden axes object contains an object of type image.

Input Arguments

collapse all

First set of color data, specified in one of these formats.

  • A 1-by-3 numeric vector representing a reference color.

  • A c-by-3 numeric matrix representing a set of c colors.

  • An m-by-n-by-3 numeric array representing a color image.

  • A multidimensional numeric array, such as an m-by-n-by-3-by-p array, representing a batch of color images. The third dimension must correspond to the color channel and have 3 channels.

If I2 is not a reference color, then I1 must be either a reference color or a numeric array of the same size as I2.

I1 and I2 must be in the same color space. By default, the deltaE function expects that I1 and I2 are in the sRGB color space. If I1 and I2 are instead in the L*a*b* color space, then specify the isLab argument as true. L*a*b* color values can be of data type single or double only.

Data Types: single | double | uint8 | uint16

Second set of color data, specified in one of these formats.

  • A 1-by-3 numeric vector representing a reference color.

  • A c-by-3 numeric matrix representing a set of c colors.

  • An m-by-n-by-3 numeric array representing a color image.

  • A multidimensional numeric array, such as an m-by-n-by-3-by-p array, representing a batch of color images. The third dimension must correspond to the color channel and have 3 channels.

If I1 is not a reference color, then I2 must be either a reference color or a numeric array of the same size as I1.

I1 and I2 must be in the same color space. By default, the deltaE function expects that I1 and I2 are in the sRGB color space. If I1 and I2 are instead in the L*a*b* color space, then specify the isLab argument as true. L*a*b* color values can be of data type single or double only.

Data Types: single | double | uint8 | uint16

Color values are in the L*a*b* color space, specified as a numeric or logical 0 (false) or 1 (true).

Output Arguments

collapse all

Color difference (delta E), returned as one of the following.

  • An m-by-n numeric matrix. The array represents the pixel-wise color difference between two color images, or between a color image and a reference color.

  • A c-by-1 numeric column vector. The vector represents the color difference between two sets of c colors, or between a set of c colors and a reference color.

  • A numeric scalar that represents the color difference between two reference colors.

  • A multidimensional numeric array. The array represents the pixel-wise color difference between two batches of color images, or between a batch of color images and a reference color. The third dimension has length 1 and indicates the color difference.

If I1 or I2 is of data type double, then dE is of data type double. Otherwise, dE is of data type single.

Data Types: single | double

Tips

  • To improve the accuracy of the color difference calculation, use the imcolordiff function. This function follows the CIE94 and CIEDE2000 standards and offers parameters to improve perceptual uniformity for different applications.

Version History

Introduced in R2020b

expand all