Tuesday, May 18, 2010

There is not just one color blindness

When people hear about color blindness they usually relate it to the term red-green color blindness, which is interpreted as 'not being able to distinguish the colors red and green'. Unfortunately this is misleading and merely describes the most common form of color vision deficiency.

In 1798, John Dalton (of atomic theory fame) was the first known scientist to describe color blindness in detail, as he discovered to be colorblind himself [1]. After studying his color vision, comparing his results with his brother, who was also colorblind, and talking to other colorblind people which he found during his research, he put together a list of Characteristic Facts of our Vision (by our he refers to the group of colorblind people including himself and his brother). This list includes the following points:
1. In the solar spectrum three colors appear, yellow, blue, and purple. [...]
2. Pink appears, by day-light, to be sky-blue a little faded, [...]
5. There is not much difference in color between a stick of red sealing wax and grass, by day.
John Dalton was suffering from deuteranopia [2] - one specific form of red-green color blindness - and his findings already show us, that this is not only about having troubles with the colors red and green but affects the whole color spectrum.

During the 19th century many scientists such as Young, Helmholtz, Maxwell, and Wilson became interested in the topic of color vision and color blindness. These scientists formed the fundamental research paving the way to our understanding of the perception and misperception of colors. In 1855 Maxwell wrote in a letter to Wilson: "The mathematical expression of the difference between colour-blind and ordinary vision is that colour to the former is a function of two independent variables, but to an ordinary eye, of three; [...] If we find two combinations of colours which appear identical to a colour-blind person, and mark their positions on the triangle of colours, then the straight line passing through these points will pass through all points corresponding to other colours, which, to such a person, appear identical with the first two. We may in the same way find other lines passing through the series of colours which appear alike to the colour-blind. All these lines either pass through one point or are parallel, according to the standard colours which we have assumed, and the other arbitrary assumptions we may have made." [3]

Color vision

In order to understand the source of the different types of color vision deficiency, it is important to understand how our color vision works. The human eye consists of approximately seven million cone cells and one hundred twenty million rod cells. Cone cells are responsible for color vision and function best in high levels of illumination; this is the reason color vision is absent at night. Rod cells function in low levels of illumination, and play a secondary role in color vision as they can only distinguish between lightness and darkness.

The average person has three types of cone cells, referred to as trichromacy, which differ in their peak sensitivity along the color spectrum. Long-wave sensitive cones have a maximum absorbance at 560nm, medium-wave sensitive cones at 530nm and short-wave sensitive cones at 420nm. These wavelengths are very close to the the primary colors red, green and blue and therefore are often referred to by those three colors [4].

Mixing the input of those three types of cones makes up our entire visible color spectrum. With this knowledge it is easy to understand that someone with more than three types of cones would have an increased perception of color; an example being tetrachromacy with four cone types. Whereas, on the other side, if there is a problem with one of those cone types or if one is missing the perceived variety of colors can be reduced dramatically.

MacAdams Ellipses
Diagram 1: MacAdam ellipses in the CIE 1931 chromaticity diagram.
Even people with normal color vision, or tetrachromacy for that matter, cannot distinguish differences within the entire color spectrum. This is important to understand as otherwise even people with no defect could be classified as colorblind.

In the 1940s MacAdam conducted a series of tests and introduced the discrimination ellipses, also known as MacAdam ellipses (see Diagram 1), into the CIE 1931 chromaticity diagram [5]. Every ellipse encloses colors which cannot be discriminated at the same level of luminance. These ellipses provide the tolerance limits for color specification and color reproduction. MacAdam estimated that a trichromat can distinguish about seventeen thousand unique colors at each level of luminance, or about three million perceivable colors overall.

Color vision deficiency

With the theory of color vision in the backpack, understanding the different types of color blindness is one step away. As our color vision is based on the three types of cones - red, green, and blue - a slight shift of the maximal sensitivity of one of those three types of cones results in less possible color mixtures, and reduction of the perceived color spectrum. This form of color blindness is an abnormality of the normal trichromatic color vision and referred to as anomalous trichromacy.

If one cone type is missing completely there are only two receptors left to mix the perceived range of colors, resulting in a dramatic reduction of the amount of visible colors; this type of color vision deficiency is called dichromacy.

If we keep removing cones we end up in forms of color blindness where two or even all are missing. In this case the term 'color blindness' is really correct, as only shades of gray or slight hints of colors can be seen. This complete form of color blindness is called monochromacy and is accompanied by a severe light sensitivity as only rods are used to retrieve visual information.


