Rasterization and Vector Graphics

spongemintΛογισμικό & κατασκευή λογ/κού

2 Δεκ 2013 (πριν από 3 χρόνια και 9 μήνες)

84 εμφανίσεις

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

1
/30

02


Rasterization

and Vector Graphics

Lecture 02:

Rasterization

and
Vector Graphics


COMP
175: Computer
Graphics

September 6, 2011

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

2
/30

02


Rasterization

and Vector Graphics


Graphics library/package is intermediary between application and
display hardware (Graphics System)


Application program maps application objects to views (images) of
those objects by calling on graphics library. Application model may
contain lots of non
-
graphical data (e.g., non
-
geometric object
properties)


User interaction results in modification of model and/or image


This hardware and software framework is more than 4 decades old but
is still useful

Conceptual Framework for Interactive Graphics

Graphics

System
/

GPU

Application

Model/data
base

Software

Hardware

2

Application

program

Graphics

Library

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

3
/30

02


Rasterization

and Vector Graphics


Examples: OpenGL™, DirectX™, Windows
Presentation Foundation™ (WPF),
RenderMan



Primitives (characters, lines, polygons, meshes,…)


Attributes


Color, line style, material properties for 3D


Lights


Transformations


Immediate mode vs. retained mode


immediate mode
: no stored representation, package
holds only attribute state, and application must
completely draw each frame


retained mode
: library compiles and displays from
scenegraph

that it maintains, a complex DAG. It is a
display
-
centered extract of the Application Model

Graphics Library

Introduction

3

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

4
/30

02


Rasterization

and Vector Graphics


Two Basic Paradigms

Computer Graphics Paradigms

What’s the difference?

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

5
/30

02


Rasterization

and Vector Graphics


Images are made up for grid of discrete pixels, for 2D “picture
elements”


Pixels are point locations with associated sample values, usually
of light intensities/colors, transparency, and other control
information


When we sample an image, we sample the point location along
the continuous signal and we cannot treat the pixels as little
circles or squares


Sample
-
based Graphics

Visualization of a

mathematical

pixel grid

LCD display

CRT beam illumination pattern

Can’t
resolve adjacent
pixels on CRT

1 pixel

light intensity

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

6
/30

02


Rasterization

and Vector Graphics


Samples created directly in paint
-
type program, or as sampling of
continuous (analog) visual materials. E.g., photograph can be sampled
(light intensity/color measured at regular intervals) with many devices
including:


flatbed and drum scanners


digital still and motion (video) cameras


add
-
on boards such as frame grabbers


Sample values can also be input numerically (e.g., with numbers from
computed dataset)


Once an image is defined as pixel
-
array, it can be manipulated


Image editing:
changes made by user, such as cutting and pasting sections,
brush
-
type tools, and processing selected areas


Image processing:
algorithmic operations that are performed on image (or
pre
-
selected portion of image) without user intervention. Includes blurring,
sharpening, edge
-
detection, color balancing, rotating, and warping.

Sample
-
based Graphics

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

7
/30

02


Rasterization

and Vector Graphics











A color value is measured at every grid point and used to color corresponding
grid square










Note: this poor sampling and image reconstruction method creates blocky
image

Sampling an Image

3D scene

0 = white, 5 = gray, 10 = black

7

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

8
/30

02


Rasterization

and Vector Graphics

What’s the Advantage?


Once image is defined in terms of
colors at (x, y) locations on grid, can
change image easily by altering
location or color values


E.g., if we reverse our mapping above
and make 10 = white and 0 = black, the
image would look like this:



Pixel information from one image can
be copied and pasted into another,
replacing or combining with
previously stored pixels

8

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

9
/30

02


Rasterization

and Vector Graphics


WYSIAYG (What You See Is All You Get): No additional
information


no depth information


can’t examine scene from different point of view


at most can play with the individual pixels or groups of pixels to change
colors, enhance contrast, find edges, etc.

What’s the Disadvantage?

Photo Tourism: Exploring photo collections in 3D

(
Siggraph

2006
)

http
://www.youtube.com/watch?v=IgBQCoEfiMs


But recently, strong interest
in image
-
based rendering to
fake 3D scenes and
arbitrary camera positions.
New images constructed by
interpolation, composition,
warping and other
operations
.

9

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

10
/30

02


Rasterization

and Vector Graphics


Sample
-
based graphics: discrete
samples are used to describe visual
information


pixels can be created by digitizing images,
using a sample
-
based “painting” program,
etc.


often some aspect of the physical world is
sampled for visualization, e.g., temperature
across the US


example programs: Adobe Photoshop™,
GIMP™ , Adobe
AfterEffects



Sample
-
based Graphics

Introduction

10

Graphics

System
/

GPU

Application

Model/data
base

Software

Hardware

Application

program

Graphics

Library

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

11
/30

02


Rasterization

and Vector Graphics





Questions?


COMP 175 | COMPUTER GRAPHICS

Remco

Chang

12
/30

02


Rasterization

and Vector Graphics


Geometry
-
based Graphics


Also known as (scalable) vector graphics,


Or object
-
oriented graphics



Geometry is created along with various appearance
attributes, and is then sampled for visualization
(via rendering)


examples of 2D apps: Adobe Illustrator™, Adobe
Freehand™, Corel
CorelDRAW



examples of 3D apps: Autodesk’s AutoCAD2010™,
Autodesk’s (formerly
Alias|Wavefront’s
) Maya™,
Autodesk’s) 3D Studio Max™


Geometry
-
based Graphics

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

13
/30

02


Rasterization

and Vector Graphics


Geometry
-
based

