Food Color Comparisons

Colors are commonly represented in terms of the absolute magnitude of their coordinates in a specified color space, and differences between them in terms of the distance between their locations in that space. This Demonstration creates images for convenient visual comparison of two colors based on the numerical values of their CIE Lab or RGB coordinates. It can also translate continuous changes in any coordinate into an image that reveals visually how the perceived difference grows or diminishes.


  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]
  • [Snapshot]


Snapshot 1: beet in CIE Lab color space
Snapshot 2: tomato in CIE Lab color space with the rectangles touching
Snapshot 3: mustard in CIE Lab color space using antialiasing to blur the rectangles' edges
Snapshot 4: peanut butter in CIE Lab color space with the rectangles touching and using antialiasing
Snapshot 5: chocolate in RGB color space
Snapshot 6: condensed milk in RGB color space with the rectangles touching
Snapshot 7: spinach in RGB color space using antialiasing to blur the rectangles' edges
Snapshot 8: blueberry in RGB color space with the rectangles touching and using antialiasing
In many publications and technical documents, changes in color are reported in terms of changes in the magnitude of one or all of their coordinates in the color space being used. The difference between any two colors is frequently expressed in terms of , the Euclidean distance between them in that space, or any of its more elaborate modifications [1, 2, 3]. Although such numerical values can be easily subjected to statistical analysis, they cannot be intuitively translated into the visual changes or differences. At least in principle, this can be overcome by generating colors using their reported coordinates and comparing them visually. This Demonstration generates two images for comparison from entered CIE Lab or RGB coordinates. The first generated color can be a standard or reference, for example, and the second the sample whose visual appearance is to be assessed against it.
Given coordinates in CIE Lab color space can be converted into RGB space coordinates using Mathematica's ColorConvert function, which can then be used to generate an image of the same color.
In this Demonstration, the CIE Lab or RGB color space is chosen with a setter and the corresponding coordinates—, , and or , , and —with sliders. There are two rectangular images 1 (left) and 2 (right), whose colors are specified with three sliders for each. By using the "rectangles touch" box, they can be compared while visually touching each other or slightly separated. Checking the "use antialiasing" box blurs the edge pixels of the colored rectangles.
In the CIE Lab color space, the slider for the (lightness) coordinate can vary between 0 (black) and 100 (white). The coordinate sets the location on the green () to red () axis, while sets the location on the perpendicular blue () to yellow () axis. In the RGB color space, which is the default for Mathematica, the , , and sliders vary from 0. to 1.
The default food color setting is for an orange-colored food. To facilitate finding the six sliders' settings for the color of a food that is not listed, click the setter having the same or a similar color to the food of interest. For example, for apricot, select "orange," for green lettuce, select "spinach," and for raspberry, select "beet." This will display the chosen food's approximate coordinates in CIE Lab or RGB space. Having done that, you can use the coordinate sliders to exactly match the color of the food of interest.
Since perceived color depends on the illumination intensity and direction and is affected by other factors, the compared images in this Demonstration might not be exact replicas of the colored foods whose coordinates have been used to generate them. Yet, they still enable one to conveniently assess color differences that cannot be intuitively revealed from numerical data alone.
[1] Wikipedia. "Color." (Jul 16, 2015) en.wikipedia.org/wiki/Color.
[2] Wikipedia. "Color Space." (Jul 16, 2015) en.wikipedia.org/wiki/Color_space.
[3] Wikipedia. "Color Difference." (Jul 16, 2015) en.wikipedia.org/wiki/Color_difference.
    • Share:

Embed Interactive Demonstration New!

Just copy and paste this snippet of JavaScript code into your website or blog to put the live Demonstration on your site. More details »

Files require Wolfram CDF Player or Mathematica.

Mathematica »
The #1 tool for creating Demonstrations
and anything technical.
Wolfram|Alpha »
Explore anything with the first
computational knowledge engine.
MathWorld »
The web's most extensive
mathematics resource.
Course Assistant Apps »
An app for every course—
right in the palm of your hand.
Wolfram Blog »
Read our views on math,
science, and technology.
Computable Document Format »
The format that makes Demonstrations
(and any information) easy to share and
interact with.
STEM Initiative »
Programs & resources for
educators, schools & students.
Computerbasedmath.org »
Join the initiative for modernizing
math education.
Step-by-Step Solutions »
Walk through homework problems one step at a time, with hints to help along the way.
Wolfram Problem Generator »
Unlimited random practice problems and answers with built-in step-by-step solutions. Practice online or make a printable study sheet.
Wolfram Language »
Knowledge-based programming for everyone.
Powered by Wolfram Mathematica © 2017 Wolfram Demonstrations Project & Contributors  |  Terms of Use  |  Privacy Policy  |  RSS Give us your feedback
Note: To run this Demonstration you need Mathematica 7+ or the free Mathematica Player 7EX
Download or upgrade to Mathematica Player 7EX
I already have Mathematica Player or Mathematica 7+