deltaE
Color difference based on CIE76 standard
Description
Examples
Calculate Color Difference of Two Colors using CIE76 Standard
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
Calculate Color Difference of RGB Images
Read a color image into the workspace.
I1 = imread('peppers.png');
imshow(I1)
Alter the local color contrast in the image.
I2 = localcontrast(I1); imshow(I2)
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,[])
Calculate Color Difference of L*a*b* Images
Read and display an image of tissue stained with hemotoxylin and eosin (H&E).
he = imread('hestain.png');
imshow(he)
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 = imcolordiff(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,[])
Input Arguments
I1
— First set of color data
m-by-n-by-3 numeric array | c-by-3 numeric matrix
First set of color data, specified as an
m-by-n-by-3 numeric array representing an image
or a c-by-3 numeric matrix representing a set of c
colors. I1
and I2
must be the same size with
values in the same color space.
By default, the deltaE
function interprets the color data as
RGB color values. To calculate the color difference in the L*a*b* color space, 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
I2
— Second set of color data
m-by-n-by-3 numeric array | c-by-3 numeric matrix
Second set of color data, specified as an
m-by-n-by-3 numeric array representing an image
or a c-by-3 numeric matrix representing a set of c
colors. I1
and I2
must be the same size with
values in the same color space.
By default, the deltaE
function interprets the color data as
RGB color values. To calculate the color difference in the L*a*b* color space, 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
isLab
— Color values are in L*a*b* color space
false
or 0
(default) | true
or 1
Color values are in the L*a*b* color space, specified as a numeric or
logical 0
(false
) or 1
(true
).
Output Arguments
dE
— Color difference
m-by-n matrix | c-element column vector
Color difference (delta E), returned as one of the following.
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
Abrir ejemplo
Tiene una versión modificada de este ejemplo. ¿Desea abrir este ejemplo con sus modificaciones?
Comando de MATLAB
Ha hecho clic en un enlace que corresponde a este comando de MATLAB:
Ejecute el comando introduciéndolo en la ventana de comandos de MATLAB. Los navegadores web no admiten comandos de MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)