non-photorealistic computer graphicsstefans/slides/05a-stippling.pdf · non-photorealistic computer...

38
_ _ University of Magdeburg Stippling and Hatching 1 Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I

Upload: others

Post on 18-Jun-2020

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 1

Non-PhotorealisticComputer Graphics

Chapter 5: Stippling and Hatching

Part I

Page 2: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 2

1. Stippling

• Points or dots are the primitives, images consist completely of these points or dots.

• well known artistic technique

• Tone as well as texture are created by the placement of small dots (stipples).

• dots equally but randomly distributed

• done by hand:

very time consuming

hard to learn

needs to be done carefully

Page 3: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 3

Jacquetta Hawkes: The Atlas of Early Man. St. Martin’s Press, 1976

Page 4: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 4

• algorithmic approach:

- obtain an initial point distribution

- modify this distribution with respect to

image intensity

image properties

edges

gradients

possibly additional properties needed for animation

- user interaction for fine tuning

Page 5: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 5

1.1. Obtaining an Initial Point Distribution

• even but random distribution of stipples required

• brute force:

- take a random number generator

- generate random coordinates

- place stipples there until the desired tone is achieved

→ stipples may overlap each other

→ stipples not equally distributed

• another possibility

- use the result of a halftoning algorithm

→ usually too many points

→ put more emphasis on the initial distribution to yield a good starting point for further processing

Page 6: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 6

• generate a number of random coordinates (points) each of which is assigned a random number between 0 and 1

• view the image as an intensity surface and the random numbers as lines of the respective height

• select these points where their assigned random number is greater than the intensity value, i.e. the line intersects the intensity surface

• Regions with higher intensity (white = 1) will intersect less lines, resulting in fewer stipples

• Ideally

- For i=0, the surface would be completely covered.

- For i=0.5, the surface would be half covered.

- For i=1, there would be no dots.

Page 7: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 7

Page 8: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 8

1.1.1. Algorithm

1. Convert imput image into a piecewise function I: [0,1] [0,1] [0,1] by scaling

2. Generate a distribution of lines in R3

3. Intersect each line with the surface defined by I and record the projection of the intersection point onto the base plane

4. Display intersection points as stipples

Page 9: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 9

1.1.2. Distributions

• should be defined on the unit cube [0,1] [0,1] [0,1]

The first two coordinates describe the position of the line in the plane and the third coordinate describes the line’s height. This means that the target image has to be scaled.

• Requirements for the final distribution of stipples:

- linear intensity response

- no overlapping stipples

- no visual patterns

Page 10: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 10

1.1.3. Vertical Lines Distributions

• uniform random distribution

- most simple variant

- uniform random distribution of position and heights

Courtesy of Adrian Secord

Page 11: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 11

• Sobol Distribution

- quasi random distribution

- gradually fills the entire area at finer and finer resolutions

- filling is non-deterministic but “ordered”

Courtesy of Adrian Secord

Page 12: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 12

• Osculating distribution

“perfect distribution” by completely covering the plane with stipples

assume each stipple has a radius r – pack disks as close as possible and use the centers of these disks as bases for the vertical lines

Courtesy of Adrian Secord

Page 13: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 13

1.1.4. Non-Linear Intensity Response

• biggest problem with automatic stippling

• compensation needed

• map input intensities to corrected intensities

- render stipple images for discrete intensity levels ik- compute for these average output intensities ok

- corrected intensity ik/ok will produce ik when rendered

- Instead of using ik, use ik/ok for stippling

Page 14: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 14

uncorrected corrected

Courtesy of Adrian Secord

Page 15: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 15

Courtesy of Adrian Secord

Page 16: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 16

1.2. Modifying the Distribution of Points

• want to approximate

a given gray scale image S

by a descrete, dot-based representation D,

that enables halftoning

and fullfills additional geometric constraints.

• more formally:

A two-dimensional intensity function S(x,y) (the input image) is to be approximated by D(x,y)=D(x,y,j) which consists of n discrete elements j (the dots or stipples).

Page 17: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 17

• Let CI,j be the observable quantities of the input image at position j

As an example, this could be the intensity value or a gradient value.

• Let CD,j the same quantities of the desired output D(x,y,j) which are computed differently since D is a discrete representation (only dots).

• find a representation which approximates the tonal values of S and fulfills geometric constraints by minimizing the penalty

n

jgjDj jEwjEv

nE

