NIH Image can acquire, display, edit, enhance, analyze, print and animate images.
It reads and writes TIFF, PICT, PICS and MacPaint files, providing compatibility
with many other applications, including programs for scanning, processing, editing, publishing
and analyzing images. It supports many standard image processing functions, including
contrast enhancement, density profiling, smoothing, sharpening, edge detection, median filtering, and spatial convolution with user defined kernels. A series
of images can be animated or viewed in a stack. Particles can be counted and sized.
NIH Image can be customized using a Pascal-like macro programming language and
through use of plug-in code modules.
NIH Image comes with many other files: a user manual ("NIH Image Manual"), a programmer's guide ("Inside NIH Image"), a folder of convolution kernels, and a folder
of macros. In addition, the NIH Image FTP site (zippy.nimh.nih.gov) has numerous
example images including those used in this paper (via anonymous FTP from zippy.nimh.nih.gov,
in the /pub/nih-image/images and the /pub/nih-image/stacks directories), and it has macros and plug-ins, as well as several enhanced versions of NIH Image.
MacLispix, described in an accompanying article in this issue, is another public
domain image processing program for the Macintosh, which does some of the same things
but in different ways. MacLispix is not as polished a Macintosh application as
is NIH Image, but is intended for more special purpose analyses such as three dimensional
scatter diagrams, principal components and chemical phase analysis, and for instances
where more numerical precision than 8 bits per pixel is needed.
Features
NIH Image conforms well to the Macintosh user interface standard, and is visually
and graphically oriented, making it easy to use with little experience. For example,
NIH Image has a palette of tools for drawing, measuring and examining images which
are fully described in "About NIH Image". A variety of measurements can be made on
user-specif ied regions of interest and results exported to a spread sheet or plotting
package. The "LUT" (color look up table) and "Map" windows allow control of the
video lookup table, providing flexible contrast enhancement and false color. The
"Info" window displays cursor position, pixel values, selection size, line length,
etc. Images, look-up tables, macros and convolution kernels can be opened by dragging
them to the NIH Image icon.
System requirements
NIH Image requires a Mac II or later with 8 MB or more of RAM. (Running NIH Image
on a 4 MB Mac is a struggle.) System 7 or later is also required for versions 1.56 and later (because of the plug-ins and 24-bit to 8-bit color conversion), and for many of
these examples. A Power PC native version is available as well as a non-FPU version
for Macs without a floating-point co-processor.
NIH Image Users
There is an active electronic mailing list on the Internet with over 1000 subscribers
and a dozen messages or so a day covering topics such as a) news of the latest
versions of NIH Image b) special purpose macros c) image processing tips using
NIH Image d) hardware - frame grabbers e) bugs, wish list items. Subscribe to the list
by sending the one line message "subscribe nih-image <first name> <last name>"
to listproc@soils.umn.edu.
The user base for NIH Image is large: over two thousand copies of v1.55 alone have
been downloaded from the NIH Image FTP site.
Examples
( The actual steps begin with bullets.)
These examples are meant to be cook-book type lists that can be followed by a new
user to get started. Menu commands are shown in italics, for example, File - Open
is the Open command in the File menu.
Starting up and configuring
Reading in an image
TIFF, PICT, PICS (for a stack of images) and a few other file formats are read and
displayed using the File - Open
command. Files can also be opened in groups either by selecting them in the Finder
and dragging and dropping them on the icon of the NIH Image application, or, if
a folder contains images of interest only, by selecting the Open All button in
the Open
command dialog. The Open
command will also read IBM PC ".TIF" files and text files. Raw data, that is images
without any encoding or header information, can be also be read with the File - Import
command. Although several file formats such as TIFF are becoming widely accepted,
the raw format with one byte (8 bits) per pixel is still useful for moving images
between different computer systems, but one must remember to keep track of the image
dimensions when the image is originally recorded, e.g. 480x640 pixels.
The image can be modified with the drawing tools - the pencil, eraser, brush, line drawing tool, paint bucket and spray can - as explained in the manual "About NIH Image". It is of interest here to note that
when the image has been zoomed so that the individual pixels are visible, single
pixels can easily be modified one by one with the pencil tool. The shade of gray
applied by the pencil tool is the shade inside the paintbrush, which can be changed by
clicking on the eyedropper tool, then clicking on the desired shade either in the
color bar or in the image.
Depressing the option key will change the "+" to "-" inside the magnifying glass
tool, which will reverse the effect of the zooming. Restore the image to its original
state with the option key and zoom tool. If you have done any drawing on the image, also use the File - Revert To Saved
command to return to the unmodified image. To avoid undesired drawing on the image
when proceeding, select the rectangular selection tool by clicking on its icon at the upper right
of the Tools window.
Display and Contrast Enhancement
Contrast enhancement can also be done by using the mouse to move the B (brightness)
and C (contrast) sliders in the Map window, by moving any of the three dots on the
graph in the Map window, or by selecting the LUT tool and manipulating the color
bar in the LUT window.
The changes in the pixel values can be seen easily by looking at the histogram before
(Fig. 6a) and after (Fig. 6b) the log operation, using Analyze - Show Histogram
. The changes in pixel values will also be seen in the Info window, as the cursor
is moved around the image, but they will be less obvious because the logarithms
have been rescaled to integer values (actually 8 bit byte values) between 0 and
255, which is the same value range that the original image had.
Intensity Profile
Thresholding, Smoothing and Counting Particles
Note that intensity levels of 0 and 255 are not accessable for thresholding. I.e.,
zero and 255 can't be within the density slice because those entries in the lookup
table can never be colored red. 0 is always white and 255 is always black. This
is intentional, to prevent loosing the mouse, tools, etc. due to thresholding. If an image shows
saturation, either in the black or white, then pixels with values of 0 or 255 might
likely appear within the areas of interest, but not be selectable via thresholding.
If the image has values of 0 that need to be selected, for example, they may be changed to value 1 using the Process - Arithmetic command
twice: 1) Arithmetic - subtract
, then use 1 as the constant to subtract. NIH Image clips results of arithmetic
so that they lie within the range 0-255, so this subtraction results in all pixels
being lowered by one intensity unit, except for the zero valued pixels which are
still zero. Note that this affects the internal pixel values - if the Invert Pixel Values
box is checked, then the values to read are in the parentheses to the right in the
Value: line of the Info window. 2). Arithmetic - add
, then use 1 as the constant to add. This results in all pixel values being restored,
except for the old zero valued pixels, which now have the value 1, along with the
pixels which used to have the value 1. Use the reverse arithmetic sequence to
lower pixels with value 255 down to 254. (Note 1. This can also be done using Process - Fix Colors
.)
Noise in the image causes lots of little red selected areas and some holes in the
red dots representing the pores. Most of the noise in this case can be ignored
by the Analyze - Analyze Particles
command by setting the 'Min Particle Size' to something greater than the area of
the small red dots (such as 10 pixels), and by checking the 'Include Interior Holes'
box. Alternatively, smoothing the image will get rid of a lot of the dots (Fig.
10). Do this with the Process - Smooth
command.
Size calibration and photographing
A version of the TEM filter image, rendered for publication with a micrometer marker
and with a black background, is shown in Fig. 15. This figure was made using the
calibration feature of NIH Image, the Text tool, the line drawing tool, and the
Photo Mode
command:
Illusions
A couple of illusions of the visual system are illustrated well with NIH Image:
Mach Bands, and the brightness vs. background illusion. Both of these affect how we see our data if the data is represented as
images. The first can simulate a gradient (of intensity, concentration or whatever)
where there is none, and the second can alter the interpretation of numerical values from gray levels using annotated scale bars.
Mach Bands
Foreground/Background
Often, annotated gray scale wedges or color bars are used to infer numerical values
from images using the gray scales or colors. In some instances, in particular when
a more natural or smooth color scale is used, this can be prone to error.
If our perception of gray levels is faulty here, then our perception is also likely
to be faulty when 'matching' gray levels in an image to a gray ramp or color bar.
Multiple images (stacks)
NIH Image has the capability of handling stacks of images, such as those making up
a three dimensional data set. 'Boron stack.pics' is an example of a stack of 50
Boron images (Gillen, 1994) of grain boundaries in a steel sample. The images
were taken at equal time intervals with an ion microscope, which etches away the surface at
a more or less constant rate. The images thus approximate serial sections of the
steel sample. (The stacks can be saved in two formats - PICS and TIFF. The boron stack requires 618K in PICS format and 4232K in TIFF format. The TIFF format is more widely used, but the PICS format was used
for this example to save space.)
Many capabilities of NIH image could not be covered in a paper of this length. Among
these are image arithmetic, background subtraction, operation of frame grabber cards,
and using the rapidly increasing number of plug-ins. Use of these is covered in 'About NIH Image'.
This paper is to give the microscopist hands-on experience with some of the tools
provided by NIH Image for the inspection and analysis of digital images. Many
laboratories use it on a daily basis for acquiring images, sharing data and writing
papers, as well as for analyzing images and enhancing them.
Published research assisted by the use of NIH Image should use the following quote
in the materials and methods section "... analysis performed on a Macintosh <model>
computer using the public domain NIH Image program (written by Wayne Rasband at
the US. National Institutes of Health and available from the Internet by anonymous FTP
from zippy.nimh.nih.gov.
NIH Image is an indispensable tool for the analysis and sharing of digital micrographs.
Gillen 1994, Image stack provided by Dr. Greg Gillen, Surface and Microanalysis Science
Division, NIST. (personal communication)
O'Neill, R.R., Mitchell, L.G., Merril, C.R., Rasband, W.S. (1989) "Use of image analysis
to quantitate changes in form of mitochondrial DNA after x-irradiation", Applied
and Theoretical Electrophoresis 1: 163-167.
Steel, 1993, TEM Filter image provided by Dr. Eric Steel, Surface and Microanalysis
Science Division, NIST. (personal communication)
Fig. 1-- Portion of screen containing image "TEM filter sample.tiff" as loaded, along
with the menu bar and the LUT, Tools and Map windows of NIH Image. Note overall low contrast,
but appropriate contrast for detail in the more dense particles. (Figures that
follow do not include the menu bar, which is included here to show the appearance of the entire upper left corner
of the Mac screen.
Fig. 2 -- TEM filter sample image in Fig. 1 with linear contrast enhancement as done
by the Process - Enhance Contrast
command. Note that the slope of the line in the Map window has increased, the black
to white region in the color bar (LUT window) is shortened, and that more of the
particles with less contrast and more of the filter substrate can be seen.
Fig. 3. -- Filter sample image with histogram equalization.
Fig. 4. -- Filter sample image with hand drawn LUT.
Fig. 5. -- Thermal scale enhancement. Logarithm of filter image (Process -Arithmetic - Log
command) false colored with the thermal scale (Options - Color Tables - Fire-1
command).
Fig. 6. -- a) Histogram of original image. Observe using the Revert To Saved
command and then the Analyze - Show Histogram
command. b) Histogram of Logarithm image. Observe using the Process -Arithmetic - Log
command and then the Analyze - Show Histogram
command.
Fig. 7. -- Filter image shown with system LUT. This is rarely useful for analysis,
but sometimes occurs upon switching to and from the Finder.
Fig. 8. -- Illustration of the line profile tool. -- plot across the filter, a pore
and a particle. Left inset - plot of single pixel values along line as shown.
Right inset - plot of averaged pixel values along a 'fat' line (not shown), with
width of bottom line in the line width tool.
Fig. 9. -- Filter image with pores selected using thresholding (see text).
Fig. 10. -- Pores in smoothed TEM Filter image selected by thresholding.
Fig. 11. -- Result of Analyze Particles
command. Pores are outlined and numbered.
Fig. 12. -- Table of results corresponding to Fig. 11 (only first 12 rows shown),
shown with Show Results
command.
Fig. 13. -- Particles in smoothed TEM Filter image selected by thresholding.
Fig. 14. -- Result of Analyze Particles
command. Particles are outlined, except for the one touching the edge at the lower
right.
Fig. 15. -- Contrast enhanced version of the Filter image suitable for publication,
with micrometer bar. Black background not shown. (The figures were made by 'capturing'
the screen (shift-command-3), a function provided by the Macintosh operating system, or by pieces of software such as 'Capture'*. Capturing does not work in the
photo mode, so only the image window is shown in this figure.)
Fig. 16. -- Mach Band Illusion, generated with NIH Image (see text). Bands appear
darker on the left and brighter on the right although they are of uniform color.
Fig. 17. -- Foreground/Background illusion (see text). The small rectangles all
have the same shade of gray, although they appear to have differing shades of gray.
Fig. 18. -- Foreground/Background illusion persists when a thermal scale is applied
to the image.
Fig. 19. -- Foreground/Background illusion does not persist with 'unnatural' or 'false
color' type color scales. This scale applied to the image with Options - Color Tables - Spectrum
command.
Fig. 20. -- The stack of images 'Boron Stack.pics' as it appears after loading.
First image in the stack of 50 is displayed, with a thermal scale. Image dimension
- 100 m.
Fig. 21. -- Montage of the Boron Stack, with an Increment of 2 in the Stacks - Make Montage...
dialog box.
Fig. 22. -- Line selection for viewing stack along plane perpendicular to the images - see next figure.
Fig. 23. -- Boron stack viewed perpendicular to images in plane intersecting dotted
line, Fig. 22.
Fig. 24. -- Synthetic volume rendering of Boron Stack, done with the Stacks - Project
command (see text). First frame - top view, gray scale.
Fig. 25. -- Volume rendering of boron stack - montage of every other frame showing different rotations, gray scale. The three-dimensional structure of these
grain boundaries is more apparent upon viewing the animation of this stack using
the Stacks - Animate
command.