BonyParts

An Image Analysis Program


Notice: This is a very rough draft. New features are not described and removed features may still be listed. A complete manual will be produced when the program features stabilize.

John Brittnacher & Loo Botsford
Wildlife & Fisheries Biology
University of California, Davis
Davis, California 95616

Bony Parts version 4.0

Electronic mail
Internet: jgbrittnacher@ucdavis.edu
lwbotsford@ucdavis.edu

Acknowledgments

Plamondon, J. 1988. Pop-Up Menus CDEF. MacTutor 4(9):56-81.
Sheets, S. 1987. Color Image F-Key. MacTutor 3(12):.

This Program was written with MacAppreg.: (c) 1985 - 1988 Apple Computer, Inc.

APPLE COMPUTER, INC. MAKES NO WARRANTIES WHATSOEVER, EITHER EXPRESS OR IMPLIED, REGARDING THIS PRODUCT, INCLUDING WARRANTIES WITH RESPECT TO ITS MERCHANTABILITY OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.

The MacApp software is proprietary to Apple Computer, Inc. and is licensed to the University of California Regents for distribution only for use in combination with Bony Parts.

This research supported by a grant from the California Sea Grant College Program.


The BonyParts program is designed to be a special-purpose program for production reading of otoliths and other bony parts of fish on the Macintosh II, Centris, and Quadra computers. It will directly acquire images through a Data Translations DT2255 frame grabber board and read previously stored images from disk. The user is responsible for presenting the image to BonyParts and selecting the region to be analyzed. BonyParts then reads the image data, analyzes it, reports the number of bands counted, and marks the bands in color on the image. The program also displays the data in a graphical format that may be printed in color The user may request analysis output in various formats in a text file that is compatible with all Macintosh word processing and spreadsheet programs.

Hardware and Software Requirements

BonyParts requires the use of a Macintosh II, Centris, or Quadra. The Macintosh should have at least 4 megabytes of RAM and an 8-bit video display with color preferred. The operating system version should be 6.0.5 or higher.

To grab images from a video camera, the Macintosh must have a Data Translations DT2255 or DT2253 frame grabber installed. The machine should be started with the Data Translations QckCapInit version 1.04 or later in the System Folder (System 6) or Extensions folder in the System Folder (System 7). The program will not acquire new images from any other source although BonyParts will open and analyze any PICT or 8-bit-unformatted image created by other programs and stored on disk.

Images captured from a frame grabber are stored internally and saved to files using 256 shades of gray (8-bits). They are displayed with 250 shades of gray if the user wants color tick marks on bands or 256 shades of gray if the user wants black, white, or gray tick marks on bands.

Installing BonyParts

The BonyParts program may be reside on any disk on the Macintosh. Usually the program is placed on a hard disk by dragging the BonyParts icon from the distribution floppy to any convenient location on the hard disk. The program may be run from a floppy disk but the disk will need to remain in the drive most of the time.

The QckCapInit may be installed by dropping the file on a closed System Folder.

Starting BonyParts

To start BonyParts, double click on the BonyParts icon or click on the icon once and select Open in the File menu.

Your First Time...

With the video camera and video monitor on and connected to your frame grabber, find and focus an image you want to analyze on the video monitor. When you like what you see in the video monitor, press command-G (that is, press G while holding down the command- key) to tell BonyParts to grab the image. You may also use the menu by pressing the mouse button with the cursor on Image in the menu bar at the top of the screen and dragging down to Grab Frame in the pull-down menu. Your image should now appear in the main window labeled Image. Click on the Image window to make it the active window if you have not already done so.

To take an age reading, find a region with parallel bands. The idea is to click and drag the mouse across the region perpendicular to the bands; as you drag the mouse, BonyParts will draw a rectangle showing you the part of the image it will analyze.

Using the example above, press the mouse button outside the otolith and drag the mouse perpendicular to the bands. When you release the mouse button, Bony Part analyzes the area inside the rectangle and tells you how many bands it saw and where it where they were.

Practice a little to see how close to perpendicular to the bands you have to be for BonyParts to see the bands. The example above is a little off. Notice that the number of bands counted is displayed near where you first pressed the mouse button and each band is marked. The program might not count bands that fade out or merge in the region selected so you may need to use the BonyParts count as a first approximation.

BonyParts decides where the bands are by looking at the pixels inside the selection rectangle. The program assumes you dragged the selection perpendicular to the bands so it sums the intensities of the rows of pixels perpendicular to the selection. Below is an example of part of a scan.

These data are from an actual scan and the text file reports. The raw data column contains the sum of the intensities of the pixels in each row. The program filters this series using a convolution filter with parameter values you may specify. The default values are set for an expected interband distance of five to eight pixels. The filtered data column contains the output from the convolution filter. BonyParts then looks at the output from the filter using a threshold detector to determine where the dark bands are located. The band mark column contains the output from the band detector. The program then displays the number of bands seen above the start of the scan and puts a mark on the image where it saw each band.

