Quantifying Stained Liver Tissue

The goal in this example is to quantify the red-stained collagen in an image of a mouse liver tissue section stained with Sirius Red. The image is courtesy of Dr. Ashish N. DebRoy, a Pediatric Gastroenterology Fellow at the University of Iowa. Dr. DebRoy is studying the effects of a high fat diet on liver injury in mice. The original 1360x1024 RGB image (C57_HFD7_4.zip) is available for download.

There are four steps:

  1. Change the scale to micrometers
  2. Convert the image to grayscale
  3. Segment (isolate) the red-stained collagen using thresholding
  4. Measure the thresholded area
[mouse-liver-section]
Notice that the size of the image, as shown in the sub-title, is 9.44 x7.11 inches, which is obviously not correct. We can fix this by measuring the length of the scale bar and using the Analyze>Set Scale command to set the scale to micrometers. To measure the scale bar, use the straight line selection tool (fifth tool from the left on the ImageJ tool bar) to create a line selection along the length of the scale bar, as shown below.
[scale bar]
Next open the Analyze>Set Scale dialog box. Notice that the length of the line selection (317 pixels) is automatically entered as the "Distance in Pixels". Enter the scale bar length (200 µm) as the "Known Distance" and "um" as the "Unit of Length". ImageJ will automatically convert the "u" to the micrometer symbol (µ). Click "OK" and notice that the image size has changed to 858.95x646.74 µm.
[set scale dialog]
Next use the Image>Type>RGB Stack command to split the image into red, green and blue channels. This is necessary because the Image>Adjust>Threshold tool only works with grayscale images. Try to threshold an RGB image and you will get a lot beeps and the status bar message "RGB images cannot be thresholded". Move the slider to view each of the channels. Notice that the green channel has the best separation.
[RGB stack]
Use the Image>Stacks>Make Montage command to view all three channels at the same time.
[RGB channels]
Select the RGB stack (with the Green channel selected) and press shift-t (Image>Adjust>Threshold). The "Threshold" tool opens and the the green channel is automatically thresholded. Unfortunately, ImageJ is not able to correctly threshold this image so the threshold must be manually adjusted. Do this by moving the the lower slider until the stained collagen is highlighted in red. Notice that the threshold level arrived at manually is about half the automatically set level of 175. Click on "Set" and set the upper level to 175/2, or 87. Setting a threshold that is a fraction of the automatically determined threshold will allow us to later create a macro that does not require manual thresholding.

Next we must erase the scale bar to prevent it from being included in the calculated area. To do this, use the rectangular selection tool to select the scale bar, then press Backspace (Delete on the Mac). If the current background is not white, use the color picker tool (Image>Color>Color Picker) to change it to white. Note that the current background color is indicated by the color of the border surrounding the eye dropper tool icon.

[Thresholding]
We are almost ready, but first we have to tell ImageJ what to measure by opening the Analyze>Set Measurements dialog and checking "Area", "Area Fraction", "Limit to Threshold" and "Display Label". Then press "m" (Analyse>Measure) and the area and percent area will be displayed in the "Results" window. Right click in the "Results" window and select "Save As" to save the results as a tab-delimited text file or select "Copy" to copy the results to the Clipboard.
[Results]
Another way to measure the red-stained collagen is to convert the thresholded portion of the image to a selection using Edit>Selecton>Create Selection, transfer the selection to the original RGB images by selecting it and pressing shift-e (Edit>Selecton>Restore Selection), and then pressing "m" (Analyse>Measure) to measure the area of the selection.
[Selection]
Below is a macro that automates the analysis. To run it, copy it to the clipboard, switch to ImageJ, press shift-v (File>New>System Clipboard), click on the "Clipboard" window and press ctrl-r (Macros>Run Macro). Information about the ImageJ macro language is available at
   rsb.info.nih.gov/ij/developer/macro/macros.html

   // select the green channel, which has the best contrast
   run("RGB Stack");
   setSlice(2);
   // change scale from inches to microns
   run("Set Scale...", "distance=317 known=200 pixel=1 unit=um");
   // erase scale bar
   setBackgroundColor(255, 255, 255);
   makeRectangle(1019, 906, 320, 44);
   run("Clear", "slice");
   run("Select None");
   // set threshold
   setAutoThreshold();
   getThreshold(min, max)
   setThreshold(0, max/2);
   // measure area and area fraction
   run("Set Measurements...", "area area_fraction limit display redirect=None decimal=3");
   run("Measure");
   selectWindow("Results");  
   
A second image (C57_CT5_4.zip) is available for testing the macro. The "Results" window below contains the output resulting from running the macro on both images. The "Label" column displays the image title and channel.
[stained section]
| Examples | Home |