Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

57
Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Transcript of Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Page 1: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Simulating Decorative Mosaics

Alejo HausnerUniversity of Toronto[SIGGRAPH2001]

Page 2: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

2

Mosaic Tile Simulation

• Reproduce mosaic tilings– long-lasting (graphics is ephemeral)– realism with very few pixels– pixels have orientation

Page 3: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

3

Real Tile Mosaics

Page 4: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

4

Real Mosaics II

Page 5: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

5

The Problem

• Square tiles cover the plane perfectly

• Variable orientation loose packing

• Opposing goals:– non-uniform grid– dense packing

Page 6: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

6

Formal Statement

• Given a rectangular region I2 in the plane R2, and a vector field (x, y) defined on that region, find N sites Pi(xi, yi) in I2 and place N squares of side s, one at each Pi, oriented with sides approximately parallel to (xi, yi), such that all squares are disjoint and the area they cover is maximized.

Page 7: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

7

Previous Work

• Romans: algorithm?• Relaxation (Haeberli

90) – scatter points on

image– voronoi region = tile– tiles not square

Page 8: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

8

Previous Work

• Escherization (Kaplan 00) – regular tilings– use symmetry groups

• Stippling (Deussen 01)

– voronoi relaxation– round dots

Page 9: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

9

Voronoi Diagram

• What is it?– Input: sites (generators)– Result: regions closest to each site

Page 10: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

10

Voronoi Diagram

Page 11: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

11

Centroidal Voronoi Diagrams

• VD sites centroids• Lloyd’s alg. (k-

means):– 1: move site to

centroid– 2: recalculate VD– 3: repeat

Page 12: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

12

Centroidal Voronoi Diagrams

• VD sites centroids• Lloyd’s alg. (k-

means):– 1: move site to

centroid– 2: recalculate VD– 3: repeat

Page 13: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

13

Centroidal Voronoi Diagrams

• VD sites centroids• Lloyd’s alg. (k-

means):– 1: move site to

centroid– 2: recalculate VD– 3: repeat

Page 14: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

14

CVD After Convergence

Almost a hexagonal grid

Page 15: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

15

CVD properties

• Minimum-energy arrangements• In Nature:

– honeycombs– giraffe spots

• Point Sampling:– approximates Poisson-disk (low

discrepancy)– can bias for filter function

Page 16: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

16

Key Idea 1

• CVDs and Tilings– best circle packing = hexagonal tiling– Euclidean metric: CVD =“hexagonal”

tiling– different metric: CVD = ?

• Mosaics are Tilings– non-periodic– locally-varying orientation

Page 17: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

17

Key Idea 1(continued)

• Create “mosaic” metric– locally Manhattan (L1)

– locally varying orientation

• BUT:– existing algorithms limited– they assume Euclidean metric

– if L1 metric: they assume isotropic

Page 18: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

18

Hardware-assisted VD’s

• Hoff 99– uses graphics hardware– draw cone at each site– orthogonal view from

above– region color = cone color– can extend to non-point

sites (curves)

project

Page 19: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

19

Key idea 2

• Cone is distance function– radius = height

• Non-euclidean distance:– different kind of cone– eg square pyramid– can be non-isotropic

(rotate pyramid on Z axis)

r

h

h=|x-a|+|y-b|

(a,b)

(x,y)h

h2=(x-a)2+(y-b)2

(a,b)

(x,y)

Page 20: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

20

Basic Tiling Algorithm

• Compute orientation field (details later)

• initialize: random points on image– use pyramids to get oriented tiles

• use Lloyd’s method– spreads sites evenly

• draw oriented tile at each site

Page 21: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

21

Details

• Lloyd’s method:– to get Voronoi region centroids:

1: read back pixels (frame buffer) 2: get average (row,col) per colour 3: convert back to object coords.

– move sites to centroids– repeat until converged

Page 22: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

22

Algorithm

1. S<-list of random points on the image.2. repeat until converged:

a. for each p in S, place a square pyramid with apex at p.

b. rotate each pyramid about the z axis to align itwith the direction field (p).

c. render the pyramids with an orthogonal projectiononto the xy plane, producing a voronoi diagram.

d. compute the centroid of each voronoi region.e. move each p to the centroid of its voronoi region.

