This example shows how to produce images for a sequence of planes through a 3D volume texture. Each plane image corresponds to the values of the volume texture on the surface of that plane. The slices through the volume texture can be used as input data for the digitisor.
The exnode and exelem plane files used to specify the position of the slice are created using a perl script CreateSlices.pl This script generates a sequence of node and element files corresponding to orthogonal planes centered on the nodes of a curve file given as an argument to the CreatesSlices script as shown below.
perl CreateSlices.pl curve.exnode
The load_slices.com file loads up the generated slices with the associated curve nodes to check whether generation has produced the desired plane positions.
Created by Peter Bier, October 2002.
# Project volume texture onto a set of planes and write out each projected # image to a file. # Author: Peter Bier # set number of planes to read in $max_plane_number=10; # directory containing scanned image files, in this case dicom format $image_dir="$example/images"; # directory containing exnode and exelem files for the block to contain the # texture, includes texture files specifing texture coordinates $block_dir="$example/block"; # directory containing exnode and exelem files for each plane $slice_dir="$example/slices"; # directory images will be written to $output_dir="$example/slices"; # read in a block to view the texture in gfx read nodes $block_dir/tex_block.exnode gfx read elements $block_dir/tex_block.exelem # define the texture coordinates which vary from 0 to 1 along the axes gfx read nodes $block_dir/tex_coords.exnode gfx read elements $block_dir/tex_coords.exelem # read in mri data and create a volume texture gfx create texture original_tract image dcm:$image_dir/IMAGE_5_000.ima number_pattern 000 number_series 327 342 1 width 1 height 1 depth 1 distortion 0 0 0 colour 0 0 0 alpha 0 decal linear_filter resize_nearest_filter clamp_wrap; # use linear interpolation gfx modify texture original_tract linear # create a sample field for tract gfx define field tex sample_texture coordinates xi field original_tract; # rescale the intensity in the sample_texture field gfx define field rescaled_tex rescale_intensity_filter field tex output_min 0 output_max 1; gfx cre spectrum monochrome clear; gfx modify spectrum monochrome linear range 0 1 extend_above extend_below monochrome colour_range 0 1 ambient diffuse component 1; #create a texture using the rescaled sample_texture field gfx create texture tract linear; gfx modify texture tract width 1 height 1 depth 1 distortion 0 0 0 colour 0 0 0 alpha 0 decal linear_filter resize_nearest_filter clamp_wrap specify_number_of_bytes 2 evaluate field rescaled_tex element_group texture_block spectrum monochrome texture_coordinate xi fail_material transparent_gray50; # create a material containing the texture so that we can select along # with appropriate texture coordinates to visualise the 3D image gfx create material tract texture tract # create some useful materials to colour parts of our picture gfx create material purple ambient 0 0 0 diffuse 0.55 0.35 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.5 gfx cre mat bluey ambient 0 0.25 0.5 diffuse 0 0.4 1 emission 0 0 0 specular 0.5 0.5 0.5 alpha 1 shininess 0.3 # Define the components of the coordinate field as individual scalar # fields for defining slice planes gfx define field x component coordinates.x; gfx define field y component coordinates.y; gfx define field z component coordinates.z; # Draw the 3-D texture on the surface z = 0 gfx modify g_element "/" general clear; gfx modify g_element texture_block lines coordinate coordinates material default; gfx modify g_element texture_block iso_surfaces coordinate coordinates iso_scalar z iso_value 0 use_elements select_on material tract texture_coordinates tex_coords selected_material default_selected render_shaded; # Create a 3d window gfx create window 1 gfx mod win 1 view perspective gfx mod win 1 image view_all # create an gray_spectrum spectrum gfx cre spectrum gray_spectrum clear; gfx modify spectrum gray_spectrum linear range 0 1 extend_above extend_below red colour_range 0 1 ambient diffuse component 1 gfx modify spectrum gray_spectrum linear range 0 1 extend_above extend_below green colour_range 0 1 ambient diffuse component 1 gfx modify spectrum gray_spectrum linear range 0 1 extend_above extend_below blue colour_range 0 1 ambient diffuse component 1 # create a texture coordinate field which can be evaluated using only # coordinates. We need this otherwise we run into problems when creating # a sample texture for our plane as the plane only knows about the # coordinates field, it has no access to the tex_coords field gfx define field lookup_tex_coords compose texture_coordinates coordinates group texture_block element_dimension 3 find_element_xi coordinates calculate_values_field tex_coords; # create a sample texture field which we can use to evaluate the texture # values for each plane gfx define field colour_slice sample_texture field tract coordinates lookup_tex_coords; # cycle through each plane, project volume texture onto plane and write # the image to a file $plane_number=1; sub run { while ($plane_number <= $max_plane_number) { # load in a plane to project onto $plane_name = sprintf("plane%03d", $plane_number); gfx read node $slice_dir."/".$plane_name.".exnode"; gfx read elem $slice_dir."/".$plane_name.".exelem"; # create a texture for each plane which will be used each time to evaluate # the colour_slice field. This is an unnecessary waste of textures, as we could # otherwise just reuse the same texture over and over but doing it this way # means we end up with all the textures showing in the slices in the correct places. # Alternatively just make a single texture and set the $texture_name to point at it. $texture_name = sprintf("plane_texture%03d", $plane_number); gfx create texture $texture_name width 1 height 1 clamp_wrap decal; gfx modify texture $texture_name linear; gfx create material $texture_name texture $texture_name; # link up the plane just loaded to the material for this plane gfx modify g_element $plane_name surfaces material $texture_name texture_coord xi; # evaluate the texture field colour_slice over the surface of the plane #We don't want the source fields depth so we specify_depth 1 gfx modify texture $texture_name specify_width 256 specify_height 256 specify_depth 1 specify_format i evaluate element_group $plane_name element_dimension 2 field colour_slice spectrum gray_spectrum texture_coordinates xi; # write out the image as a png file gfx write texture $texture_name file $output_dir."/".$plane_name.".png" print "Processed plane $plane_number\n"; $plane_number++; } } if ($TESTING) { # only test one plane $max_plane_number=1; # write output to current directory $output_dir="."; run; #Check it read in properly and is 16bit = 2 bytes per component gfx list texture field tract; # list the generated gfx list texture field plane_texture001; } # Type run to begin projecting the volume texture onto the slices # note this takes several minutes to execute on an O2 # Using hpc2 will reduce execution time to a few seconds
Name Modified Size
create_slices.com 17-Mar-2014 6.4k COPYRIGHT 17-Mar-2014 504 CreateSlices.pl 17-Mar-2014 10k block/ 18-Mar-2014 - curve.exnode 17-Mar-2014 1.2k images/ 18-Mar-2014 - load_slices.com 17-Mar-2014 1.1k slices/ 18-Mar-2014 -
Name Modified Size
examples_a_create_slices.tar.gz 09-Mar-2016 2.9M
Status | Tested | Real time (s) | |
i686-linux | |||
cmgui-wx | Failure | Sun Mar 6 00:18:36 2016 | 4 |
last break | Tue Feb 24 03:21:00 2015 | 4 | |
cmgui-wx-debug | Failure | Sun Mar 6 00:19:31 2016 | 5 |
last break | Tue Feb 24 03:22:00 2015 | 5 | |
cmgui-wx-debug-memorycheck | Failure | Sun Mar 6 00:21:19 2016 | 7 |
last break | Tue Feb 24 03:24:00 2015 | 6 | |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 01:47:49 2016 | 203 |
last break | Sun Mar 6 01:44:00 2016 | 203 | |
x86_64-linux | |||
cmgui-wx | Failure | Sun Mar 6 00:01:30 2016 | 1 |
last break | Sun Mar 6 00:01:00 2016 | 1 | |
cmgui-wx-debug | Failure | Sun Mar 6 00:01:30 2016 | 1 |
last break | Sun Mar 6 00:01:00 2016 | 1 | |
cmgui-wx-debug-memorycheck | Failure | Sun Mar 6 00:01:29 2016 | 0 |
last break | Sun Mar 6 00:01:00 2016 | 0 | |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 00:02:25 2016 | 9 |
last break | Sun Mar 6 00:02:00 2016 | 9 | |
cmgui-wx-gcc-cad-debug-valgrind | Success | Thu Jan 7 00:02:26 2016 | 7 |
x86_64-linux | |||
139 | cmgui-wx: | error exit status 139. | |
139 | cmgui-wx-debug: | error exit status 139. | |
139 | cmgui-wx-debug-memorycheck: | error exit status 139. | |
139 | cmgui-wx-debug-valgrind: | error exit status 139. |
i686-linux | |||
Failure | cmgui-wx: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-memorycheck: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with generic answer; Test output. | |
x86_64-linux | |||
Failure | cmgui-wx: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-memorycheck: | diff test: differences with generic answer; Test output. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with generic answer; Test output. |
i686-linux | |||
Success | cmgui-wx: | idiff test: Test output; generic answer. | |
Success | cmgui-wx-debug: | idiff test: Test output; generic answer. | |
Success | cmgui-wx-debug-memorycheck: | idiff test: Test output; generic answer. | |
Success | cmgui-wx-debug-valgrind: | idiff test: Test output; generic answer. | |
x86_64-linux | |||
Missing | cmgui-wx: | output file not generated for idiff; generic answer. | |
Missing | cmgui-wx-debug: | output file not generated for idiff; generic answer. | |
Missing | cmgui-wx-debug-memorycheck: | output file not generated for idiff; generic answer. | |
Missing | cmgui-wx-debug-valgrind: | output file not generated for idiff; generic answer. |
Html last generated: Wed Mar 9 16:01:33 2016
Input last modified: Wed Mar 9 15:49:38 2016