Image Processing Slide Set 7 07 Image Processing

  • Slides: 9
Download presentation
Image Processing Slide Set 7. 07

Image Processing Slide Set 7. 07

Image Processing • We can do more than paint images onto surfaces: we can

Image Processing • We can do more than paint images onto surfaces: we can harness the power of the GPU to modify images on a pixel by pixel basis • Some of the effects are applied on individual pixels • Other effects use multiple pixels close to each other to derive the value of a single pixel • We’ll refer to these effects as filters • Typically implemented by applying mathematical operations to the color vectors 2

Example Organization • The image processing example uses the render to texture example as

Example Organization • The image processing example uses the render to texture example as a basis • The ‘view in view’ covers the whole window now and the objects are not rendered directly to the window • Processing is carried out by sampling the texture and processing samples before setting the output fragment color 3

Filters for Individual Pixels • A filter applied to an individual pixel takes a

Filters for Individual Pixels • A filter applied to an individual pixel takes a single sample from the texture and manipulates that • Examples • Select a single color channel • Monochrome • Coded brightness • A simple brightness formula: • Luminance = 0. 2126 * R + 0. 7152 * G + 0. 0722 * B 4

Multi-Pixel Filters • Smoothing • Averages pixels in a neighborhood • Smooths out roughness

Multi-Pixel Filters • Smoothing • Averages pixels in a neighborhood • Smooths out roughness • Removes detail • Derivatives • Can be used for edge detection • Uses differences between close pixels • Our example will display a gray scale image result 5

Getting Nearby Pixels • The coordinates of a texture range from 0 to 1

Getting Nearby Pixels • The coordinates of a texture range from 0 to 1 in each axis • To get to the next pixel row we must use 1 / height • height is the number of rows in the texture • To get the next column use 1 / width 6

Smoothing • • • Useful in a picture with ‘noise’ Or if you want

Smoothing • • • Useful in a picture with ‘noise’ Or if you want to ‘fuzz’ the image A discrete version of integration Recipe: add up nearby sample colors and divide Two versions • Four nearby pixels • Many, using nested loops 7

Derivatives • Because the texture is two dimensional, there are derivatives for each coordinate

Derivatives • Because the texture is two dimensional, there are derivatives for each coordinate direction • We will use the Sobel operator that seems to visualize edges nicely • At an edge, the color changes rapidly which means the derivative is larger • We are approximating the gradient which is a vector form of the derivative: it points in the direction of change • We will use the length of the gradient to create a monochrome image 8

Size of Target Texture • Changing the size of the texture used in the

Size of Target Texture • Changing the size of the texture used in the framebuffer has a strong effect on the result • 64 x 64 is very pixelated • 128 x 128 is closer to the actual scene but still has visual anomalies • 2048 x 2048 looks like the actual scene 9