52
IT Uppsala universitet Scientific Visualization 5 hp Fall 2010 Filip Malmberg filip@cb.uu.se Ch 1. Introduction Ch 2. Computer Graphics primer Ch 4. The Visualization pipeline

Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

IT Uppsala universitet

Scientific Visualization5 hp

Fall 2010

Filip Malmberg [email protected]

Ch 1. IntroductionCh 2. Computer Graphics primerCh 4. The Visualization pipeline

Page 2: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #2@ UU/IT

Filip Malmberg ([email protected]) Stefan Seipel ([email protected]) Patrik Malm ([email protected]) Pontus Olsson ([email protected]) Gustaf Kylberg ([email protected])

Teachers

Centre for Image Analysis, CBAITC building 2, floor 1Office 2111

Page 3: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #3@ UU/IT

About me PhD-student in image processing. Working with medical volume images. Using visualization as a tool in my research.

Page 4: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #4@ UU/IT

About the course 10 lectures 3 Computer exercises/assignments (3 hp) Written exam (2 hp)

Textbook:The Visualization Toolkit, An Object-Oriented Approach to 3D Graphics,4th edition, Kitware, Inc., 2006ISBN 1-930934-19-X

Page 5: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #5@ UU/IT

Course webpagehttp://www.it.uu.se/edu/course/homepage/vetvis/ht10/

Page 6: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #6@ UU/IT

What is visualization?Dictionary:vi·su·al·ize

• To form a mental image of; envisage: try to visualize the scene as it is described

• To make visible

Page 7: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #7@ UU/IT

Interpreting data in visual terms When data is complex: Collected/Computed

When numerous data Visualization is not a substitute to,

but in addition to, statistical analysis and other quantitative methods

Visualization takes advantage of human sensory abilities• Pattern recognition, Trend discovery, etc.

Page 8: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #8@ UU/IT

Example: Graphs

0500

1000150020002500300035004000

Mfl

op/s

ec

2 4 8 16 32 64

Number of Processors

158,7601,121,320

Unknowns

IBM SP2

Page 9: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #9@ UU/IT

Some more sophisticated examples

Nuclear, Quantum, and Molecular Modeling

Structures, Fluids, and Fields

Advanced Imaging and Data Management

Page 10: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #10@ UU/IT

Scientific visualization Scientific visualization is the process of

exploring, transforming, and viewing data as images

The dimensionality of the data is generally larger than or equal to 3

Visualization is often interactive We are not trying to create realistic images,

but to visualize data in an informative way Dependent on the task given

Page 11: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #11@ UU/IT

Visualization serves many purposes ”Pretty pictures” For further analysis Debugging ...

Page 12: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #12@ UU/IT

Visualization can be used in every step of most processes

Problem formulation Mathematical modelling Software/Hardware Simulation Result Interpretation

Page 13: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #13@ UU/IT

General development of visualization

Rather new discipline still developing into sub-areas

Multi-disciplinary (Computer science, human perception, computer graphics, HCI)

Faster computers, high-speed networks, new user-interfaces

Page 14: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #14@ UU/IT

Ch 3: Computer graphics primer Creating images with a computer – 3D

Page 15: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #15@ UU/IT

Digital images

Image of a rat Close-up of rat nose

94 100 104 119 125 136 143 153 157 158103 104 106 98 103 119 141 155 159 160109 136 136 123 95 78 117 149 155 160110 130 144 149 129 78 97 151 161 158109 137 178 167 119 78 101 185 188 161100 143 167 134 87 85 134 216 209 172104 123 166 161 155 160 205 229 218 181125 131 172 179 180 208 238 237 228 200131 148 172 175 188 228 239 238 228 206161 169 162 163 193 228 230 237 220 199

Page 16: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #16@ UU/IT

Color

Page 17: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #17@ UU/IT

Visible spectrum Light=electromagnetic radiation

Page 18: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #18@ UU/IT

Colour The eye’s and the brain’s impression of electromagnetic

radiation in the visual spectra

How is colour percieved?

Lightsource

Reflecting object

Detector

rods & cones

red-sensitive

green-sensitive

blue-sensitive

Page 19: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #19@ UU/IT

Human color perception

3 types of “detectors”->We can think of colour as a “3D space”.

Page 20: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #20@ UU/IT

RGB/ CMY colour space

RGB - for additive colour mixing, e.g., on a computer screenCMY - for subtractive colour mixing, e.g., in printing or painting

Page 21: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #21@ UU/IT

HLS colour space Hue: dominant wavelength, tone Lightness: Intensity, brightness Saturation, dilution by white

Important aspects:•Intensity decoupled from colour•Related to how humans perceive colour

Page 22: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #22@ UU/IT

Computer graphicsComponents: Model: geometry, surface properties, … Lighting: number, positions, properties Viewpoint Projection

Computer graphics is the foundation of data visualization... but visualization is more than computer graphics!

Page 23: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #23@ UU/IT

Rendering Generation of an image from data. “Physical” view:

• Rays of light are emitted from a light source• Some rays strike an object• The object surface absorbs some light and reflects

the rest• Some reflected light enter our eyes (or a camera)• We ”see” the object

Page 24: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #24@ UU/IT

Ray-tracing or ray-casting Ray-tracing simulates the interaction of light

with objects by following the path of each light ray.

In computations: • follow the rays backwards from the eye into the

scene

