June 3, 2004
Measurement of Percent Area
This exercise selects features of an image by thresholding,
and measures the number of 'red' pixels with the Analyze ->
- Open the Sample Images / MAS Journal Article / TEM Filter Sample.tiff
image with the File -> Open menu
- (part of image shown).
- Examine the histogram
- NIH Image only
- Make sure the Invert Pixel Values box is checked (Options
-> Preferences menu), so that lighter image gray levels have
higher pixel values.
- Analyze -> Show Histogram menu.
- There are no pixels with low values - corresponding to the absence
of darker shades in the image.
- Analyze / Histogram shows
- There are very few pixels with high values,
corresponding to darker shades in the image.
The image appears washed out. It can be enhanced to make the
holes in the filter easier to see.
- ImageJ: Be sure to click on the image to make
it active. Otherwise, the histogram, which is also an image, will be
active, and will be "enhanced". The histogram is primarily
a black and white image, and will show no change on "enhancement".
- Process -> Enhance Contrast
- Use the default settings in the dialog.
The features in the image are easier to see. The gray levels have not been
changed, as reapplying the Analyze -> Show Histogram Analyze
-> Histogram menu will show.
- To actually change the pixel values:
- NIH Image: Process -> Apply LUT.
- ImageJ: Repeat Process / Enhance
Contrast, but this time check the Normalize
- Analyze -> Show Histogram Analyze
/ Histogram to see the modified histogram
- Note that there are not more gray levels in this enhanced image - the
gray levels are just spread out. Adding new gray levels between the old
ones might be done with a smoothing operation, but not using the LUT.
Either the enhanced image or the original can be thresholded
with the same effect, since the number of gray levels is the same.
The enhanced image may be easier to use, since the details are
more easily seen, and using the thresholding tool is less
Measure the percent area of the pores in the filter.
- First, the pores must be selected using the thresholding tool (colored
- NIH Image:
- Double-click on the thresholding tool , and move the top and bottom of the red band
in the LUT window to select the pores as well as possible.
- Image / Adjust / Threshold Move
the sliders to select the pores (turn them red):
Two problems immediately appear. Red pixels are missing inside
the pores where they should be, and there are red pixels outside
the pores where they should not be.
- Both problems are almost completely eliminated by one application
of the Process -> Smooth menu.
We will ignore the remaining red dots that lie outside the
pores. We will also not check for any slight alteration of pore
area that the smoothing might have caused.
- Alternative ways to clear up the problems:
- (Does not apply to ImageJ). The holes inside
the pores are due to those pixels having value 255, which cannot be thresholded.
These pixels can be selected after adding and subtracting 1 to the image,
because of the scaling rules Image uses (see manual).
- Process -> Arithmetic -> Add, select 1.
- Process -> Arithmetic -> Subtract, select 1.
- The extra pixels outside the pores can be taken care of by making a
binary image from the thresholded image with the Process -> Binary
-> Make Binary Process / Binary / Threshold
menu, and then removing the isolated single pixels in the binary
image with the Process -> Binary -> Open menu, and analysing
the result. The open menu erodes a one pixel layer from every object
(black) and then dilates a layer back on (these are available in
the Binary menu). Since the erosion eliminates objects that are
one pixel thick, there are no pixels left to dilate, and these objects
are eliminated, while the others are (almost) their original size. Process
/ Binary / Close will fill small holes. Your result might
look something like this:
Counting and sizing pores with NIH Image
- With the thresholded image (Upper and Lower are 227 - 254 in the Info menu,
when the mouse button is held down and the threshold tool is in the LUT window)
- Analyze -> Measure menu, see 14127 square pixels in the Info
- Select the entire image with the threshold tool, and use the Analyze
-> Measure menu again. See 207944 in the info menu. (Otherwise, determine
the area of the image by multiplying the height x width. The only way I
know to find that using Image is to carefully move the cursor to the upper
right, seeing 499 and 416 for X and Y. The image is 500 x417 - the lower
left pixel is (0,0) in Image.)
- The % area (approximately) of the pores is 100 x (14127 / 207944).
- Note that without adding and subtracting 1 from the image (in the bullet
above this one), that a small percentage of the area of the particles that
has a pixel value of 0 (255), and cannot be selected. We are ignoring this
- Measure the percent area of the particles in the image by selecting them.
Note that what constitutes 'particle' is your choice - there are faint gray
splotches that could be considered particle or background.
- List the pores and their areas and diameters:
- Select the pores by thresholding as above.
- Analyze -> Options menu, check Area, Ellipse Major
Axis and Ellipse Minor Axis.
- Invoke the Analyze -> Analyze Particles menu, checking
all of the boxes, and selecting a reasonable minimum particle
size so as not to count any remaining single or double red pixels.
- NOTE: Lables and outlines are drawn right on the image,
making it useless for a second analysis. Make a copy of the image,
or save it to a file before analyzing.
- An image with the particles labeled and outlined is the result:
- and the properties are
listed in a table in a text window using the Analyze -> Show
Results menu. This table can be saved as a text file (File
-> Save As menu, click the Measurements button)
and imported into statistical or plotting packages.
- NOTE: If the Label Particles box is checked,
but the particles are not labeled, there are probably more particles
in the image than the Max Measurements parameter allows.
Increase Max Measurements in the Analyze -> Options
dialog and restart Image.
(part of table shown)
Counting and Sizing Pores with
This proceedure starts fresh - you might
already have the image open from above steps.
- File / Open and
select Sample Images / MAS Journal Article / TEM filter sample.tiff.
- Smooth with Process / Filters / Median /
radius of 2 pixels.
- Image / Adjust / Threshold, thresholds
249 - 242.
- Analyze / Measure Particles, set
the options like this:
- The summary window shows that the percent area of
the pores is 6.5%:
- The drawing shows each pore outline and label:
- And the results window lists the area for each pore.
You can cut and paste these results to Excel, or save them to a file.
(Only the first seven pores in the list are shown.)
- Other sample images
- Sample Images / Proc samples / Apt#3
- All of the particles can be selected by thresholding. When
the darker particles at the bottom of the image are selected,
the brighter particles at the top tend to be joined together
-- these particles will add to the total a little more than their
- To measure the area of the background, which as loaded has
a level of 255 (not reachable with the LUT tool)
- Process->Arithmetic->Add... menu. Select 2 (the
default is 25).
- Process->Arithmetic->Subtract... menu. Select
- Sample Images / Proc samples / Rainey Nickel.tiff
- This is more of a challenge because the two lighter phases
cannot be cleanly selected by thresholding without some processing.
- The image has noise, which can be removed by smoothing.
- The illumination (over-all signal level) falls off to the
- The easiest way around the problem with this particular image
is to divide it in half, and measure the left and right halves
- Alternatively, the image can be flattened by convolving a
copy of the image several times with the Mean(63x63 ) kernel
(this is the largest available in Image), and using the paste
control to divide the original by the smoothed copy. (This
does not appear to work properly with Scion Image - the gray
levels are reduced such that the three phases are no longer distinguishable.)
- FFT low cut filtering does not seem to work on this image
as well as on the Betsy image in the FFT
Flatten Illumination exercise. The requirement is more stringent
here - the gray levels in each phase must be flat for thresholding,
this is harder than making the image just look better. If too
many low frequencies are removed , each phase becomes
more shaded. If too few low frequencies are removed , the
image still has a gray level gradient going across it. (The gradient
is apparent if a red band, 1-2 cm long in the LUT window is moved
up and down with the mouse, while observing the gray areas in
the image.) Perhaps more precise low cut filtering, using the
FFT macros, would be sufficient.