next up previous contents index
Next: Reading unusual image files Up: Open image Previous: Opening images   Contents   Index


Reading CT, X-ray, or MRI images, or raw bytes

Below is a detailed example for reading images produced by X-ray, CT or nuclear magnetic resonance scanners and other equipment. These machines typically use unusual file formats not recognized by tnimage, but usually the images can easily be read as ``raw bytes''.

The same procedure is applicable to any non-compressed file of unknown type.

NOTE: Tnimage can create a ``custom'' image file format, which is a superior method for reading medical image files, because once the custom format is set up, reading the image is transparent to the user, obviating the necessity for reading ``raw bytes'' as described here (See ``Create File Format'').

(1) Select ``File...Open image'' and enter the image file name.

(2) Click on ``Raw bytes''.

(3) Click on ``OK''.

(4) Tnimage will make a guess at the image width. If the image width is known, enter the image width and height. Otherwise, if the guess turns out to be wrong, use the auto-increment method described below to determine the width. In this case, the width happens to be 381.

(5) Select the bits/pixel of the image. This is usually 12 or 16 for CT images (MAMOGRAM.LUM is 16 bits).

(6) (Optional): If the length of the image file header is known, enter this value under ``skip bytes''. Otherwise, leave it as 0.

(7) Click on ``OK'' to open the image.

(8) Once the image is loaded, if the skip bytes were incorrect in step 6, the image border will be visible as a vertical strip in the image. Use the mouse to locate the X-position of this strip. Close the image and re-open it, using the X-position * bytes/pixel as an estimate for skip bytes.

(10) If the image was color, it may be necessary to add 1,2, or 3 additional skip bytes to get the colors to line up correctly.

(11) If the image is grayscale, the grayscale mapping can be adjusted by selecting ``Color...Grayscale map''. This the image to be adjusted interactively as a sliding scale, to highlight areas of different intensity (See ``Grayscale brightness'' below).

(12) The image can now be saved in a conventional file format.


Determining the width of an unknown image:

Tnimage has a unique feature for determining the width of an image whose dimensions are completely unknown. This procedure is substituted for step (4) above:

(4a) Make a conservative guess of the image width. For instance, if the image is known to be square, and it is 16 bits (2 bytes) per pixel, use

$\displaystyle width = \sqrt( file size / 2 ) $

as the starting estimate.

(4b) Click on ``Auto increment''. This will cause the width to be increased with each scan line.

(4c) For ``Increment'', enter ``1'' or ``2''.

(4d) Click on ``OK'' to load the image. The image should consist of a swirling pattern, with fuzzy lines in a horizontal ``U'' shape. Usually, the image is slightly clearer at the vertex (marked with a *). If so, find the Y-coordinate of the vertex using the mouse. Subtract 32 (the size of the menu bar) from this value and add the result to the previous estimate of the image width.

(4e) Unload the image.

(4f) Turn off ``Auto increment'' and load the image again. The image should now be recognizable. If the image slopes to the right (when viewed from top to bottom), the value is still too low. Increase the image width slightly and try again. If it slopes left, the value is too high.

If the image is still not recognizable after these steps, try changing the byte order, or check the ``Convert-gray scale'' option.

If the wrong number of bits/pixel or y size for a ``raw bytes'' image was selected, the automatic grayscale detection may estimate the maximum and minimum gray levels incorrectly. This will result in an image that is too dark or too light. This can be easily corrected by remapping the gray levels (See Grayscale intensity mapping ).


next up previous contents index
Next: Reading unusual image files Up: Open image Previous: Opening images   Contents   Index
root 2006-11-13