High Performance Computing 811
Download
Report
Transcript High Performance Computing 811
Computational Methods
in Physics
PHYS 3437
Dr Rob Thacker
Dept of Astronomy & Physics (MM-301C)
[email protected]
Today’s Lecture
Visualization
More on Opendx
3d visualization methods
Making movies
Isosurfaces
Volume rendering
makempeg script & the Berkeley mpeg encoder
References:
Some overheads borrowed from a presentations by Tamara
Munzner, Gordon Kindlmann
Getting started with Opendx
Using Import Data is perhaps
the simplest way to get started
with Opendx
Selecting it will take you to the
Data Prompter
Data Prompter
The data prompter will
create a .general file
which the import module
can read
We’ll look at importing
gridded data
Will take many different
types
Let’s look at the simplest –
a regular grid
Using an engineering example in this case
Datafile description
Once the data is described, use “save as” in the
File menu to save the general description used by dx
Simplest tool
Default viz option will allow
you to see the data
immediately
Ensure everything loaded in OK
Note on Windows version
The windows version has problems with spaces in file names
Don’t save files with names such as
Helpful to set up an Opendx directory right at the top of the
directory tree
C:\Programs and something\myfiles\and so on\
e.g. C:\Opendx
Also, the default viewer in the data prompter did not work for
me
But could just be my laptop running out of memory
One of the drawbacks of Opendx is that it rapidly consumes memory
A workstation dedicated to visualization usually needs ~2 GB or more of
memory
Will exploit multiple processors though – good news!
Everything else seems fine though, the VPE works without a problem
Checking data
You can test that your loaded data is correct in a
couple of ways
Try the test import button
Will give information about range and so forth
Examine the data directly with the browse data
button
Lastly, go directly to the visualization system
described on the previous page
Unfortunately, if something is wrong it won’t tell you
much quantitative information about the problem
Creating a program
The default visualization system
is useful, but most of the time
we’ll want to create our own
programs
When we used the data
prompter we saved a description
of the file called fan.64_ascii
in fan.general
We can load this into our own
program
The next few overheads walk
through a simple 3d
visualization
Creating the visualization program
Open the program editor and expand the ALL listing
of modules, place fileselector, import, isosurface, image
Link by left clicking
on tab and then
drawing a line to
the other box
Now double
click on fileselector
Fileselector
This will bring up a control panel into which you can type the
name of the .general file saved when using the data prompter
Executing the program
Select Execute Once
from the execute menu
Image output
Running the
program will
produce an
isosurface
output
Interacting with the image
Under
options
select the
view
control:
Select rotate under mode
Rotate the image
Click and drag
on the image
with the mouse
to rotate
It isn’t that
fast though
Note the globe
is turned on by
selecting it in
the options
menu
Algorithms for 3d visualization
A bit of background to the algorithms used in
3d visualization will explain why it is such a
computationally expensive process
Look briefly at
Isosurface rendering
Playing with it in Opendx using the isosurface module
Volume rendering methods
Volume rendering is part of the Image module
Voxel data
The analogy of a pixel in 2d is the voxel in 3d
Field values are described at the vertices rather than in
the center
Field values along the edges and internally can be
derived by a number of interpolation functions
Isosurface Extraction
Which choose a fixed iso- 0
value
Then need to extract out 1
the contour (surface in
3d) corresponding to this 3
value
2
The marching cubes
algorithm is the most
1
common method
Patent has recently expired
on this algorithm
1
1
3
2
3
6
6
3
7
9
7
3
7
8
6
2
2
3
4
3
Iso-value = 5
First step of Marching cubes
Classify the voxel by the values at the vertices
Each vertex is either
- outside the surface (> isovalue)
- inside the surface (<= isovalue)
10
10
5
Iso=9
5
10
8
8
8
Iso=7
=inside
=outside
Marching Cubes: Triangle Example
c
a
b
Example Triangle configurations
These 15 base examples can be used to derive the 28=256 total configurations
Surface vs volume rendering
compared
Surface Rendering
2d surfaces are rendered within a
3d space & object appears “solid”
Data must be converted into
geometrical primitives such as
triangles for rendering
Volume Rendering
This process may lead to
information being lost or
disguised
Makes sense for objects with a
solid surface
Entire volume can be rendered
providing interior information
Spatial data is mapped to a volume
of RGBA values using a transfer
function
data is not explicitly hidden
This volume is rendered directly
using a variety of techniques
Makes sense for objects with
complex interior structure and no
solid boundaries
Improving on the earlier visual program
Add these new
modules
Set the opacity of
the 1st color module
to 0.3, for the second
0.7
New image is a combination of a
surface and a volume rendering
Surface has
a reduced
opacity so
we can see
through it
Interior
volume is
shown using
different
colours for
different
field values
Volume render alone
Volume Rendering Pipeline
Data volumes are used as input to the transfer function,
which produces a sample volume of colors and
opacities as output
Sample volume is rendered to produce a final image
FRGBA(data)
data
volume(s)
transfer
function
sample
volume
rendering
final
image
Transfer Functions (TF’s)
a
RGB
Map data value to color and opacity
f
RGB(f)
a(f)
Shading,
Compositing…
Human Tooth CT
Gordon Kindlmann
Choosing transfer functions
This is one of the black arts of visualization
Need to know fundamental scales of variation in your
problem (linear? Logarithmic?)
Opacity can’t be too high otherwise we can’t see
through
If it’s too low we don’t perceive enough information
Colours should be chosen in sympathy with the data
Volume rendering generally doesn’t cope well with too
much high frequency data
Examples
Linear increase places too much
weight on mid range
a
a
f
f
Sharply peaked to high opacity
effectively gives a surface render
a
Cutting out high values
has no effect
Moving to a lower value of
f doesn’t help
a
f
f
Gordon Kindlmann
Ray casting: one rendering technique
The sample volume must now be rendered
Vast body of literature on different techniques
Simplest idea is ray casting
(1) Send ensemble of rays through the system corresponding to
image pixels
(2) Interpolate values along each ray from grid
(3) Local gradient is calculated to estimate amount of light
reflected back to image
(4) Values are composited together from back to front
Image source: Wikipedia
Trilinear Interpolation
What is the effect of interpolation on the volume rendered image? Could
choose nearest neighbour value, or linear interpolation
Below is a comparison of nearest neighbour to trilinear
The additional expense of the interpolation removes a significant amount of
noise in the final image
Michael Knapp
Nearest Neighbor
Trilinear Interpolation
Multiple layers in volume rendering
Example using a
tool called “vfleet”
Rendering of gas
density in one of
my simulations
Transfer function
has been chosen to
pick out three
surfaces
“See through”
isosurfaces
Exactly the same
as having multiple
opaque isosurfaces
Making movies
Some toolkits (e.g. AVS) will make movies from a bunch of
frames (images) for you
First step in making a movie manually is to create a series of
frames with a fixed naming convention
e.g. frame.00001.gif, frame.00002.gif, frame.00003.gif
From this series of frames a number of freely available tools will
compile them into a movie for you
Opendx unfortunately doesn’t
Most tools rely on some kind of UNIX script to do this
I’ll give explicit details for the “makempeg” script
This makes MPEG-1 standard movies which are lossless
Fairly low compression ratio, but no bad rectangular artifacts
Ideal for scientific viz.
Makempeg
I will put this Unix driver script on the class website (if
you are interested)
Rather dated now, but it works effectively
You need two other packages
Berkeley MPEG encoder (will also put on website)
netpbm image manipulation tools (can be installed in Linux)
This is the program that creates (encodes) the movie from your
images
Compile this code, will create the “mpeg” executable
Need by the makempeg script to convert images into the format used
by the MPEG encoder
Place the makempeg script and mpeg executable in the
same directory as your frames of name xxxx.yyyyy.ext
Running makempeg
Example command:
makempeg –fs 1 –fe 10 –fi 1 –base test –ext gif
Will make a movie
Starting at frame 1 (-fs)
Ending at frame 10 (-fe)
Increments between frames is 1 (-fi)
Name of files is test.????.gif
Script expects 4 digit number for each frame
-base = base name
-ext = filename extension (could be jpg, tiff…)
i.e. test.0001.gif test.0002.gif test.0003.gif
Script will convert to the “YUV” format and then launch the encoder
Quite quick – may be up to 2 minutes for a larger movie, much faster for
smaller
Example movie made with
makempeg
Summary
Use the data prompter to create the description file for
Opendx data
Construct visual programs quickly and easily by linking
modules together in the visual program editor
Isosurface and volume rendering techniques are both
supported by Opendx
Selecting suitable transfer functions is non-trivial and takes
time
Lastly, movies can be made quickly and easily from a
series of frames using a large number of freely available
tools
I’ve provided codes for one method on the website
Student presentations
No lectures March 24th, 26th, 31st
April 2nd
Mike Hiland
Ashley Campbell
Glen Hodge
Masaki Uchida
April 7th
Michael Palmer
Nick Presse
Cristina Collicott