Computer Graphics and Scientific Visualization

9 downloads 108427 Views 5MB Size Report
Computer Graphics has several meanings: .... c. Random-scan system's are generally costlier. move 10 20 line 20 40 ... char O char R ... c. Lines map to lines d. Parallel lines remain parallel e. Ratios are preserved f. Closed under ..... Computer Graphics - C version (second edition) –. Donald Hearn, M. Pauline Baker. ▣.
Indo German Winter Academy 2009

Avishek Banerjee Computer Science and Engineering, IIT Kharagpur Mentor: Dr. Suman Chakraborty 1



Computer Graphics Why Computer Graphics ?  Relevant Disciplines 



Scientific Visualization 



Motivation

Fundamentals of Scan Displays Random Scan  Raster Scan 



Drawing Geometric Primitives Digital Line Drawing  Circles, Spline curves 

 

Transformations 3D Rendering Visible Surface Determination  Viewing and Clipping 

 

Illumination Models Conclusion 2



Computer Graphics has several meanings: Representation and manipulation of pictorial data by computers.  The sub-field of Computer Science which studies methods for digitally synthesizing and manipulating visual content. 

Image Analysis

(pattern recognition) Mathematical Model

Image Image Synthesis

(Rendering)

Modeling

Image processing 3







Developing Computational Capability –

Rendering: Synthesizing realistic-looking, useful, or interesting images



Animation: Creating visual impression of motion



Image processing: Analyzing, transforming, displaying images efficiently

Better Understanding of Data, Objects, Processes through Visualization –

Visual summarization, description, manipulation



Virtual environments (VR), visual monitoring, interactivity



Human-computer intelligent interaction (HCII): training, tutoring, analysis, control systems

Time is Right –

Recent progress in algorithms and theory



Rapidly emergence of new I/O (display and data acquisition) technologies



Available computational power, improving price-performance-ratio of hardware



Growth and interest of graphics industries (e.g., information visualization, entertainment CAD) 4



Analytic Geometry



Art and Graphic Design



Cognitive Science



Computer Engineering



Engineering Design



Education



Film



Human Factors



Linear Algebra



Numerical Analysis

CAD CAE / CASE CAM

Rendering Hardware VR Systems Portable/Embedded CG

Immersive Training Tutoring Interfaces

Color/Optical Models CG/Vision Duality Interface Design Layout CG Design Visualization Parametric Equations Conics Polygon Rendering

Computer Graphics

Surface Modeling Physically-Based Modeling Stat/Info Visualization

Transformations Change of Coordinate Systems

User Modeling Ergonomic Interfaces, I/O

Animation Large-Scale CG 5

 



Generation of Huge datasets in experiments. Goal : to assist the researchers in developing a deeper understanding of the data under investigation. Create graphical representations from the results of computations and simulations

Why successful?   

   

Human eye : An efficient pattern Detector. Computer generated images combined with human vision, Perceptual psychology.

Computer simulation Information visualization Volume visualization Surface rendering 6

Medical Imaging

Software Visualization

Information Visualization 7







Display screen is imagined to be split into a very fine mesh of elementary rectangles called PIXELS. Two different types of Scan displays: a. Raster Scan Display: Image is represented as an rectangular grid of coloured squares b. Random Scan Display: Image is represented by continuous geometric objects: lines, curves, etc

What is Scan Conversion ?  Process of digitizing a picture definition into a set of pixel-intensity values for storage in the frame buffer.  Need to locate point closest to the given point and store its intensity in the frame buffer.

8



Raster scanning, is the rectangular pattern of image capture and reconstruction in television.



Image: subdivided into a sequence of (usually horizontal) strips known as "scan lines". Each scan line can be transmitted in the form of an analog signals it is read from the video source.



  

Properties: Less resolution. The lines produced are ziz-zag as the plotted values are discrete. Frame buffer 0 0 0 0 0 0

0 7 7 0 0

0 0 0 0 7 7 6 7 7 Refresh speed independent of 0 scene complexity pixel

RASTER 9



 

Display Units operate by directing the electron beams to only those parts of the screen where picture is to be drawn. Called Vector Graphics Properties: a. High resolutions since the picture definition is stored as a set of line drawing commands and not as a set of intensity values. b. Smooth lines are produced as the electron beam directly follows the line path. c. Random-scan system's are generally costlier. Display list move 10 20 line 20 40 ... char O

Display Controller

VECTOR

char R 10



What does Drawing Line mean ?: Given two points P and Q in the plane, (with integer coordinates), determine which pixels on a raster screen should be on in order to make a picture of a unit width line segment starting from P and ending at Q.



