Evaluate a volume image at embedded gauss point locations and write the values.
#Example image_sampling.com: Evaluate a volume image at embedded gauss point locations and write the values. $FileFormat="jpg" $PATH="$example" $CTPath="$PATH/ScannedCTSlices/$FileFormat" $OutputPath="." #================= Read texture mesh ================== # # Read in block geometry used to contain the volume texture read below gfx read nodes $PATH/texture_block.exnode; gfx read elements $PATH/texture_block.exelem; gfx read nodes $PATH/iso_block.exnode; gfx read elements $PATH/iso_block.exelem; gfx define field x component coordinates.x; gfx define field y component coordinates.y; gfx define field z component coordinates.z; #================= Read texture ================== # # Read in a scanned volume and create some fields that reference the volume data. # gfx create texture mandible width 170 height 170 depth 58 image $CTPath/Mandible0000.$FileFormat number_pattern "0000" number_series 0002 0118 1 compress; # Align the texture to the first repetition (from 0-width, 0-height, 0-depth) and compensate # for the fact that the depth is no longer expanded out to a power of two. gfx define field offset_coordinates offset field coordinates offsets 0 -170 126.90598; gfx define field tex sample_texture coordinates offset_coordinates field mandible; # Define a grayscale spectrum useful for displaying the texture values. gfx create spectrum grayscale clear overwrite_colour; gfx modify spectrum grayscale linear range 0 1 extend_above extend_below red colour_range 0 1 ambi diffuse component 1; gfx modify spectrum grayscale linear range 0 1 extend_above extend_below green colour_range 0 1 ambi diffuse component 1; gfx modify spectrum grayscale linear range 0 1 extend_above extend_below blue colour_range 0 1 ambi diffuse component 1; #================= Read in geometry ================== # # Read in the element geometry represent the jaw and in which the embedded points # at which we want to evaluate the texture field will be located. gfx read nodes $PATH/FinalMandibleGeometry2.exnode; gfx read elements $PATH/FinalMandibleGeometry.exelem; #================= Define graphics ===================== # Create materials gfx create material bone ambient 0.7 0.7 0.3 diffuse 0.9 0.9 0.8 emission 0 0 0 specular 0.05 0.05 0.05 alpha 1 shininess 0.1; gfx create material green ambient 0 1 0 diffuse 0 1 0 gfx create material mandible ambient 1 1 1 diffuse 1 1 1 emission 0 0 0 specular 0 0 0 alpha 0.65 shininess 0 texture mandible; # Clear out the default graphics in the texture_block gfx modify g_element texture_block general clear; # Clear out the default graphics in the iso_block and set the resolution we want for the iso_surface display gfx define tessellation fine16 minimum_divisions "16" refinement_factors "1"; gfx modify g_element iso_block general clear; # Draw an iso_surface of this field gfx modify g_element iso_block iso_surfaces coordinate coordinates tessellation fine16 iso_scalar tex iso_value 0.35 use_elements select_on material bone texture_coordinates coordinates selected_material default_selected render_shaded; #================= Open graphics window ===================== # # The graphics window is not required to calculate the texture values and the example will # run much faster as the volume will not need to be loaded and compressed in the graphics card # and the iso_surface will not be displayed and therefore not calculated. # if (! $TESTING) { gfx create window 1 double_buffer; gfx modify window 1 image scene default light_model default; gfx modify window 1 image add_light default; gfx modify window 1 layout simple ortho_axes z -y eye_spacing 0.25 width 664 height 664; gfx modify window 1 set current_pane 1; gfx modify window 1 background colour 0.5 0.5 0.5 texture none; gfx modify window 1 view perspective eye_point 147.392 688.357 150.456 interest_point 77.385 253.245 -107.58 up_vector -0.00310034 -0.509712 0.860339 view_angle 31.6892 near_clipping_plane 5.10692 far_clipping_plane 1825.04 relative_viewport ndc_placement -1 1 2 2 viewport_coordinates 0 0 1 1; gfx modify window 1 set transform_tool current_pane 1 std_view_angle 40 normal_lines no_antialias slow_transparency blend_normal; } #================= Read embedded gauss point locations ===================== # # The locations at which we want to sample the image field are gauss points, embedded within the # mandible mesh, specified as locations at Element:Xi locations within that mesh. # gfx read data $PATH/GaussPointsFittedMandible.exdata; # To view the data points, create an 'embedded' field returning the coordinates field # from the host mesh evaluated at the element_xi location read in from the data points: gfx define field element_xi_coordinate embedded element_xi element_xi field coordinates; gfx modify g_element GaussPointsMandible general clear; gfx modify g_element GaussPointsMandible data_points coordinate element_xi_coordinate glyph sphere general size "1*1*1" centre 0,0,0 select_on material default selected_material default_selected; #================= Display tex_mag on datapoints ===================== # # To define the texture field on these embedded fields we need to define a field that connects the Element:Xi field with # the texture sampling field. The "tex_mag" field is the one we want to sample and the "element_xi" field is the embedded # position we want to use. (The "element_xi_coordinate" coordinate field is automatically generated for these datapoints # but any other embedding fields need to be created manually). gfx define field element_xi_tex embedded field tex element_xi element_xi; # This embedded field can now be displayed on the data points gfx modify g_element GaussPointsMandible data_points coordinate element_xi_coordinate glyph sphere general size "1*1*1" centre 0,0,0 select_on material default selected_material default_selected data element_xi_tex spectrum grayscale; #================= Evaluate tex_mag at datapoints ===================== # # To write out the values at the datapoints we need to explicitly evaluate the # tex_mag field into storage locations in the data points. # Define a field that can store the grayscale value we want gfx define field tex_values finite_element number_of_components 1 real coordinate component_names value; # Define this field on each of the data points, the initial value will be zero. gfx modify data group GaussPointsMandible define tex_values; # Evaluate the element_xi_tex_mag field at each data point into this storage. gfx evaluate dgroup GaussPointsMandible source element_xi_tex destination tex_values; # Write out these values. gfx write data group GaussPointsMandible field tex_values "$OutputPath/tex_mag_values.exdata"; # Additionally more fields could be evaluated and written out, such as the coordinate field or # maybe the tex with some image processing applied as shown in many of the examples in this directory.
Name Modified Size
image_sampling.com 20-Apr-2012 6.8k COPYRIGHT 19-Apr-2012 504 FinalMandibleGeometry.exelem 20-Apr-2012 576k FinalMandibleGeometry2.exnode 20-Apr-2012 320k GaussPointsFittedMandible.exdata 20-Apr-2012 1.1M ScannedCTSlices/ 19-Apr-2012 - iso_block.exelem 20-Apr-2012 1.6M iso_block.exnode 20-Apr-2012 264k texture_block.exelem 20-Apr-2012 3.6k texture_block.exnode 20-Apr-2012 1.0k
Name Modified Size
examples_a_backup_image_sampling.tar.gz 12-Aug-2014 5.5M
Status | Tested | Real time (s) | |
i686-linux | |||
cmgui-wx | Success | Sun Mar 6 00:16:34 2016 | 4 |
cmgui-wx-debug | Success | Sun Mar 6 00:15:36 2016 | 4 |
cmgui-wx-debug-memorycheck | Success | Sun Mar 6 00:21:04 2016 | 6 |
cmgui-wx-debug-valgrind | Success | Sun Mar 6 01:31:56 2016 | 119 |
x86_64-linux | |||
cmgui-wx | Success | Thu Jan 7 00:01:42 2016 | 3 |
cmgui-wx-debug | Success | Thu Jan 7 00:01:42 2016 | 2 |
cmgui-wx-debug-memorycheck | Success | Thu Jan 7 00:01:54 2016 | 4 |
cmgui-wx-debug-valgrind | Failure | Sun Mar 6 00:09:20 2016 | 121 |
last break | Sun Mar 6 00:07:00 2016 | 121 | |
last success | Wed Jun 3 00:57:00 2015 | 110 | |
cmgui-wx-gcc-cad-debug-valgrind | Success | Thu Jan 7 00:08:59 2016 | 92 |
i686-linux | |||
Success | cmgui-wx: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug-valgrind: | diff test: no differences with generic answer. | |
x86_64-linux | |||
Success | cmgui-wx: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug: | diff test: no differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | diff test: no differences with generic answer. | |
Failure | cmgui-wx-debug-valgrind: | diff test: differences with generic answer; Test output. |
i686-linux | |||
Success | cmgui-wx: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-valgrind: | ndiff test: no significant differences with generic answer. | |
x86_64-linux | |||
Success | cmgui-wx: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-memorycheck: | ndiff test: no significant differences with generic answer. | |
Success | cmgui-wx-debug-valgrind: | ndiff test: no significant differences with generic answer. |
Html last generated: Sun Mar 6 05:50:58 2016
Input last modified: Fri Apr 20 15:59:42 2012