PV227 GPU Rendering Marek Vinkler Department of Computer Graphics and Design PV227 GPU Rendering 1 / 14 DevIL library for working with images, simplifies loading textures to OpenGL, download built SDK at http://openil.sourceforge.net/ (http://downloads.sourceforge.net/openil/ DevIL-SDK-x86-1.7.8.zip). PV227 GPU Rendering 2 / 14 DevIL (cont.) update VC++ Directories (taken care of ;-)), pass data from DevIL to OpenGL. PV227 GPU Rendering 3 / 14 Image Processing image effects applied to a texture, may be used as post-process on the framebuffer, gray scale, negative, thresholding, blurring, general convolution. PV227 GPU Rendering 4 / 14 Texture Setup same way as in fixed OpenGL, texture unit ID passed to the sampler in the shader, rendered using two triangles (quad), camera setup so that only the quad is seen. Figure: Rendered texture PV227 GPU Rendering 5 / 14 Gray Scale Figure: Taken from wikimedia.org linear combination of the RGB channels into luma (intensity), texel is multiplied component-wise (dot product) with the weights. PV227 GPU Rendering 6 / 14 Gray scale (cont.) several options for choosing the weights, NTSC weights: 0.299, 0.587, 0.114. Figure: Grayscale PV227 GPU Rendering 7 / 14 Negative inversion of each color channel, alpha channel should not be inverted. Figure: Negative PV227 GPU Rendering 8 / 14 Thresholding usually applied to gray scale images, assigns white to pixels above threshold, black otherwise. Figure: Thresholding PV227 GPU Rendering 9 / 14 Blurring averaging of the image, the amount of blur depends on the kernel size, blur type is controlled by the blurring weights, the weights must sum to 1. Figure: Gaussian 5x5 blur PV227 GPU Rendering 10 / 14 Convolution Figure: Taken from illinois.edu used to compute any linear filter, (f ∗ g)(t) ≡ ∞ −∞ f(τ)g(t − τ)dτ, (f ∗ g)(t) ≡ ∞ −∞ f(τ)g(t − τ). PV227 GPU Rendering 11 / 14 Sharpening inverse of blurring (subtraction of neighbourhood), the amount of sharpening depends on the kernel size, sharpen type is controlled by the convolution weights, the weights must sum to 1. Figure: Sharpening 3x3 PV227 GPU Rendering 12 / 14 Edge Detection detects changes in intensity, preferably blur the image before edge detection, detection type is controlled by the convolution kernel, the weights must sum to 0. Figure: Laplacian edge detection PV227 GPU Rendering 13 / 14 More PV131: Digital Image Processing, PA166: Advanced Methods of Digital Image Processing, PA170: Digital Geometry, PA171: Digital filtering, PA172: Image Acquisition Principles, PA173: Mathematical Morphology, . . . PV227 GPU Rendering 14 / 14