Appendix A


This Appendix contains two examples. The first example illustrates how to develop your own program to convert external image data files into those of 3DVIEWNIX form. The second example illustrates how you may develop your own program that does a certain processing operation on data within the 3DVIEWNIX discipline.

A.1 Writing Programs to Convert External Image Data into Data in 3DVIEWNIX Form

The program illustrated here converts 3D image data handled by a package called SOFTVU developed some years ago in our group into an IM0 file of 3DVIEWNIX. The source code for this conversion program is in the directory PROCESS/SAMPLES/CONVERT of the 3DVIEWNIX system. The conversion is done in five steps.
  1. Read the SOFTVU header
  2. Read images from SOFTVU file
  3. Compute 3DVIEWNIX header
  4. Write 3DVIEWNIX header
  5. Write data in 3DVIEWNIX form
The SOFTVU header is in soft_hdr.h. Not all fields in this header are used for image data. You can ignore all fields that are not used. This program also assumes that slices are equally spaced. Neither SOFTVU nor 3DVIEWNIX makes this assumption although it is made in this program for simplicity.

The program reads in all slices once into the memory before writing it out. If memory is a problem the slices can be read and written out one at a time. It is assumed that the byte ordering of the data is the same as the machine the program is running on. And as such it is read using the fread call.

The computation of the 3DVIEWNIX header is done in the function "Initialize_Output_Header". The most important items that need to be filled are the "type 1" fields (see [12] for details on type specification).

The function used for writing 3DVIEWNIX headers is VWriteHeader. This function requires that the file pointer be read/writable. The format of the function call is as follows.

o

There are three library functions used in writing the data. They are VSeekData, VWriteData, VCloseData. VSeekData moves the file pointer relative to the end of the header. This is used to skip the header before writing(reading) the data. The format of the function is as follows.

o

VWriteData writes the data from the machine dependent format (which is the format in memory) into the 3DVIEWNIX convention, see [12] (big endian byte order). The format of the function is as follows.

o

VCloseData simply sets the size of the data segment according to the ACR-NEMA convention and closes the file.

o

A.2 Writing Processing Programs

The example included here does scene filtering using a 2D Gaussian operator. The source code (gaussian2D.c) for this program is available in PROCESS/PREPROCESS/SCENE_OPERATIONS/FILTER directory of the main 3DVIEWNIX system. This should help you in writing programs that do not interact with the 3DVIEWNIX user interface. In addition to the data writing function used above, you would need a few additional 3DVIEWNIX library calls that allow you to read the 3DVIEWNIX header and the data from the input file. The processing consists of five steps.
  1. Read the 3DVIEWNIX Header from the input file.
  2. Modify the header to accommodate the header changes after filtering and write out the header.
  3. Read one slice at a time from the input file.
  4. Apply the filter to the slice read.
  5. Write out the processed slice.
In Addition to the commands used above in Section A.1, you would need to use VReadHeader, VReadData calls.

o


User Manual Library Ref. Manual Tutorial