NIH Image: An Introduction and Tutorial

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.

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.


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 the "Tools" section of the NIH Image manual. 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. Instructions for subscribing to list can be found in the FAQs section of the NIH Web page.

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.


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

Select the Monitors control panel in the Control Panels folder (from the Apple - Control Panels menu) and set the display to 256 colors. (Versions of NIH Image 1.55 and later will work with other monitor settings, but the appearance of the images may differ from those described here, and the performance of NIH Image may be degraded.

In the Finder, click once on the NIH Image icon and use the File - Get Info command to set the preferred size to 4000K. Leave NIH Image in a folder that also contains the macros folder and plug-ins folder. Make an alias of NIH Image and move it to either the Apple Menu items folder (in the System folder) or the desktop. To start up, do one of the following actions to either the NIH Image icon or its alias: double click it, select it in the Apple Menu, drag and drop one or more selected images onto it, or double click on an image that is an NIH Image document, such as TEM Filter Sample.tiff (Steel, 1993) image discussed below. Which application (such as NIH Image) 'owns' the file can be displayed by going to the finder, selecting the file by clicking on it, and using the File - Get Info command or pressing the command-I keys.

In the event of the error message that there was not enough room for various buffers, use the Options - Preferences command in NIH Image to set the Undo and Clipboard buffers to 300K. (The Clipboard and Undo buffers don't need to be larger than the largest example image. You may have obtained a preferences file along with NIH Image, which might have preferences different from those recommended for these examples. ) Also make sure that the Invert Pixel Values box is checked so that black = 0 and white = 255. Save the preferences using File - Record Preferences , Quit and restart NIH Image.

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.

Open the image file TEM Filter Sample.tiff by using File - Open , by dragging and dropping the file onto NIH Image's icon or by double clicking on the file. The image is a transmission electron micrograph of a particulate sample deposited on a polycarbonate filter.


Figure 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.
Note that the image is displayed in its own window with the name of the file in the title bar. The LUT (color Look Up Table), Tools, Map and Info (not shown in figure) windows are also displayed. (Fig. 1) When the cursor is run over the image window, the coordinates and pixel value for the cursor position are displayed in the Info window. The LUT window displays the current gray level or color look-up table. Move the cursor over the LUT window and observe that the pixel values are displayed in the Info window (255 or black at the bottom, and 0 or white at the top as the default, or 0 or black at the bottom and 255 or white at the top with the pixel values inverted - see above).

Click on the zoom tool - the magnifying glass at the upper left of the Tools window. The cursor will change to a magnifying glass. Move this cursor to a particle of interest and click on it once. The particle should be magnified by a factor of two, and centered in the window. At this point, if your screen is large enough, the image window can be expanded by dragging the grow icon in the lower right corner of the window. Clicking and holding on the hand in the Tools window allows panning of the image (with the hand cursor) by dragging any part of the image in the direction you wish it to go. The image can be zoomed as much as desired with more clicks on the magnifying glass tool, until a single pixel fills the window. Note that the zoom factor appears to the right of the file name in the title bar. A 3:1 zoom will make the individual pixels visible as small squares.

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.

[Index] [Next]