The digital differential analyzer (DDA) samples the line at unit intervals in one coordinate corresponding integer values nearest the line path of the other coordinate. Basic incremental scan-conversion(DDA) algorithm for line drawing for x from x0 to x1 Compute y=mx+b Draw_pixel(x, round(y))



Major deficiency in the above approach :





Floating Point Calculation



Has rounding operations

11

  

Used for Drawing Lines, Circle etc. Only Integer Arithmetic, no Floating point computation. Often implemented in Hardware of Graphics Cards.

12



Specify transformations for objects  Allows definitions of objects in own coordinate systems.  Allows use of object definition, multiple times in a scene.



Linear Transformations Homogenous Co-ordinates





2D Transformations  Basic 2D transformations  Matrix representation  Matrix composition



3D Transformations  Basic 3D transformations  Same as 2D



Composition of Tranformations 13

Properties : a. b. c. d. e. f.

Satisfies: T ( s1p1 + s2p 2 ) Origin maps to origin Lines map to lines Parallel lines remain parallel Ratios are preserved Closed under composition

 x '  a  y ' =  c   

b x d   y 

= s1T (p1 ) + s2T (p 2 )

Multiply matrix by column vector ⇔ apply transformation to point

 x ' =  a  y '  c

b  x d   y 

x ' = ax + by y ' = cx + dy 14

 



Represent coordinates in 2dimensions with a 3-vector. (x, y) in Cartesian coordinate is (xh, yh, h) in Homogeneous coordinate Where xh = x * h and yh = y * h

 x  x  homogeneous coords    y     → y     1 

How to Construct ? Add a 3rd coordinate to every 2D point  (x, y, w) represents a point at location (x/w, y/w)  (x, y, 0) represents a point at infinity  (0, 0, 0) is not allowed y

2 1

(2,1,1) or (4,2,2) or (6,3,3)

1 2

x 15



Repositioning an object along a straight line path from one coordinate location to another.

 x ' 1 0 t x   x   y ' = 0 1 t   y  y       1  0 0 1   1  16



Types of Scaling: 

Scaling a coordinate means multiplying each of its components by a scalar.

 x '   ax   y ' = by     

×2

17

Transformation III: Rotation x = r cos (φ) y = r sin (φ) x’ = r cos (φ + θ) y’ = r sin (φ + θ)

(x’, y’) (x, y)

θ

φ

Trig Identity… x’ = r cos(φ) cos(θ) – r sin(φ) sin(θ) y’ = r sin(φ) sin(θ) + r cos(φ) cos(θ) Substitute… x’ = x cos(θ) - y sin(θ) y’ = x sin(θ) + y cos(θ)

 x '   cos Θ  y ' =  sin Θ     1   0

− sin Θ cos Θ 0

0  x  0   y  1   1  18



A transformation that distorts the shape of an object so that the transformed object appears as if the object were composed of internal layers that had been caused to slip over each other.  A 2-Dimensional Shearing transformation is specified as :  x’ = x + hx*y  y’ = y + hy*x

 

When hx=0, y-axis Shearing When hy=0, x-axis Shearing

 x' sx 0 0x  y' =  0 s 0 y y       1   0 0 11 19



Q: How do you undo a rotation of q, R(q)?



A: Apply the inverse of the rotation… R-1(q) = R(-q)





Q: How to construct R-1(q) = R(-q) ?  Inside the rotation matrix: cos(q) = cos(-q)  The cosine elements of the inverse rotation matrix are unchanged.  The sign of the sine elements will flip. Therefore… R-1(q) = R(-q) = RT(q)

20

Matrices are a convenient way to represent a sequence of transformations

 x'   1 0 tx  cos Θ − sin Θ 0  sx 0 0   x   y '  =  0 1 ty   sin Θ cos Θ 0  0 sy 0   y      w'  0 0 1   0    0 1   0 0 1    w  p’ =

T(tx,ty)

R(Θ Θ)

S(sx,sy)

p

If two transformations (say P and then Q) are performed in succession. So a point ‘x’ is transformed to ‘P.x’ after transformation P and then to ‘Q.P.x’ after transformation Q. Order of transformations matters:-

Matrix multiplication is not commutative !! Ex: Rotate line segment by 45 degrees about endpoint and lengthen

R(45)

T(-3) R(45) T(3)

21

The following issues to be addressed while rendering:

a. b. c. d.

3D scene representation 3D viewer representation Visible surface determination Lighting simulation 22

 



How is the viewing device described in a computer? Camera Models  The most common model is pin-hole camera  All captured light rays arrive along paths toward focal point without lens distortion. Displaying an image Involves mapping the coordinates of points and lines from the picture to appropriate coordinates on the device where image is to be displayed.

Some terminology:   

World coordinate system WINDOW VIEWPORT

23

  