Table 1: Classification of congential color vision deficiency [6]

Table 1 shows the various types of color vision deficiencies. As there are three unique cone types, and each type can have a shifted peak of sensitivity or be missing completely, dichromats and anomalous trichromats are further subdivided into protans (defective long-wave red cones), deutans (defective medium-wave green cones), and tritans (defective short-wave blue cones).

Protan and deutan defects are the most common forms and often grouped together into one description known as red-green color blindness. The reason for this is they share similar areas of color confusion in the red/green portion of the spectrum. By far the most common type is deuteranomalous trichromatism of which around 5% of men are tested for positively. Other forms cannot easily be measured as they are rarely observed.


Table 2: Prevalence of different types of red-green color blindness [6]
The difference between prevalence rates among men and women is based on the fact that every form of red-green color blindness is a sex linked recessive trait. This means that women are often carrying a defective X chromosome but do not show any sign of deficiency, as the normal X chromosome acts dominantly.

Confusion lines and dichromatic convergence points

Dalton described his color blindness to be affecting the entire color spectrum. Pitt estimated in 1935 that the number of distinguishable spectral hues can be as low as 17 when suffering from deuteranopia, compared to about 150 in normal color vision [7]. Maxwell also thought about lines of color confusion for certain color spaces as early as 1855.

Today, we know that confusion lines, or dichromatic isochromatic lines, exist and converge at a single point for each type of color vision deficiency [8]. Colors represented along such a line are perceived as identical if no luminance contrast is present. The same lines are also true for the corresponding types of anomalous trichromatism, whereas the confusion zone is shorter and the full range of chromaticities is not included. These confusion lines are often represented in the CIE 1931 color space.

The CIE chromaticity coordiantes (x/y) for each type of color vision deficiency are as follows:
  • Protanopia (0.7465, 0.2535)
  • Deuteranopia (1.4, -0.4)
  • Tritanopia (0.1748, 0.0)

Diagram 2: Protanopia, deuteranopia and tritanopia confusion lines in the CIE 1931 color space.
Confusion lines and dichromatic convergence points put color vision deficiency into a mathematical framework. For this reason this information is useful for many types of applications:
  • Color blindness tests including pseudoisochromatic plate tests (also known as Ishihara plates), arrangement tests and modern computer based tests often use this data to calculate the type of color vision deficiency and severity.
  • Color blindness simulation algorithms make use of confusion lines by utilizing the fact that colors along these lines are perceived as identical to colorblind individuals. Using this knowledge, color blindness can be simulated by shifting the colors which are confused together along the lines of confusion to a single color.
  • Daltonization algorithms utilize confusion lines to compensate for color blindness. This is accomplished by shifting colors away from confusion lines towards colors visible to the colorblind individual. For example, daltonizing for protanopia involves shifting red values towards the blue end of the spectrum.
References
  1. Dalton J. Extraordinary facts relating to the vision of colours. Memoirs of the Literary Philosophical Society of Manchester: 1798. 5:28-45.
  2. Mollon JD, Dulai KS, Hunt DM. Dalton’s colour blindness: an essay in molecular biography. John Dalton’s Colour Vision Legacy. Selected proceedings of the international conference. Dickinson CM, Murray IJ and Carden D, Eds; Taylor and Francis Ltd 1997: 15-33.
  3. Judd DB. Fundamental Studies of Colour Vision from 1860 to 1960. Mechanisms of Color Vision. Proc N A S: 1313-1330.
  4. Dartnell HJA, Bowmaker JK, Mollon JD. Human visual pigments: microspectrophotometric results form the eyes of seven persons. Proc R Soc (Lond) B 220, 1983: 115-130.
  5. MacAdam DL. Visual sensitivities to colour differences in daylight. J Opt Soc Amer 32, 1942: 247-274.
  6. Birch J. Diagnosis of Defective Colour Vision. Oxford University Press, 2nd ed. 2001.
  7. Pitt FHG. Charateristics of Dichromatic Vision. Medical Research Council Special Report Series no 200, HMSO, London, 1935.
  8. Birch J. Dichromatic convergence points obtained by subtractive colour matching. Vision Res 13, 1972: 1755-1765.

Thursday, May 13, 2010

Daltonize in Google Chrome

Presenting Chrome Daltonize! as one step towards solving the issue of color-accessibility on the Internet – a Google Chrome extension enabling users to daltonize the image content of websites.  Daltonization is a technique of exposing details to color-blind users, enabling them see what they otherwise would have missed.

