Tech Tip: Creating a Volume From a Series of Images
It's often useful to be able to collate a set of images into a volume. For example, the images could be slices from an MRI scan through a 3D object, and there is a need to reconstruct the object in 3D space.
The simplest method is to use WriteAnimation. It writes incoming 2D lattices into a single 3D image in FIT format. The FIT file can then be read in by ReadImg, which outputs the data as a 3D lattice. Alternatively, if the images are already on disk as .rgb files, use the ReadImages module, which reads in a series of these files and composes them into a 3D lattice.
If you already have the component lattices in IRIS Explorer and simply want a module that stacks them, you must write a new module. Although you could use the module builder, it's easier to use the LatFunction module, which enables simple creation and manipulation of lattices via a script written in the Shape language. The script is passed to the module and interpreted by it, which bypasses the traditional edit-compile-link cycle, leading to more rapid development. Here is a script that takes two lattices and stacks them together to create a new lattice with a dimensionality which is one greater than that of either of the input lattices.
foo := scalar_lattice_in(First_In)
bar := scalar_lattice_in(Second_In)
baz := outside([foo, bar])
First_Out := scalar_lattice_out(baz)
The input lattices must be the same size otherwise LatFunction will complain with a - somewhat obscure - error message. The lattices are stacked in the slowest varying dimension - e.g., if both the input lattices have dimensions of 8 by 8, then the output lattice will have dimensions of 2 by 8 by 8. The stacking direction can be switched to the fastest varying dimension using the inside command - i.e., to get a lattice that's 8 by 8 by 2, change the third line to
baz := inside([foo, bar])
See Chapter 10 of the Module Writer's Guide for more information on the LatFunction module and the Shape language.
Learn more about IRIS Explorer at www.nag.co.uk/ie.
For specific technical advice in using NAG's products, please contact our technical experts.
Return to Technical Tips & Hints index page.