Build3DAssemble

Synopsis

Reads a image file, and places this data into a specified slice of a uniform vector field. ARGB data is stored as vector node data.


macro Build3DAssemble {
   ilink filename;
   ilink index;
   Build3DImageParams &ImageParams<export=1,NEportLevels={2,1}>;
   Build3DMakeDims Build3DMakeDims {
      &ImageParams => <-.ImageParams;
   };
   DVM.DVread_image DVread_image {
      filename => <-.filename;
      flip = 0;
   };
   IAC_PROJ.Build3D.Build3DMods.Build3DExtractScalar extract_scalar {
      in_field => <-.DVread_image.out;
      component => <-.ImageParams.component;
   };
   int+OPort  in_data_dims[2] => {4,
      (Build3DMakeDims.dims[0] * Build3DMakeDims.dims[1] * Build3DMakeDims.dims[2])};
   char+OPort in_data<export=1>[in_data_dims[1]][in_data_dims[0]];
   FLD_MAP.uniform_vector_field uniform_vector_field {
      mesh {
         in_dims => <-.<-.Build3DMakeDims.dims;
      };
      data {
         in_data => <-.<-.in_data;
         dims+IPort3 => <-.<-.in_data_dims;
      };
   };
   DVM.DVset_slice_data DVset_slice_data {
      inField => <-.uniform_vector_field.out;
      sliceField => <-.DVread_image.out;
      slice => <-.index;
   };
   olink out => .DVset_slice_data.inField;
};

Description

The Build3D project consists of a set of macros that build up a 3D model from a set of 2D slices or layers. The 2D layers can be represented by any of the image file formats that AVS/Express supports. The purpose of the Build3DAssemble macro is to perform the low-level task of reading in a single image file and placing that data into the appropriate slice within a uniform vector field. It should be noted that due to the use of a uniform mesh, best results will be obtained when all slices are evenly spaced. This is a limitation of the current macro. In the future it maybe possible to use a rectlinear mesh and thereby allow unevenly spaced layers.

Inputs

&filename

Reference to a string containing the path and filename of the layer to be loaded.

&index

Reference to an integer specifying the slice of the 3D uniform scalar field that the image file should be read into. To build a complete set of data the index and filename should be changed together so that each image file is read into the appropriate position in the field data. The index number is used to directly index the data array and therefore it should be in the range 0 to the (number of layers - 1), and not in the range start_layer to end_layer. Typically this will require an adjustment to be performed on the loop counter in the calling macro.

&ImageParams

Reference to the parameter block, which contains real instances of the parameters for the Build3DAssemble macro.

resx

The horizontal resolution of the image file. The parameter is of type int. This has to be the same for each layer of the 3D volume. To increase performance the resolution of each file is not determined, instead it is assumed that the supplied value is correct. The actual resolution can be extracted from a single image at a higher level. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ImageParams input.

resy

The vertical resolution of the image file. The parameter is of type int. The resolution has to be the same for each layer of the 3D volume. To increase performance the resolution of each file is not determined, instead it is assumed that the supplied value is correct. The actual resolution can be extracted from a single image at a higher level. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ImageParams input.

start_layer

The index number of the first layer that the 3D model should be built up from. The parameter is of type int. The indices of the start and end layers are required so that the storage array for the resulting node data can be completely specified. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ImageParams input.

end_layer

The index number of the last layer that the 3D model should be built up from. The parameter is of type int. The indices of the start and end layers are required so that the storage array for the resulting node data can be completely specified. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ImageParams input.

component

The colour component that should be extracted from the image data and placed in the 3D model. This parameter is not used by the Build3DAssemble macro. Instead the macro outputs vector data containing the alpha, red, blue and green components. The specified component is extracted later. This method enables the colour component to be changed without forcing all the image data to be reread. Normally the value of this parameter is found by referring to the parameter block, which is referenced by the &ImageParams input.

Outputs

out

The generated 3D block in the form of a uniform vector field with the dimensions specified in the parameter block (i.e. [resx][resy][layers]). The image data for the present layer is stored as a 4 byte vector of node data at each point within the current horizontal layer. The field data will also contain any other image layers that have been previously read. Therefore as each layer is read the field data will change and updates will ripple through the network. If the visualization being performed is lengthy then this is likely to be undesirable and the network should be disconnected while images are being read in. A method of performing this is shown in the Build3DFunc functional macro.

Utility Macros

The low-level Build3DAssemble module is used in the Functional Macro Build3DFunc which is in turn used in the User Macro build3D. Additionally, this macro also uses the Build3dImageParams parameter block group object, as does the Build3DUI UI Macro.

Example

Two example applications are provided. The Build3DEg application loads four BMP files that are 4x4 pixels in size, builds a 3D volume from these and displays the volume using an isosurface and a bounding box.

The CreateImageSlicesEg application uses an orthoslice module, a 2D viewer and a write_image module to create TIFF images that represent slices from a volume field. These slices can later be rebuilt into a volume by the build3D macro. This application is unlikely to have any practical usage. Instead it is intended to generate images that build3D can be tested with.

Files

iac_proj/build3d/bl3dmods.v contains the Build3DImageParams group and the Build3DMakeDims, Build3DExtractScalar and Build3DAssemble module V definitions.

iac_proj/build3d/bl3dmacs.v contains the build3D User Macro, the Build3DFunc Functional Macro and the Build3DUI UI Macro.

iac_proj/build3d/bl3dapps.v contains the Build3DEg and CreateImageSlicesEg example application V definitions.

Prerequisites

This project relies on the successful installation of the following components. Without them it will not function correctly.

Other Notes

The low-level Build3DMods library inherits its process. As this library contains no procedural code, the process is not important.

Authors

Steve Larkin

Modifications

Jimmy Schumm
Paul G. Lever
Andrew Dodd

Contact

International AVS Centre
Manchester Visualization Centre
Manchester Computing
University of Manchester
Oxford Road
Manchester
United Kingdom
M13 9PL

See Also