That is essentially all BonyParts was originally designed to do. The program will do more now because features were added as needed by the users. It will do more in the future, but the basic purpose of the program continues to be to assist in aging fish from cross sections of their BonyParts.

Below is a list of features and specifications for the program. The features are broken into a section describing each window and its purpose followed by a section describing each command and its purpose. It is not expected that every user needs to read the catalog of features as many of them are supposed to be obvious while others are included in the program as special requests and are thus not generally useful.

Windows

BonyParts has six windows to assist in analyzing images. The primary window is the Image Window, which may have various names depending on what your are doing. The Image Window contains the image to be analyzed and it is the window in which you do most of the work. The Analysis Control Window allows you to modify the environment in the Image Window. The widows labeled Scan Data and Fourier Analysis are there to give you feedback on how BonyParts "sees" your data. The Text Editor window is available for accumulating and editing the data produced by scans. The Memory Window and Debug Window are present primarily for use by programmers but may supply some amusing information.

Image Window (has variable name, initially "No Picture"; "Image" after frame grab; the file name when displaying an image from a file.

Live Video Window

The Live Video window is a real-time view of the image available for grabbing. The window is updated continuously when it is the top or active window. When the window is not the top window, it is not updated so any image there will be erased by other widows or dialog boxes.

The purpose of the Live Video window is to position and adjust the subject under the camera while still viewing the last image analyzed. For instance, if a subject is too large to scan in one image, you may reposition the subject using the Live Video window while viewing the Image window containing the last frame grab. To do this conveniently will require careful adjustment of window size, viewed area, and placement on the screen.

This feature was not added to make an external monitor unnecessary but with a faster Macintosh the external monitor may not be required. A stock Macintosh II can not update the screen fast enough to make this window useful for fine focusing an image.

Scan Data Window

The Scan Data window is normally displayed in color if you have a color monitor and Force is checked in the Analysis Control window. The window may also be printed in color or black & white on an ImageWriter II printer.

In the example above, the upper line is the raw data. The raw data and the word "Raw" are displayed in red. The lower line is the output of the filter; it and the word "Filtered" are displayed in blue. The vertical lines are the locations of the detected bands; they and the words "Detected Bands = 10" are displayed in green. The scaled threshold is also given in the window in green lettering and by making the detected band lines wider as in the example to the right.

Fourier Analysis Window

BonyParts has the capability of performing a Fourier analysis with frequency domain filtering on scanned data. This feature is generally not useful and is not documented here.

Text Editor Window

BonyParts contains a built-in text editor. The editor has the usual Macintosh mouse and cursor support as well as cut, copy, and paste clipboard support. The major limitation of the editor is that the maximum file size is 32,700 bytes. Initially the Text Editor window is named Untitled-1 but this will change to a file name when you save the text to a file. The file produced from this window is an unformatted file of type TEXT that may be opened from any word processing or spread sheet program. The window may also be printed.

BonyParts will help make reports of the images analyzed by inserting text into the Text Editor window. The data are "tab formatted" in the usual Macintosh way. For more information, please see "Scan to Text Command", "Band Interval to Text Command", and "Analysis to Text Command" in the section on Menu Commands below.

Menu Commands

Image Menu

Load PICT File...

BonyParts can load any PICT file from disk. Normally, you want to load files of type PICT containing a bitmap image but the program will also "scan" drawings. (On the Macintosh there is no real connection between a file name and its type--the file type is set by the program that created the file. Also most applications hide or at least don't advertise file type information. You can assume that any file BonyParts allows you to select is of the correct file type.)

The current version of BonyParts does not create a bitmap of the PICT images read from disk so it must read the video memory to get scan data. If there is any feedback information such as ticks on the part of the image scanned, they will be considered data. Also the whole scan must be visible on the screen and BonyParts uses red intensity as the signal.

Save As PICT File.../Save Selection As PICT File...

Create a file of type PICT from the current image. Any feedback drawn by BonyParts over the image will not be saved. (Save Selection As PICT File... has not been implemented yet and will always be grayed in the menu.)

Load Image File...

Load an unformatted image file into BonyParts. BonyParts expects the file to contain a stream of 8-bit bytes where each byte corresponds to a pixel value. Since all files on the Macintosh are essentially streams of 8-bit bytes, BonyParts accepts files of any type.

Load Image File... allows you to select a file in the usual get file dialog box and then the following dialog box appears.

BonyParts tries to figure out the relevant information from the size of the file selected. If you know that any of the numbers suggested are incorrect, change them in the edit text boxes. If you are opening a series of files with the same numbers, check "Don't guess for me next time!" to preserve your set of values.

BonyParts creates a color bitmap PICT image from the data in the file and the color look-up-table (CLUT) selected in the Load Image File Options dialog box. It is recommended you use any of the first three CLUTs for serious analysis if you are going to save the image as a PICT file. BonyParts uses the red signal for analysis if there is no bitmap in memory. In the Rainbow CLUT, the red signal is zero for pixel values of 0 to 127.

Note: in all CLUTs, absolute black and white are reversed--a value of 0 maps to white and a value of 255 maps to black.

Save As Image File.../Save Selection As Image File...

These commands create an unformatted image file from the image displayed. If there is no selection, the command in the menu is Save As Image File... and the whole image will be saved; if there is a selection the command changes to Save Selection As Image File... and only the selection will be saved. When either of these commands is selected, the following dialog box will appear.

Information about the image or selection is placed in the text boxes of the dialog box. If you wish to save a different part of the image, enter the new values. Note that no information about the size or shape of the image or selection is stored in the file. The user must use a standard size, use a square selection, put size information in the file name, or otherwise keep track of the actual size. When BonyParts opens an unformatted image file, the program will "guess" the image is square if the image is not the number of bytes expected for a 640 X 480 image.

After the user clicks on Create File or presses enter, BonyParts asks for the name of the new file using the usual Macintosh dialog box. The request may be canceled an any point by clicking on the Cancel button.

Save Image as TEXT.../Save Selection As TEXT...

These commands are identical to Save As Image File.../Save Selection As Image File... except that a text file is created instead of an unformatted image file. An example file of a 10 by 10 selection would look like

where each number represents a pixel value or intensity, each column of numbers is separated by a tab and each line ends in a return. This tab-formatted file could be opened in any word processing or spreadsheet program for data analysis.

Grab Frame

Acquires an image from the Data Translations frame grabber. command-G is the keyboard shortcut.

Show Picture/Show Palette

Switches back and forth between the image and palette.

Scan Menu

Refilter Data

Refilters data using the current parameter values without taking a new scan. If AutoInterpretation is checked, the new analysis is drawn on the screen. This is useful if you wish to experiment with the convolution wave filter period and filter threshold.

Band Interval to Text

Inserts the interval between bands into the BonyParts text window; the keyboard shortcut is command-B. The data are inserted in tab-format so that the file is compatible with Macintosh spreadsheets. As an example, if you made one scan on a an image loaded from disk, pressed command-B, changed the calibration of the image window, pressed command-B again, saved the text file (Save or Save As... from the Edit menu), and then opened the file in a spreadsheet, you would see

after a little reformatting. The first time you press command-B or select Band Interval to Text, BonyParts inserts three lines into the text window, the first line identifies the chosen command, the second gives the column headings, and the third gives the data for the last scan. Each subsequent command adds only data. Note that you should expect (# Bands + 1) intervals with the first interval being the distance between the start of the scan and the first band. Most of the time you will probably want to ignore this datum and start any analysis in column 11 for as many columns listed in column 2.

Analysis to Text

Inserts the number of bands counted and parameter information into the BonyParts text window; the keyboard shortcut is command-A. The data are inserted in tab-format so that the file is compatible with Macintosh spreadsheets.

The first time you press command-A or select Analysis to Text, BonyParts inserts three lines into the text window, the first line identifies the chosen command, the second gives the column headings, and the third gives the data for the last scan. Each subsequent command adds only data.

Scan to Text

Inserts the data for the last scan into the BonyParts text window; the keyboard shortcut is command-T. The data are inserted in tab-format so that the file is compatible with Macintosh spreadsheets.

Interpretation to Picture

Draws tick marks and number of bands seen over image. The keyboard short-cut is command-I. The color used to draw the tick marks and number is selected in the Analysis Control window.

AutoInterpretation

When a check appears before the item in the menu, BonyParts will automatically do an Interpretation to Picture any time a scan is selected or there is a re-analysis of the data.

Window Menu

Image

Select the window containing the image. The item name in the menu changes with the name of the window and grays when this window is the top window.

Live Video

Select the Live Video window. The item name grays when this window is the top window.

Scan Data

Select the window containing the graph of the latest scan. The item name grays when this window is the top window or the window is hidden.

Fourier Analysis

Select the window containing the graph of the Fourier Analysis of the latest scan. The item name grays when this window is the top window or the window is hidden.

Untitled-1

Select the editable text window. The item name grays when this window is the top window.

Hide Live Video / Show Live Video

Makes the Live Video window invisible if visible and vise versa. The window is only updated when it is the active or top window.

Hide Scan Data / Show Scan Data

Makes the Scan Data window invisible if visible and vise versa. The window is not really closed and the information in it is not lost.

Hide Fourier Analysis / Show Fourier Analysis

Makes the Fourier Analysis window invisible if visible and vise versa. The window is not really closed and the information in it is not lost. However, the Fourier analysis NOT performed when the window is hidden. This is a feature as the analysis can take some time. (To entertain you while the analysis is being performed, the cursor changes into a turning Earth.)

Hide Text / Show Text

Makes the Fourier Analysis window invisible if visible and vise versa. The window is not really closed and the information in it is not lost.