3. draw a tile centred at each p, oriented along .

Page 23: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

23

Lloyd Near Convergence

Manhattan metric(isotropic)

Page 24: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

24

Tile Orientations

• Artisan’s algorithm– draw region boundaries– line tiles up on boundaries– build concentric rows

• Tile orientations– emphasize boundary curves– near curve: must follow curve– far from curve: don’t care

Page 25: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

25

Orientation Field

• Vector Field (x,y) unit vector at each (x,y)– near a curve: = curve direction– far away: less curve influence

• Align tiles to – rotate Manhattan-metric pyramids– rotate square tiles

Page 26: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

26

Computing (x,y)

• Choose curves that need emphasis• get VD for curves (Hoff 99)

– draw generalized “cones”

• z(x,y) = eye distance = z-buffer(x,y)– z = distance from curve

• get gradient, normalize (x,y) = z |z|

Page 27: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

27

Generalized Cones

Page 28: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

28

Edge Discrimination

• Problem: Tiles on Curve same on both sides (mod 180o)– rotate tile 180o no change– Lloyd’s alg. ignores edges– result: tiles straddle curves

Page 29: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

29

Edge Discrimination

• Solution: use hardware– draw edge thick, different color– edge overwrites part of tile– centroids move away from edge– apply Lloyd’s alg.– leaves gap where edge was.

Page 30: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

30

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 31: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

31

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 32: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

32

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 33: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

33

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 34: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

34

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 35: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

35

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 36: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

36

Edge Discrimination

– Tiles on edge– new centroids– move sites– repeat Lloyd’s– gap created– repeat Lloyd’s– edge is clear

Page 37: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

37

Putting It All Together

Page 38: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Putting It All Together

Initial randomtiles

Page 39: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Putting It All Together

20 iterationsof Lloyd’s

Page 40: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Putting It All Together

Edges cleared

Page 41: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Putting It All Together

Final tiling

Page 42: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

42

Tile Attributes

• We have:– tile position, orientation

• Can also control:– size– aspect ratio– shape (round, square, diamond)– colour

Page 43: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

43

Colour

• Each tile colour – the tile’s centre point– average over all pixels

• Point samples work best for images with uniformly-coloured regions

• Area samples suit continuous-tone images

Page 44: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

44

Size

• h*w pixel image with n tiles, this yields tiles with sides of d = pixels. < 1 accounts for packing

inefficiencies due to variations in

• Smaller tiles for detail areaz= (|x-x0|+|y-y0|)

Page 45: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

45

Size

• Initial tile positions?– uniform slow convergence– rejection sampling

• An initial tile position will be accepted with probability (smin/s)2

– s = tile size

– smin = smallest tile size in the image

Page 46: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

46

Aspect Ratio

• Fine detail is needed when– near a curve– any places where the direction field

must be strongly emphasized

• z= |x-x0|+(1- )|y-y0|

Page 47: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Lybian Sibyl

Original Curves, regions, (x,y)

Page 48: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Size Variation

2000 equal-size tiles2000 variable-size tiles

Page 49: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Tiles Carry More Information

2000 PIXELS2000 TILES

Page 50: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

50

Other Effects: “Painterly”

Oval over-sizeoverlapping tiles

Page 51: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

51

Other Effects: Regions

Voronoi regionswith colorfrom image

Page 52: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

52

More Pictures

“ Second Story Sunlight” (Hopper 60)

Page 53: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

53

More Pictures

Stained-glassphotograph

Page 54: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

54

More Pictures

Photograph:Seal on Beach

Page 55: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

55

Summary

• Pack tiles on curvilinear grid– Low-energy particle arrangements

• Generalized CVD– Voronoi diagram for any metric– Use graphics hardware

Page 56: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

56

Further Work

• Reduce “grout”– final pass: adjust tile shapes

• currently don’t use adjacency info

• Paint strokes– textured tiles

Page 57: Simulating Decorative Mosaics Alejo Hausner University of Toronto [SIGGRAPH2001]

Decorative Mosaics SIGGRAPH 2001

57

Further Work

• User-defined – better tile orientations

• Tile shapes– higher moments: x2, xy, etc.

• Dithering– no regular grid