<html>
<head>
<title>
Texture Synthesis
</title>
</head>
<body>

<h2>
Texture Synthesis
</h2>

<blockquote>
CS 348B - Computer Graphics: Image Synthesis Techniques
<br>
Spring Quarter, 1997
<br>
(TA)  Lucas Pereira
<br>
Lecture notes for Tuesday, April 29
<br>
Handout #20
<br>
</blockquote>

<hr>
<h2>
Texture Synthesis
</h2>

<h3> Contents: </h3>
<ul>
<li> Review: Texture framework
<li> Types of Texture
	<ul>
	<li> Scanned Texture
	<li> Synthesized Texture
	</ul>
<li> To Store or Compute?
<li> Perlin's Image Synthesizer ('85)
<li> Worley's Cellular Texture Basis Function ('96)
<li> Heeger's Pyramid-Based Texture Analysis/Synthesis ('95)
<li> Turk's Reaction-Diffusion ('91)
<li> Dorsey's Flow and Changes in Appearance ('96)
<li> Fleischer's Cellular Texture ('95)
</ul>



<h3>
Review:  Texture framework
</h3>
<ul>
<li> What is Texture?
	<ul>
	<li> color (Primary focus today)
	<li> normal (bump map)
	<li> position (displacement map)
	<li> shininess
	<li> transparency
	<li> micro-geometry (such as Fleischer, below)
	<li> ...
	</ul>

<li> How is it parameterized?
	<ul>
	<li> 2D
	<li> 3D
	<li> 4D (view-dependent texture -- similar to a lumigraph, or
		 a geometry-corrected light field)
	<li> 5D (volumetric view-dependent texture)
	<li> 6D (spatially varying BRDF)
	<li> Additional dimensions:
		<ul>
		<li> time
		<li> wavelength
		</ul>
	</ul>
<li> Mapping to the surface
	<ul>
	<li> 2D: parameterize (warp) onto the surface
	<li> 3D: No warp, surface cuts through 3D volume
	</ul>
</ul>


<h3>
Types of Texture:
</h3>
<ul>
<li> Scanned Texture
	<ul>
	<li> From real life
	<li> Sampled, stored, resampled
	</ul>

