Docsity

Image Processing: Techniques, Algorithms, and Tools - Prof. Juraj Obert, Papers of Computer Graphics

Partial preview of the text

Download Image Processing: Techniques, Algorithms, and Tools - Prof. Juraj Obert and more Papers Computer Graphics in PDF only on Docsity!

10/23/2008 1

Juraj Obert

[email protected]

http://graphics.cs.ucf.edu/cap4720/fall2008/

Image Processing

 Techniques, algorithms, tools to perform

image operations without explicit

knowledge of underlying geometry

 All previous rendering tasks dealt with

geometry information

 Per-vertex lighting

 Shadow maps

10/23/2008 3

Typical operations

 Color correction

 HSV, CMYK corrections

 Gamma correction

 Artistic effects

 Blur

 Edge detection

 All Photoshop filters (Emboss, Noise, etc.)

 Advanced effects

 HDR (High Dynamic Range) rendering

 Screen-space ambient occlusion

 requires implicit geometry information

 Bilateral upsampling

 smart edge-preserving upsampling method

Examples

Original Gaussian blur, kernel 10

10/23/2008 7

Examples

Original Photoshop Water Paper

Convolution revisited

  • Convolution describes how a system with impulse

response, h(x), reacts to a signal, f(x).

  • Discrete case in 1D
  • Discrete case in 2D

โˆž

โˆ’โˆž

f ( x )* h ( x )= f (ฮป ) h ( x โˆ’ฮป) d ฮป

f [ i ]* h [ i ] f [ n ] h [ i n ]

n

โˆž

=โˆ’โˆž

โˆž

=โˆ’โˆž

โˆž

=โˆ’โˆž

n m

f [ i , j ]* h [ i , j ] f [ n , m ] h [ i n , j m ]

10/23/2008 9

Kernels

Box kernel

wi j otherwise

W W

iffij W

wi j

2

Tent kernel

wi j otherwise

wi j i j iffi j

Kernels

Spline kernel

() ( 2 ) ( 1 , 2 ]

() ( 1 ) ( 0 , 1 ]

() ( 1 ) ( 1 , 0 ]

() ( 2 ) ( 2 , 1 ]

3 2 1

3 0

3

3 0

3 1

3 1

3 0

b t t b t t t t

B t otherwise

B t b t iff t

B t b t iff t

B t b t iff t

B t b t iff t

10/23/2008 13

Rendering algorithm

 Pass 1:

 setRenderTarget(target0);

 Clear(white);

 Render(scene);

 Pass 2:

 setRenderTarget(frameBuffer);

 Clear(white);

 setTexture(target0.texture);

 setShader(postProcessingShader);

 Render(quad);

Rendering clip-space geometry

 So far, all geometry we submitted to GPU was specified in

object space

 We had to transform everything to clip space in a vertex

shader, because rasterizer needs clip-space positions

 For image processing:

 We need to shade a specified portion of the screen (usually the whole screen)

 How do we specify object-space positions so that their clip-

space equivalents cover the entire screen?

 Answer : We donโ€™t. We use clip-space positions from the beginning

10/23/2008 15

Object-space to clip-space

transformations

(-1,17, 2.5)

Object space

(0.0, -0.4)

Clip space

(-1.0, -1.0)

(1.0, 1.0)

gl_Position = gl_ProjectionMatrix * gl_ModelViewMatrix * gl_Vertex;

Object-space to clip-space

transformations

(0.0, -0.4)

Clip space

(0.0, -0.4)

Clip space

(-1.0, -1.0)

(1.0, 1.0)

gl_Position = vec4(gl_Vertex.xy, 1.0, 1.0);

(-1.0, -1.0)

(1.0, 1.0)

10/23/2008 19

Convolution shader template

uniform float texelX;

uniform float texelY;

uniform sampler2D sampler0; varying vec2 positionTextureSpace;

const float boxKernel[9] = { 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11 };

void main() {

vec4 result = vec4(0.0, 0.0, 0.0, 0.0);

float i = 0; float j = 0;

float k = 0;

for (i = -1.0; i <= 1.0; i += 1.0)

for (j = -1.0; j <= 1.0; j += 1.0, k += 1.0) result += vec4(boxKernel[k] *

tex2D(sampler0, positionTextureSpace + vec2(i, j)*vec2(texelX, texelY)).rgb, 0.0);

gl_FragColor = result; }

Next class

 More per-fragment techniques

 HSV, filters (edge detection, โ€ฆ.)

 Stencil buffers