Color Deconvolution


The overall colors seen in H&E stained slides can vary widely, influenced by factors such as the precise stains and scanner used. This MATLAB function implements the color normalization strategy described in Macenko et al (2009) in order to match stain colors in an image more closely to 'reference' stains. This may help when comparing images visually, or when applying an automated analysis algorithm.

The function may also be useful to understand the functioning of the color deconvolution described in Ruifork and Johnston (2001).

has topic
has function

Analyzing ER, PR, and Ki-67 immunohistochemistry

ImmunoRatio is an ImageJ plugin to quantify haematoxylin and DAB-stained tissue sections by measuring the percentage of positively stained nuclear area (labeling index), described in [bib]2452[/bib].

Notes for use:

  • It is important to read the URL instructions and original paper to understand what is being measured. In particular, the primary measurement made is percentage of the total nuclear area, not the percentage of detected nuclei (the latter being the more common method of assessing e.g. Ki67). This may be further modified by the Result correction equation.
  • Ultimately ImmunoRatio relies on thresholding (color deconvolved [bib]2451[/bib]) images to define 'nucleus' vs 'non-nucleus' regions according to staining intensity. Therefore dark artefacts, such as tissue folds, are likely to cause errors.
  • The pixel size is not read automatically from the image, but rather the source image scale should be entered into the dialog box - and the image rescaled accordingly prior to analysis. This scale value is the inverse of the value normally found for pixel width and pixel height under Image -> Properties... (i.e. pixel width & height are given in microns per pixel; the dialog box asks for pixels per micron).

Web application: ImmunoRatio

Example Image: Sample ImmunoRatio results


  1. [2452] Tuominen VJRuotoistenmäki SViitanen AJumppanen MIsola J.  2010.  ImmunoRatio: a publicly available web application for quantitative image analysis of estrogen receptor (ER), progesterone receptor (PR), and Ki-67.. Breast Cancer Res. 12(4):R56.
  2. [2451] Ruifrok ACJohnston DA.  2001.  Quantification of histochemical staining by color deconvolution.. Anal Quant Cytol Histol. 23(4):291-9.
has topic
has function

[no download link, this description itself explains the steps to quantify staining in tissue sections]

The Color Deconvolution plugin for ImageJ can be used to digitally separate up to three stains from brightfield images, after which standard ImageJ commands can be used. The algorithm is described in Ruifork and Johnston (2001).

However, it is very important to take into consideration the caveats on the linked URL. In particular, note that:

  • Stain colors depend on numerous factors, such as the precise stains and scanner; therefore, the 'default' stain vectors (used to define the colors) are unlikely to be optimal and may be very inaccurate. See the URL instructions for how to create new stain vectors.
  • Pixel values should be interpreted with extreme caution; in particular, note the warning regarding 'brown' staining that attempting to quantify DAB intensity using this plugin is not a good idea.

Note, the pixel values provided by this plugin are 8-bit and not equivalent to 'optical densities' frequently presented in the literature.

Color deconvolution is particularly helpful in separating stains so that stained regions can be detected (e.g. by setting a threshold), and then the number or areas of stained structures may be quantified. Two potential approaches would be:

  1. If one measurement should be made for the entire image:
    • Image > Adjust > Threshold...
    • Edit > Selection > Create Selection
    • Analyze > Measure
  2. If distinct structures should be measured:
    • Image > Adjust > Threshold...
    • Analyze > Analyze Particles...
has topic
has function

This plugin is bundled with Fiji. For installation in ImageJ1, download from the link below and manually install the class file. 


The colour deconvolution plugin (java and class files) for ImageJ and Fiji implements stain separation using Ruifrok and Johnston's method described in [1]. The code is based on a NIH Image macro kindly provided by A.C. Ruifrok.
The plugin assumes images generated by colour subtraction (i.e. light-absorbing dyes such as those used in bright field histology or ink on printed paper). However, the dyes should not be neutral grey (most histological stains are not so).
If you intend to work with this plugin, it is important to read the original paper to understand how new vectors are determined and how the procedure works.
The plugin works correctly when the background is neutral (white to grey), so background subtraction with colour correction must be applied to the images before processing.
The plugin provides a number of "built in" stain vectors some of which were determined experimentally in our lab (marked in the source with GL), but you should determine your own vectors to achieve an accurate stain separation, depending on the stains and methods you use. See the note below.
The built-in vectors are :

  • Haematoxylin and Eosin (H&E) x2
  • Haematoxylin and DAB (H DAB)
  • Feulgen Light Green
  • Giemsa
  • Fast Red, Fast Blue and DAB
  • Methyl green and DAB
  • Haematoxylin, Eosin and DAB (H&E DAB)
  • Haematoxylin and AEC (H AEC)
  • Azan-Mallory
  • Masson Trichrome
  • Alcian blue & Haematoxylin
  • Haematoxylin and Periodic Acid - Schiff (PAS)
  • RGB subtractive
  • CMY subtractive
  • User values entered by hand
  • Values interactively determined from rectangular ROIs
has function