PV227 GPU programming Marek Vinkler Department of Computer Graphics and Design PV227 GPU programming 1 / 14 DevIL library for working with images, simplifies loading textures to OpenGL, download built SDK at http://openil.sourceforge.net/. PV227 GPU programming 2 / 14 DevIL update VC++ Directories (taken care of ;-)), pass data from DevIL to OpenGL. PV227 GPU programming 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 programming 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 programming 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 programming 6 / 14 Gray scale several options for choosing the weights, NTSC weights: 0.299, 0.587, 0.114. Figure: Grayscale PV227 GPU programming 7 / 14 Negative inversion of each color channel, alpha channel should not be inverted. Figure: Negative PV227 GPU programming 8 / 14 Thresholding usually applied to gray scale images, assigns white to pixels above threshold, black otherwise. Figure: Thresholding PV227 GPU programming 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 programming 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 programming 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 programming 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 programming 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 programming 14 / 14