Sometimes need to display only a portion of a picture. Need to effectively erase/eliminate part of picture. Avoid drawing parts of primitives outside window o Window defines part of scene being viewed o Must draw geometric primitives only inside window.

Reverse of Clipping: which means covering up portion of picture that is not visible .

Find the part of a line inside the clip window ?

24



Line Clipping algorithm.



The algorithm divides a 2D space into 9 parts, of which only the middle part (viewport) is visible.



Algorithm:

a. Both endpoints are in the viewport (bitwise OR of endpoints == 0): trivial accept. b. Both endpoints are on the same side of the rectangle, which is not visible (bitwise AND of endpoints != 0): trivial reject. c. Both endpoints are in different parts:  

Find one of the two points that are outside the viewport (there is at least one point outside). The intersection of the outpoint and extended viewport border is then calculated (i.e. with the parametric equation for the line) and this new point replaces the outpoint and then repeat. 25



What is a Colour Model ?



Abstract mathematical model describing the way colors can be represented as tuples of numbers. Orderly system for creating a whole range of colors from a set of primary colors.



26

Hidden Surface Removal Process used to determine which surfaces and parts of surfaces are not visible from a certain viewpoint.

Motivation a. Necessary to render an image correctly, so that one cannot look through walls in virtual reality, for example. b. Surfaces may be back-facing. c. Surfaces may be occluded. d. Surfaces may intersect

27







Compare the surface depths at each pixel position on the projection plane. For each pixel position (x, y) the object depths can be compared by comparing the z values. If the current pixel is behind the pixel in the Z-buffer, the pixel is rejected, otherwise it is shaded and its depth value replaces the one in the Z-buffer. Assuming a surface to be planar Ax + By + Cz +D = 0, z can be computed as z = (–Ax –By –D)/C.

Coverage Buffers(C-Buffers) and Surface Buffers(S-Buffers): a. b.

c.

Faster than Z-Buffers Instead of storing the Z value per pixel, they store list of already displayed segments per line of the screen. Mostly used in Gaming industry.

28





Attempts to model the path of light rays to a viewpoint by tracing rays from the viewpoint into the scene. Although not a hidden surface removal algorithm as such, it implicitly solves the hidden surface removal problem by finding the nearest surface along each view-ray.

29



Divide each viewing area into smaller parts until each small area is the part of a single visible surface or no surface at all.



Using appropriate Data-structures:  Kd-tree  Octree  Binary Space Partitioning tree

a. This allows visibility determination to be performed hierarchically. b. If a node in the tree is considered to be invisible then all of its child nodes are also invisible. c. If a node is considered visible, then each of its children need to be evaluated.

30



What is Rendering ? Process of Producing Realistic images/pictures.  Human Eye: Complicated System, with Rods and cones. 

Each point may have several sources of illumination: a. Direct illumination - light arrives straight from the sources. b. Indirect illumination- light arrives after interacting with the rest of the scene.

Which one is More Realistic ?.. 31







Model 1: Ambient Light a. Uniform from all directions b. Intensity I = Ka Ia Model 2 : Ambient + Diffuse light a. Follows Lambert’s Cosine Law b. Called Lambertian illumination model Model 3: Ambient + Diffuse + Specular light a. Many Surfaces are Shiny b. Shiny surfaces produces highlights. c. Highlights are due to Specular reflection and move with the observer.

32

 

Aim: Cancer Ablation and Tumor destruction Experiment: Photo Photo--thermal Tumor Destruction using LongLong-Circulating Gold NanoNano-rod Antennas.



Methodology: Building a predictive model for plasmonic nano-material assisted tumor destruction under extracorporeal laser irradiation



Observations: Studying heat dissipation for plasmonic nanomaterials , b. And Simulating our experimental findings to validate the hypothesis. a.

Tumor Periphery TUMOR

Skin

Tumor Core

Muscle 33

15 sec

1 min

1.5 min

3 min

5 min

34

35



Introduction  



Scan Displays  

 

 

Cohen-Sutherland algorithm

Illumination Models   



Z-Buffer algorithm Ray-Tracing algorithm Area Subdivision Method

Clipping 



Random Display Raster Display

Transformations Hidden Surface Removal 



Computer Graphics Scientific Visualization

Ambient illumination Lambertial Illumination Specular Illumination

Simulating Real World problem !! 36



Computer Graphics - C version (second edition) – Donald Hearn, M. Pauline Baker



Fundamentals of Computer Graphics – S. Chakraborty



“Introduction to Computer Graphics”, University of Virginia



“3D Rendering, Clipping and Illumination” lectures, Princeton University.



For further online references, http://en.wikipedia.org/wiki/Computer_graphics http:// graphics.stanford.edu/

37

38