Page 25: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #25@ UU/IT

Computationally: Ray casting Only rays that reach the eye matter Reverse direction and cast rays, instead of

trace rays Need at least one ray per pixel

Page 26: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #26@ UU/IT

Image-order and object-order methods

Ray-tracing is an image-order process, determining what happens to each pixel (ray of light), one at a time

An object-order process works by rendering each object, one at a time

Page 27: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #27@ UU/IT

Rasterization Line drawing Polygon (triangle) filling

Scan one line at a time:scan conversion/ scan line rendering

Page 28: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #28@ UU/IT

What's so interesting about triangles?

Easy to handle mathematically (e.g. always flat)

In CG, complex surfaces are often approximated by a large number of triangles.

Page 29: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #29@ UU/IT

// Image order renderingfor all pixels for all objects calculate the object's contribution to the pixel colour endend

Image-order and object-order methods

// Object order renderingfor all objects for all pixels (occupied by the object!) calculate the object's contribution to the pixel colour endend

Page 30: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #30@ UU/IT

Lights in CG We simplify by assuming (infinitely distant)

point-shaped light sources Light is emitted in all directions from a single

point in space Far away implies that rays are parallel

Page 31: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #31@ UU/IT

Light-surface interaction The Phong reflection model =

• Ambient reflection +• Diffuse reflection +• Specular reflection

n

l

rv

φθ

Page 32: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #32@ UU/IT

Phong reflection model

Illustration of the Phong Reflection Model. Created by Brad Smith, August 7, 2006.

Page 33: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #33@ UU/IT

Polygonal shading

Flat Gouraud Phong

Illumination depends on normal vector!

Page 34: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #34@ UU/IT

Local vs. Global illumination

Historically:

Ray tracing

Scan line

Global illumination

Local illumination

Offline rendering

Realtime rendering

Page 35: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #35@ UU/IT

Surface vs. volume rendering For simplicity, we can view the surface of

objects and their interactions with light However, translucent objects scatter light and

we need to consider properties inside the objects

Chapter 7 describes volume rendering (Lecture 4)

vs.

Page 36: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #36@ UU/IT

Camera model

Page 37: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #37@ UU/IT

Camera movementsMovement around focal point Movement around camera center

Page 38: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #38@ UU/IT

Coordinate systems4 coordinate systems: Model: where the object is defined World: 3D space where actors are positioned View: what is visible to the camera Display: (x, y) pixel locations See Figure 3-14

Page 39: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #39@ UU/IT

Coordinate transformations 3D to 2D Perspective Rotation, translation, scaling Homogeneous coordinates 4x4 transformation matrices

Page 40: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #40@ UU/IT

Hidden surface removal Inter-object occlusion is an important depth

cue. Needs to be handled correctly when rendering

3D objects.

Page 41: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #41@ UU/IT

Z-buffer algorithm

fill z-buffer with infinite distancefor all objects for each (object) pixel calculate object's z-value if z(x,y) is closer than z-buffer(x,y) draw pixel z-buffer(x,y)=z(x,y) end endend

Note: With ray tracing, we get this for “free”

Page 42: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #42@ UU/IT

Learning more about CG• Computer graphics, 10 hp• Period 3

Page 43: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #43@ UU/IT

Ch 4. The visualization pipeline Computer graphics: Convert graphics

primitives to images Visualization: Convert data to graphics

primitives

Page 44: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #44@ UU/IT

Visualization pipelineThe pipeline consists of objects to represent data objects to operate on data indicated direction of data flow (arrow

connections between objects)

Page 45: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #45@ UU/IT

Data objects Represent information Provide methods to create, access, and delete

data To modify data is not really allowed; reserved

for process objects

Page 46: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #46@ UU/IT

Process objects Operate on input data to generate output data New data or new form

Source objects • initiate (read, generate) visualization data flow

Filter objects • maintain visualization data flow

Mapper objects • terminate (write, graph) visualization data flow

Page 47: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #47@ UU/IT

A visualization pipeline

Page 48: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #48@ UU/IT

Pipeline topology How to connect data objects and process

objects Pipeline connections

• type concerns the form of data that process objects take as input or generate as output

• multiplicity deals with # of input and # of output allowed

Feedback loops• view intermediate results

Page 49: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #49@ UU/IT

Executing the pipeline Causing each process object to operate Most often repeated executions due to user

interaction• change parameters of process object• change input to process object

For efficiency reasons, see to that only execute the process objects whose input has changed

Synchronization between process objects required prior to execution

Page 50: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #50@ UU/IT

Memory and computation trade-off Visualization is resource demanding in

• computer memory due to input size• computational times due to algorithm complexity

Static memory model• intermediate data saved to reduce overall

computation Dynamic memory model

• intermediate data discarded, but may have to be re-computed

Combination of static and dynamic models

Page 51: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

UU/IT

08-01-29 | #51@ UU/IT

Next lecture Intro to VTK and Python. More about the visualization pipeline, as

implemented in VTK.

Page 52: Ch 1. Introduction Scientific Visualization Ch 2. Computer ... · Intro to VTK and Python. More about the visualization pipeline, as implemented in VTK. IT Uppsala universitet Scientific

IT Uppsala universitet

Scientific Visualization5 hp

Fall 2010

Filip Malmberg [email protected]

Ch 1. IntroductionCh 2. Computer Graphics primerCh 4. The Visualization pipeline