<li> Synthesized Texture  (Today's topic)
	<ul>
	<li> Equation-based
		<ul>
		<li> f(u,v) or f(x,y,z)<br>
			e.g. linear ramp, checkerboard, boolean functions,
			polynomials, sine waves, ...
		</ul>
	<li> Random
		<ul>
		<li> Fractal<br>
		<img src="tex_fractal1.gif">


		<li> Perlin ('85)
		<li> Worley ('96)
		<li> ...
		</ul>
	<li> Statistics-based
		<ul>
		<li> Heeger ('95)
		<li> ...
		</ul>
	<li> Procedure-based (Simulation-based)
		<ul>
		<li> Reaction-Diffusion (Turk '91)
		<li> Cellular Texture Generation (Fleischer '95)
		<li> Flow (Dorsey '96)
		</ul>
	</ul>
</ul>

<h3>
Store or Compute?
</h3>
<ul>
<li> Compute on the Fly
	<ul>
	<li> Compute function for every sample
	<li> Very little memory
	<li> Need to have consistent mapping <br>
		(If random, need to use same random seed each time)
	</ul>
<li> Intermediate Storage
	<ul>
	<li> Resampling issues
	<li> Lots of memory?
		<ul>
		<li> One-time generation cost -- can be expensive
			<ul>
			<li> Reaction Diffusion
			<li> Heeger
			<li> Multi-step algorithms (my crystal)
			</ul>
		<li> Tiling
			<ul>
			<li> Can save memory
			<li> Can introduce visible repetition
			</ul>
		</ul>
	</ul>
</ul>

<h3>
In-Depth Examples:
</h3>


<h3>
An Image Synthesizer <br>
Ken Perlin <br>
Siggraph 1985
</h3>
<ul)
<li> PSE: "Pixel Stream Editor"
	<ul>
	<li> Inspired by Cook's Shade Trees (Siggraph '84)
	<li> High-level language for describing shading function
	     at each pixel
	<li> Input variables: surface, point, normal, etc.
	<li> Stochastic functions: Noise, DNoise, Turbulence ...
		<ul>
		<li> Defined over 3D space
		<li> Noise: narrow band of frequencies
			<ul>
			<li> eg:  grid, each lattice-point with random number
			<li> Tri-linearly interpolate between points
			</ul>
		<img src="tex_1dnoise.gif">
		<li> DNoise: vector gradient of Noise
		<li> Turbulence: wide range of frequencies
			<ul>
			<li> <pre>
	function turbulence(p)
		t=0
		scale=1
		while (scale > pixelsize)
			t+= abs(Noise(p/scale)*scale)
			scale /= 2
		return t
			</pre>
			<li> definition self-similar (fractal)
			<li> abs causes discontinuous boundaries at all scales
			</ul>
			<img src="tex_1dturbulence.gif">
		</ul>
	</ul>	
<li> Example:<pre>
	color = white * Noise(point)
	</pre>

<li> Fancier example: <pre>
	function boring_marble(point)
		x = point[1]
		return marble_color(sin(x))
	</pre>

<li> Even fancier example: (EFE) <pre>
	function marble(point)
		x = point[1] + turbulence(point)
		return marble_color(sin(x))
	</pre>
	<ul>
	<img src="tex_marble.gif">
	<li> This used for his marble vase
	</ul>
</ul>

<h3>
A Cellular Texture Basis Function<br>
Steven Worley<br>
Siggraph 1996
</h3>
<ul>
<li> Similar to Perlin, except adds new functions:
	<ul>
	<li> distributes pseudo-random points through space
	<li> F<sub>1</sub> = distance to closest point
		<ul> 
		<li> slope discontinuity equivalent to Voronoi diagram 
		</ul> 
	<li> F<sub>2</sub> = distance to 2nd closest point
	<li> F<sub>3</sub> = distance to 3rd closest ...
	</ul>
<li> can do polka-dots, flagstone ....
<li> fractal version (multiple levels of resolution, like Perlin)
     can have detail at a wide range of scales
</ul>

<h3>
Pyramid-Based Texture Analysis/Synthesis<br>
David Heeger & James Bergen<br>
Siggraph 1995
</h3>
<ul>
<li> mainly 2D, non-directional 3D
<li> Builds statistics about a given texture (often scanned)
<li> Manipulates noise image to have same statistics
	<ul>
	<li> Histograms of frequency content for each direction,
		frequency band
	</ul>
<li> Why create new texture?
	<ul>
	<li> Can be arbitrarily large
	<li> Can be seamlessly tileable
	<li> Works well for noisy textures with non-distinguishable
	     features.
	<li> Fails for distinguishable features, and correlation of
	     high frequency over long distances, such as edges
	</ul>
<li> Steerable filters
	<ul>
	<li> A convolution kernel that picks up a certain frequency band
	     in a certain direction
	</ul>
<li> Analyzing phase
	<ul>
	<li> We filter original image with a bank of these steerable
	     filters, getting a pyramid of images of each frequency/direction
	<li> We build histograms of pixel intensities in each image
	</ul>
<li> Histogram-matching phase
	<ul>
	<li> We filter noise image with the same bank of these steerable
	     filters, getting a pyramid of images of each frequency/direction
	<li> We build histograms of pixel intensities in each image
	<li> Compute a scaling function of pixel values for each of the
	     images in the noise pyramid, so that it has the same
	     histogram as corresponding source pyramid image <br>
	<img src="tex_histomatch.gif">
	
	<li> Collapse noise pyramid
		<ul> 
		<li> filters not entirely indepent
		<li> This alters histograms
		</ul>
	<li> repeat Analyze-Match about 5 times
	</ul>
</ul>

<h3>
Generating Textures on Arbitrary Surfaces Using Reaction-Diffusion <br>
Greg Turk <br>
Siggraph 1991
</h3>

<ul>
<li> Simulates the interaction of 2 (or more) chemicals <br>
	They interact until they form a stable state
<li> Similar to how the embryo of a worm forms segments
<li> da/dt = F(a,b) + D<sub>a</sub> * Grad(a)^2
<li> db/dt = G(a,b) + D<sub>b</sub> * Grad(b)^2
	<ul>
	<li> G(a,b) is the reaction between chemicals a, b
	<li> D<sub>b</sub> is the diffusion constant for b
	<li> Grad(b)^2 is local gradient of b's concentration,
		which affects its diffusion speed
	</ul>
<li> Map chemical concentrations to a texture (color, bump, etc)
</ul>


<h3>
Flow and Changes in Appearance <br>
Julie Dorsey et. al. <br>
Siggraph 1996
</h3>
<ul>
<li> 2D
<li> Simulate water flow as a particle system
	<ul>
	<li> factors: gravity, friction, wind, roughness ...
	<li> parameters: 
		<ul>
		<li> rendering:  diffuse color, specular color, shininess
		<li> simulation: roughness, absorption, absorptivity
		<li> deposits: diffuse color, adhesion rate, solubility rate
		</ul>
	</ul>
<li> Rendering: Deposits alpha blended over surface
</ul>


<h3>
Cellular Texture Generation <br>
Kurt W Fleischer et. al. <br>
Siggraph 1995
</h3>
<ul>
<li> 2D
<li> Cellular particle simulator
	<ul>
	<li> Uses differential equations to place the cells
	<li> Constraints specified as energy functions to be minimized, e.g.:
		<ul>
		<li> Go to the object surface
		<li> Die if too far from surface
		<li> Align an axis with a vector field
		<li> Adhere to other cells
		<li> Divide until surface is covered
		<li> Set size relative to surface feature size
		<li> Reaction-diffusion
		</ul>

	</ul>
<li> Parameterized particle-to-geometry converter
	<ul>
	<li> Converts cell parameters to tiny textured polygons
	</ul>
<li> Rendered  -- lots of polygons
</ul>


<hr>	

<address>
lucasp@graphics.stanford.edu
</address>
<b>Copyright &copy; 1997 Lucas Pereira</b>
<br>
Last update:
Tuesday, 29-Apr-97 05:00:00 PDT

</body>
</html>


	
