Here we discuss how each of the filters is implemented. Similar filters are discussed together. Mean and Gaussian filters are imposed by convoluting with a fixed 3 x 3 matrix.
In our OpenCL implementation of the Mean and Gaussian filters, we write a kernel called filter_kernel
that can be used for the two filters. We do this by configuring the third argument filter
so that it can create effects of the corresponding filter. For the Mean filter we send a nine element array, where each element's value is 1/9
and when this is convoluted with the corresponding window, it produces the effect of mean of that window. When the filter_kernel
kernel is to be called for the Gaussian filter, we pass corresponding coefficients in row major form (1/16, 2/16, 1/16, 2/16, 4/16, 2/16, 1/16, 2/16, 1/16)
.
So we explain these two filters together. The following code is the common kernel code for these two filters:
__constant sampler_t image_sampler = CLK_NORMALIZED_COORDS_FALSE...