OpenCL Heterogeneous Parallel Program For Gaussian Filter
OpenCL Heterogeneous Parallel Program For Gaussian Filter
Pi19404
February 22, 2013
Contents
Contents
OpenCL Image Convolution-Seperable Filters Gaussian Filters 3
0.1 Introduction . . . . . . . . . . . . . . . . . 0.2 Gaussian Filters . . . . . . . . . . . . . . . 0.3 Parallel Implementation . . . . . . . . . . 0.4 Comparison with CPU implementations 0.5 Using the code . . . . . . . . . . . . . . . 0.6 Points of Interest . . . . . . . . . . . . . 0.7 License . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
. . . . . . . .
3 3 5 5 6 7 7 8
2 | 8
G(x; y ) =
2
x2 +y2 e 22
(1)
x is the distance from the origin on the horizontal axis,y is the distance from the origint on the vertical axis and is the standard distribution than quantifies the spread of the gaussian distribution. Convolution is a neighborhood operations where the central pixel is assigned a values which is weighted sum of its neighborhood pixels. The gaussian function never goes to zero.Thus the kernel is infinately large Thus we would need to consider entire image as neighborhood to compute the discrete convolution at a point. Generally pixels at location 3 further from the origin are small and can be considered to be zero . Thus we have a finite kernel in the range of (3; 3 ). This is still a continuous distribution.The discrete approximation of gaussian function is constructed by sampling the values from continuous distribution.
3 | 8
To perform the discrete approximation we require two parameters the size of kernel n and the standard deviations If n is the size of the kernel the center or mean of kernel is (n 1)=2 We calculate the values taken by the gaussian kernel at integral location. The number of integral locations to compute depends on the size of kernel . Consider a 1D gaussian kernel N - size of kernel
G(x) =
2
xfloor(N=2)2 2 2 e
floor(N=2) : : : 0 : : : floor(N=2)
Gaussian Kernels are seperable kernels Let G(x) be the row kernel and G(y) be the column kernel G(x) and G(y) can have different standard deviations we use the normalization method to scale the values so that sum of kernel coefficient is 1
G(x; y ) =
G(x;y) min(G(x;y)
G(x; y ) = 42
1
2 4 2
1 2 1
5
(2)
Using a similar approach the kernel approximations for kernels with different configurations can be obtained. We can use the kernel directly or a discrete approximation of kernel.
4 | 8
OpenCL Image Convolution-Seperable Filters Gaussian Filters In the present application we will use a discrete approximation to the kernel. After computing the kernel all the kernel values are scaled by normalization factor to make the sum of values equal to 1. For larger kernel sizes the values of kernel at at distances greater than 3 from the center or mean are set to zero if we observe the area under the gaussian distribution curve values at distances greater than 3 are almost zero.
5 | 8
This class
1. Methods for calling OpenCL initialization routines. 2. Methods for writing and reading to OpenCL compliant device memory. 3. Methods for setting the arguments of kernel code and calling the kernel code. main.cpp - This is main program file The input to the program is a video files.This is choosen so that average running time of OpenCL code,OpenCL with various configuration can be compared over a period of time It creater OCLX class objects.Calls the initialization routine. Then create and compiles the kernel passing the build time options which consists of user defines for various static parameters used by the kernel code. The program call the Parallel OpenCL code and OpenCV code and displays the average time required for execution for both the modules on the standard output. The output of image processing of both the routine are also displayed in seperate windows for comparion Code is available in repository https://github.com/pi19404/m19404/ tree/master/OpenCL-Image-Processing/Convolution
6 | 8
0.7 License
The Article and Software is subjected to Apache License, Version 2.0 or higher
7 | 8
Bibliography
Bibliography
[1] [2] [3] [4] [5]
uic.edu/kreda/gpu/image-convolution/. html.
Image Convolution Filter.
url: http://www.evl.
url: http://www.khronos.org/opencl/.
html.
url: http://www.shervinemami.info/colorConversion.
//www.dspguide.com/ch24/3.htm.
url: http :
8 | 8