1

)()(1 ED(j) – approximation error of the

discrete representation at

position j

Eg(j) – geometric error at position j

vj, wj – weights

1.2.1. Formal Problem Description

Page 18: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 18

• obtain value for ED(j) as difference between input and output

• dots should be spread out evenly

geometric error depends on dot distribution

variance of the dot-to-dot-distances

• ED(j) and Eg(j) continuously differentiable E can be minimized globally using optimization methods

2,,)( jDjID CCjE

2

1

1)(

jn

ijii

j

g ppln

jEli – mean value of dot-to-dot-distances in

the neighborhood of the element n

nj – number of elements in that

neighborhood

pj – element whose neighborhood is

currently considered

pi – any other element in this neighborhood

Page 19: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 19

1.2.2. Algorithmic Appraoch

• Idea: minimization of Eg(j) using an iterative scheme

• Given n dots pj in a region:

1. Compute Voronoi diagram of the dots

2. Intersect Voronoi regions with the bounds of the region to be stippled

3. Move each dot to the center of mass of its Voronoi region

Voronoi diagram and resulting Delaunay triangulation of a point set.

Page 20: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 20

• iterative algorithm to generate a Centroidal Voronoi Diagram (CVD) from any set of generating points

• CVD has interesting property: each generating point lies exactly on the centroid of its Voronoi region

• CVD is minimum-energy configuration in the sense that it minimizes the mean squared distance from the points to the centroids

→ points are well-spaced in a definite sense

A

Ai

dAx

dAxx

C)(

)(

1.2.2.1. Lloyd’s Method

A – region

x – position

ρ(x) – density function

Page 21: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 21

1 while points xi not converged to centroids do

2 compute Voronoi diagram of xi3 compute centroids ci of the Voronoi regions

4 move each point xi to the resp. centroid ci5 od

Voronoi iteration: (a) initial point set (200 points) with ist Voronoi diagram, (b) result after 20 iterations – nearly a CVD.Courtesy of Stefan Hiller

Page 22: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 22

• Lloyd’s method produces an acceptable distribution and is known to converge in most cases

• distribution should be depending on the intensity of a given gray value image → Weighted CVDs

• use density function ρ to account for image intensity

- treat image as a 2D function f(x,y) where x,y [0,1] and

0 ≤ f(x, y) ≤ 1

- if 0 black and 1 white, then: ρ(x,y) = f(x,y)

- if 1 black and 0 white, then: ρ(x,y) = 1 - f(x,y)

Page 23: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 23

Page 24: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 24

1.2.2.2. Interaction

• small regions

• similar to brushes in paint programs

• function only affects the “footprint” area of the brush

selection brush – identify larger regions

relaxation brush – perform local relaxation process

jitter brush – perform jittering of the dots

shape brush – modify shape and size of the dots

Page 25: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 25

Courtesy of Stefan Hiller

Page 26: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 26

Stipple Rendering

Courtesy of Stefan Hiller

Page 27: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 27

Courtesy of Stefan Hiller

Page 28: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 28

Courtesy of Stefan Hiller

Page 29: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 29

1.3. Beyond Stippling

• So far: distribution of dots

• now: distributing arbitrary shapes

• extension to Lloyd’s Method with the potential to solve the new problems that arise:

- incorporate shape of the object to be placed

- also change orientation in addition to position of the object

Page 30: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 30

• Lloyd’s Method for Lines and Polygons in general similar to the original algorithm

• A relaxation scheme based on Lloyd’s method can be applied to any objects provided that their Voronoi diagram can be computed

- compute centroid of a Voronoi region

- compute centroid of an object

- compute main inertia axes and rotation angle

somewhat more complicated

see the original publicationStefan Hiller, Heino Hellwig, and Oliver Deussen. “Beyond Stippling - Methods for Distributing Objects on the Plane”. In Pere Brunet and Dieter W. Fellner, editors, Proceedings of Eurographics 2003, pages 515-522, Oxford, 2003. The Eurographics Association, Blackwell Publishers.

Page 31: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 31

1 determine centroids and main inertia axes of

all objects qi2 repeat

3 determine Voronoi regions vi of the qi4 for all regions vi do

5 calculate the centroid ci of vi6 move centroid of qi to ci7 adapt the angle of the object’s main

axis according to an angle fi8 od

5 until convergence

• Input for algorithm: a set of objects qi on the plane and a density function ρ (the image)

Page 32: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 32

Stefan Hiller, Heino Hellwig, and Oliver Deussen. “Beyond Stippling - Methods for Distributing Objects on the Plane”. In Pere Brunet and Dieter W.

Fellner, editors, Proceedings of Eurographics 2003, pages 515-522, Oxford, 2003. The Eurographics Association, Blackwell Publishers.

Page 33: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 33

1.4. 3D Surface Stippling

• image-based approaches to stippling provide interactive and automatic ways to produce stipple renderings

• focus on producing single images (with high quality)

• What about animation?

- Maintaining even distribution of the dots while

viewpoint

illumination

viewing distance

geometry

may change

- obtain frame-coherent animations

Page 34: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 34

• Requirements:

- stipples should behave like a texture on the surface of the model

- stipple density should smoothly adapt to changes in illumination

- stipples blend in and out of the image by means of change in point size

- keep appropriate spacing of stipples

- avoid formation of regular patterns or grouping

Page 35: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 35

1.4.1. Point Hierarchies

• defining a point hierarchy that is fixed to the surface of the model

• each model’s vertex is considered to be a potential stipple location

• stipples move with the model → frame coherence

• adapt to changes in shading, scale and viewing distance

by using mesh simplification and mesh subdivision

Page 36: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 36

• stipples on level i+1 in the hierarchy are positioned roughly in the middle between two stipple on level i in the hierarchy

• associate stipples with vertices in a “parallel” vertex hierarchy that is established using simplification and subdivision algorithms

Page 37: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 37

• when rendering

- apply simplification or subdivision to the model

subdivision when the number of vertices (stipples) is too small to cover dark areas

simplification in the opposite case when there are too many vertices (stipples) for a bright area

- traverse the point hierarchy

- decide which stipples to draw and which size they have

- stipple size as function of lighting, viewing angle, target darkness and viewport size

Page 38: Non-Photorealistic Computer Graphicsstefans/slides/05a-Stippling.pdf · Non-Photorealistic Computer Graphics Chapter 5: Stippling and Hatching Part I _ University of Magdeburg _ Stippling

__ University of Magdeburg

Stippling and Hatching 38

1.4.2. Examples