Adapted from Counting Sheep: Image Analysis by Claudia Neuhauser

Adapted from Counting Sheep: Image Analysis by Claudia Neuhauser

Getting Started with Image Analysis Plant IT 2010 July 13, 2010

Adapted from Counting Sheep: Image Analysis by Claudia Neuhauser

A Brief Introduction to Using ImageJ

ImageJ is a NIH resource for processing and analyzing images. The software can be downloaded from the ImageJ web site: http://rsbweb.nih.gov/ij/

The documentation can be found at http://rsbweb.nih.gov/ij/docs/index.html

Tutorials are found at: http://rsbweb.nih.gov/ij/docs/examples/index.html

Learning Objectives

You will be able to

  • load images into ImageJ
  • prepare images for image analysis
  • perform simple image analysis (counting and measuring)
  • save image data to excel files

Knowledge and Skills

  • using imaging software for image analysis
  • mathematical concepts: circularity

Prerequisites

  • measurement of area and distance for objects
  • count objects within the image

Introduction

ImageJ is a public domain software that can be downloaded on a variety of platforms, including Windows and Mac. The software can convert many image formats including GIF, JPEG, and TIFF to to 8-bit, 16-bit, or 32-bit images, which can then be analyzed by ImageJ.

We will use ImageJ to measure distances and count objects. Since TIFF is the least degradable format when an image is repeatedly used for analysis, it is recommended to save any image first as TIFF before conversion to 8-bit, 16-bit, or 32-bit.

Counting Objects

To learn how to count objects, we will count the number of sheep in an aerial photo. Load the image sheep1.tif.

sheep1 tif

The image is already in TIFF format. We need to change it to a bit format before we can use any of the tools within ImageJ: Image > Type > 8-bit

To segment the image into the objects of interest and the background, we use thresholding

Image > Adjust > Threshold

A dialog box pops up where we can adjust the threshold so that only the pixels of the objects of interest appear. Choose Black & White in the drop down menu within the dialog box. Choose ellipses in the menu. Click Apply. The image will change into a black and white picture. Adjust using the sliders so that where the pixels of the objects of interest are white and all other pixels are black.

Under Edit in the menu, choose Invert. The background will appear white emphasizing the ellipses (sheep).

To count the objects, we use the Analyze menu

Analyze > Analyze Particles

A dialog box pops up where we need to enter the size and circularity of the objects, and what we want to show. In order to count only particles above a certain number of pixels, enter a single value into the Size field. Particles smaller than that value will be ignored.

Now we need to consider the shape of the particle to be counted. If the object is circular, the value of the quantity Circularity is equal to 1. Sheep are not round when viewed from above, so we need to adjust the circularity.

To understand the concept of circularity, we can look at ellipses with different values of the major radius a and minor radius b. The area of an ellipse is equal to . There is no simple formula for the perimeter of an ellipse. But circularity is approximately:

The following table provides values for circularity for different increasingly flattened ellipses:

a / b / C
1 / 1 / 1.00
2 / 1 / 0.80
3 / 1 / 0.60
4 / 1 / 0.47
5 / 1 / 0.38
6 / 1 / 0.32

Enter Size and Circularity into the dialog box, and check Display, Clear, and Include Holes.

You should start by using 5 as the value for Size. (Why are we doing this?)

Use 0.3 for Circularity to get a total count. (Be ready to explain why this is a good value.)

Count 1:

Try to increase the accuracy of your total count by fine adjustments to the threshold or changes in size and circularity.

Count 2:

Count 3:

Save your results by selecting the results window and choosing save under File in the menu. Note your data is in an Excel file. Note the area value for each sheep. (What does this tell you?)

How many sheep? Partitioning the image and counting by hand reveals 95 sheep.

Measuring Objects

To learn how to measure objects, we will measure the diameter of wool fibers in the micrograph. Load the image woolfiber.tif.

Wool is also separated into grades based on the measurement of the wool's diameter in microns and also its style. These grades may vary depending on the breed or purpose of the wool. Any wool finer than 25 microns can be used for garments, while coarser grades are used for outerwear or rugs. The finer the wool, the softer it is, while coarser grades are more durable and less prone to pilling.

Grade / Diameter of fiber (microns)
Ultrafine Merino / <15.5
Superfine Merino / 15.6-18.5
Fine Merino / 18.6-20
Medium Merino / 20.1-23
Strong Merino / 23<
Comeback / 21-26
Fine crossbred / 27-31
Medium crossbred / 32–35
Coarse crossbred / 36> microns
Carpet wools / 35-45 microns

To set the scale for this measurement,

Image > Adjust > Threshold

A dialog box pops up where we can adjust the scale so that the pixels of the objects of interest appear. Choose Black & White in the drop down menu within the dialog box. Choose ellipses in the menu. Click Apply. The image will change into a black and white picture. Adjust using the sliders so that where the pixels of the objects of interest are white and all other pixels are black.

1