Setting up Chrome Daltonize extension:

Color vision deficiency (default is Protanope)
Select option that best describes you; Protanopic (malfunctioning red-cone), Deuteranopic (malfunctioning green-cone), or Tritanopic (malfunctioning blue-cone).
Run at page load (default is false)
By default, daltonization of a page is done by clicking on the browser-action button (it's the sphere icon) on the top-right corner of your browser.  If you want to run daltonize by default every time a new page is loaded, check this box.
Show speed results (default is false)
If option is checked the amount of time it took to process the images is displayed, otherwise, the time is not displayed.
Results of Chrome Daltonize on Ishihara test plates:
The details in the following Ishihara #18 test plate [3] cannot be seen by a red-green dichromat, or can be partially seen, depending on the degree of the malfunctioning cone-cell.  Using the LMS Daltonize algorithm [1, 2], and the CVD simulation algorithm, the following was created:
References:
  1. Françoise Viénot, Hans Brettel and John D. Mollon
    Digital video colourmaps for checking the legibility of displays by dichromats
    Color Research and Application, 24(4): 243-252
    , 1999.

  2. Onur Fidaner, Poliang Lin and Nevran Ozguven.
    Analysis of Color Blindness

  3. Les Daltoniens
    Le test d’Ishihara 

Wednesday, May 12, 2010

Color Vision with Javascript

The Color Vision library for Javascript is composed of two parts; a color vision daltonize.js [1, 2] and simulate.js [3, 4, 5].  These algorithms combined enable developers to target specific forms of color blindness from both sides of the spectrum.

The following code is an example of using the Color Vision library to daltonize an image, exposing details to a protanope:

Color.Vision.Daltonize(image, {
        type: "Protanope,
        callback: function(canvas) {
            document.body.appendChild(canvas);
        }
});

Here are the results on an Ishihara test plate [6].

Color Blindness Simulation 

Gary W. Meyer and Donald P. Greenberg [3] present an algorithm to simulate the world through the eyes of dichromats.  In this example, we simulate how a protanopic (red-cone missing) individual would perceive and image:

Color.Vision.Simulate(image, {
        type: "Protanope",
        amount: 1.0,
        callback: function(canvas) {
            document.body.appendChild(canvas);
        }
});

One interesting thing about this algorithm is that it can be modified to match other forms of color blindness by modulating the confusion line coordinates.  At this time, there is no online color vision tests that can provide measurements of an individuals confusion line, as such, one is left to creating fanciful psychedelic customalies:

Color.Vision.Simulate(image, {
        type: "Custom",
        x: 0.7465,
        y: 0.2535,
        m: 1.273463,
        yint: -0.073894,
        amount: 1.0,
        callback: function(canvas) {
            document.body.appendChild(canvas);
        }
});

You can find the entire project online.

Javascript

References
  1. Françoise Viénot, Hans Brettel and John D. Mollon
    Digital video colourmaps for checking the legibility of displays by dichromats
    Color Research and Application, 24(4): 243-252
    , 1999.

  2. Onur Fidaner, Poliang Lin and Nevran Ozguven.
    Analysis of Color Blindness

  3. Gary W. Meyer and Donald P. Greenberg
    Color-Defective Vision and Computer Graphics Displays
    IEEE Computer Graphics and Applications, 8(5): 28-40, 1988.

  4. Vivianne C. Smith and Joel Pokorny
    Spectral sensitivity of the foveal cone photopigments between 400 and 500 nm
    Vision Research, 15(2): 161-171, 1975.
     
  5. Bruce Lindbloom
    RGB Working Space Information

  6. Les Daltoniens
    Le test d’Ishihara

Color Vision with Pixel Bender

Pixel Bender is a powerful tool for image processing released by Adobe Systems as part of their CS4 product line — it's integrated into After Effects, Flash, and Photoshop.  It's a fun, and straight-forward language to program with.

The Color Vision library for Pixel Bender is composed of two parts; a color vision daltonization kernel [1, 2] and simulation kernel [3, 4, 5].  These algorithms combined enable developers to target specific forms of color blindness from both sides of the spectrum.

These kernels have multiple uses, one that interests me the most is plugging them into popular video hosting websites such as Hulu, Vimeo and Youtube.  The daltonization kernel, based on the LMS daltonize algorithm, could expose 5% of the population with dichromatic vision to details they would have otherwise missed.  The simulation kernel, targeting the other 95% of the population, can be used to see what motion pictures look like through the eyes of the color blind.

Photoshop installation
  1. Install Photoshop's Pixel Bender plug-in (it's not built unless you're on CS5).  You can find this plug-in at the Pixel Bender Technology Center.  
  2. Put the Pixel Bender .pbk filters you wish to install (see Pixel Bender kernels) into the ~/Adobe Photoshop CS4/Pixel Bender Files/ directory on your computer.  
  3. Open the "Filter" menu from within Photoshop and click on "Pixel Bender Gallery".
After Effects installation
  1. Put the Pixel Bender .pbk filters you wish to install (see Pixel Bender kernels) into the ~/After Effects CS4/Plug-ins/Effects/ directory on your computer.  
  2. Open the "Effects" menu from within After Effects
Flash Player embedding
The code to import Pixel Bender kernels into Flash Player can be found in Main.as, Daltonize.as and Simulate.as.  The kernels must be compiled into .PBJ, which you can find in the parent directory.

Developers
If you're interested in messing around with the code behind these filters, download the Pixel Bender Toolkit to load the Pixel Bender .pbk filters included in this article.  Another great place to start is the Pixel Bender's Developer Guide.

Pixel Bender kernels

References
  1. Françoise Viénot, Hans Brettel and John D. Mollon
    Digital video colourmaps for checking the legibility of displays by dichromats
    Color Research and Application, 24(4): 243-252
    , 1999.

  2. Onur Fidaner, Poliang Lin and Nevran Ozguven.
    Analysis of Color Blindness

  3. Gary W. Meyer and Donald P. Greenberg
    Color-Defective Vision and Computer Graphics Displays
    IEEE Computer Graphics and Applications, 8(5): 28-40, 1988.

  4. Vivianne C. Smith and Joel Pokorny
    Spectral sensitivity of the foveal cone photopigments between 400 and 500 nm
    Vision Research, 15(2): 161-171, 1975.
     
  5. Bruce Lindbloom
    RGB Working Space Information

Monday, May 10, 2010

Color Vision with ColorLookupTables

Any color correction can be expressed as a color look-up table (CLUT); a mechanism used in image processing to transform a range of input colors into output colors.  There are 16,777,216 colors available in the standard RGB color space.  One way of representing this data is to create an image containing 4096 x 4096 pixels — when arranged in a specific way, this image is called a Hald CLUT (see "Identity" for normal vision below).  Hald CLUTs are supported by ImageMagick, and GraphicsMagick.  Other possible uses would be to offload the data onto an FPGA or an ICC profile, thereby filtering the entire display.

The following images were created using Photoshop's PixelBender plugin and the Color Vision Library.  Google Chrome, and Safari were both fast enough to process this data without timing out, unfortunately, they don't allow right-click to save the <canvas> as a PNG.

Identity
Normal Vision

Protanopia
Simulate missing red-cone
Daltonize missing red-cone


Deuteranopia
Simulate missing green-cone
Daltonize missing green-cone

Tritanopia
Simulate missing blue-cone
Daltonize missing blue-cone

LMS Daltonization Algorithm

Implementations:
  1. Matlab code from Analysis of Color Blindness
  2. Python code from AccessibleMoin
  3. Javascript code from Daltonize.org
  4. PixelBender code from Daltonize.org
Composed of four primary steps:
  1. Conversion of RGB coordinates into LMS, a color space suitable for calculating color blindness as it's represented by the three types of cones of the human eye, named after their sensitivity at wavelengths; Long (564–580nm), Medium (534–545nm) and Short (420–440nm). 

  2. Simulation of color blindness by reducing the colors along a dichromatic confusion line, the line parallel to the axis of the missing photoreceptor, to a single color.

  3. Compensation for color blindness by shifting wavelengths away from the portion of the spectrum invisible to the dichromat, towards the visible portion.

  4. Conversion of LMS coordinates back into RGB using the inverse of the RGB->LMS matrix.
LMS daltonization evolution:
  1. Analysis of Color Blindness
    Describes how to compensate for color-blindness by calculating the difference of the simulation, and then applying an error modification matrix.

  2. Intelligent modification for the daltonization process of digitized paintings
    Describes how to improve the error modification matrix by modifying it to be adaptive to each image; increasing CPU usage and providing better results.

  3. Intelligent Modification of Colors in Digitized Paintings for Enhancing the Visual Perception of Color-blind Viewers
    Optimizes the previous, reducing computational time through the use of color quantization, and caching.