graphics applications store
mathematical descriptions, or “models,” of geometric
elements (lines, polygons, polyhedrons…) and associated
attributes (e.g., color, material properties). Elements are
primitive geometric shapes, primitives for short



Images

created as pixel arrays (via sampling of geometry)
for viewing, but not stored as part of model. Images of
many different views are generated from same model


Computer Graphics
Paradigms

Graphics

System
/

GPU

Application

Model/data
base

Software

Hardware

Application

program

Graphics

Library

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

14
/30

02


Rasterization

and Vector Graphics


What is a model?


Captures salient features (data, behavior) of
thing/phenomenon being modeled


data includes geometry, appearance, attributes…


note similarity to OOP ideas


Real: some geometry inherent


physical (e.g., actual object such as a chair)


non
-
physical (e.g., mathematical function, weather data)


Abstract: no inherent geometry, but for visualization


organizational (e.g., company org. chart)


quantitative (e.g., graph of stock market)

What is Geometric Modeling?

Introduction

14

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

15
/30

02


Rasterization

and Vector Graphics


Divide and Conquer


Hierarchy of geometrical
components





Reduction to primitives (e.g.,
spheres, cubes, etc.)


Simple vs. not
-
so
-
simple
elements (nail vs. screw)

Decomposition of a Geometric Model

decomposition

Head

Shaft

Point

composition

15

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

16
/30

02


Rasterization

and Vector Graphics


Object to be modeled is (visually) analyzed, and then decomposed into
collections of primitive shapes.


Tree diagram provides visual method of expressing “composed of”
relationships of model









Such diagrams are part of 3D program interfaces (e.g., 3D Studio MAX,
Maya)


As a data structure to be rendered, it is called a
scenegraph

Hierarchical (Tree) Diagram of Nail

Nail

Head

(cylinder)

Body

root node

leaf nodes

Shaft

(cylinder)

Point

(cone)

tree diagram

16

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

17
/30

02


Rasterization

and Vector Graphics


Geometric Modeling

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

18
/30

02


Rasterization

and Vector Graphics


Examples of 3D Primitives

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

19
/30

02


Rasterization

and Vector Graphics





Questions?


COMP 175 | COMPUTER GRAPHICS

Remco

Chang

20
/30

02


Rasterization

and Vector Graphics

Vector

(calligraphic, stroke,
random
-
scan
)

Raster

(TV, bitmap,
pixmap
) used
in displays and laser
printers


Driven by display commands
(move (x, y), char(“A”) , line(x,
y)…)


Survives as “scalable vector
graphics”


Driven by array of pixels (no
semantics, lowest form of
representation)


Note “
jaggies
” (aliasing errors) due
to sampling continuous primitives



Rendering

Ideal
Drawing

Vector
Drawing


Raster

20

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

21
/30

02


Rasterization

and Vector Graphics


Vector display works
with display
list/file
stored
in refresh
buffer




Display controller
draws all vectors at
<
60
Hz (
often
at variable
rate
);



flicker is
a problem

Vector Architecture

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

22
/30

02


Rasterization

and Vector Graphics


Raster display stores
bitmap/
pixmap

in refresh
buffer, also known as
bitmap,
frame
buffer; can be in
separate hardware
(VRAM) or
in CPU’s
main memory
(DRAM
)




Video
controller draws all
scan‐lines
at consistent
> 60
Hz; separates
update rate
of
the frame buffer and refresh
rate of
the CRT

2D Raster Architecture

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

23
/30

02


Rasterization

and Vector Graphics


Raster vs. Vector Graphics

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

24
/30

02


Rasterization

and Vector Graphics


Users
cannot usually work directly with individual pixels in geometry
-
based programs; as user manipulates geometric elements, program
resamples and redisplays
elements



Increasingly
rendering combines geometric and sample
-
based
graphics, both as performance hack and to increase quality of final
product

Computer Graphics
Paradigms

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

25
/30

02


Rasterization

and Vector Graphics


Modeling


Create models


Apply materials to models


Place models around scene


Place lights in scene


Place the camera

Modeling
+

Rendering

Directional Light

Ambient
Light

Point Light

Spot
Light


Rendering

Take “picture” with camera


Both can be done
with commercial
software:

Autodesk
Maya
TM

,3D Studio
Max
TM
,
Blender
TM
, etc.

25

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

26
/30

02


Rasterization

and Vector Graphics





Questions?


COMP 175 | COMPUTER GRAPHICS

Remco

Chang

27
/30

02


Rasterization

and Vector Graphics


Things You Might Need to Know:



Representing an image in software memory



Color representation of a pixel


What are the basic colors?


How many bits do you need?



Convert 2D array into 1D array


Assignment 1: Brush

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

28
/30

02


Rasterization

and Vector Graphics


Assume you have a function like:



BGRA* pixels = Canvas
-
>
getData
();


Note: BGRA => char[4]


Setting a color:



pixels[0].r = 255


Getting a color:



char
redcolor

= pixels[0].r //or



int

redcolor

= pixels[0].r




Assignment 1: Brush

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

29
/30

02


Rasterization

and Vector Graphics


Problems:

1.
How to draw a square?

2.
How to draw a circle with radius r?

3.
How to draw a circle in grayscale?

4.
How
t
o draw
a semi
-
transparent circle (50%
transparency)?

5.
How to draw a circle at a specified location (a, b)

A.
How would you do this quickly so that

1.
your solution is not O(n) where n = number of pixels on your
screen?)

2.
you are not making k number of geometric (intersection) calls?

B.
How would you draw multiple circles?


Assignment 1: Brush

COMP 175 | COMPUTER GRAPHICS

Remco

Chang

30
/30

02


Rasterization

and Vector Graphics


Jordan:


Demo


Details of the assignment


Assignment 1: Brush