#
Fast 2D Separable Symmetric/Anti-Symmetric Convolution

#### Introduction

In the article we will look at algorithm for Fast 2D Convolution.#### Separable Symmetric/Anti-Symmetric Convolution

- This article presents a convolution algorithm involving a separable symmetric/anti symmetric kernel.
- Such kernels are common in image processing like blurring,edge detection etc
- This optimization helps in speeding up many routines .
- Another requirement being addressed is we may have multiple kernels that need to be applied to the same image in application such as computing the basis representation of rectangular path of the image.
- since we are traversing the image,we can perform computation of all these kernels simultaneously instead of independent traversals.
- It is to be noted that this optimization is specific to symmetric/antisymmetric separable filters.
- We will be assuming that all the kernel are of the same size as well
- Since kernels are separable we will perform vertical convolution followed by horizontal convolution.
- One of the considerations is to minimize the row accesses .
- Another consideration is to perform a single pass over the entire source image
- Let $n*2+1$ be the kernel size.
- The convolution filter is initialized by accepting all the row and column filter coefficients as well as the information if the filter is symmetric or not
- A class called SeperableSConvolution implemented this algorithm
#### Vertical Convolution

- First vertical convolution is considered
- If kernel size is $2N+1$ ,we need to access same number of rows
- This if we are applying the filter at row j,we need to access elements from rows from $j-k$ to $j+k$ where $k \in 0..N$ \begin{eqnarray} dst(x,y) = \sum_{i,k=-N}^{k=N} g(k+N)I(x,y+k) \end{eqnarray}
- The above needs to be processed for each $(x,y)$
- Since we need to reduce the number of row access,access rows from $j-N,j+N$ are performed for each j,compute the convolution for each x.
- Since with change in x no new rows are being accessed,hence we compute convolution for each element of the present row.
- Each of the rows need to be multiplied with suitable filter coefficients.
- since the filter is symmetric or anti symmetric the filter coefficients $g_k$ is multiplied with elements of rows $j-k$ and $j+k$
- The resultant sum of accumulated,this is performed for all the rows.
#### Horizontal Convolution

- Once vertical convolution is done we proceed to perform horizontal convolution
- Since in horizontal convolution there is only a single row access ,it is relatively simple process.
- The output image is a multi channel image,containing number of channels as desired
number of input kernels being applied to the source image.
#### Code

- The class SeperableSConvolution defines a class for performing separable symmetric/ant-symmetric convolution/ Code is available in repository https://github.com/pi19404/OpenVision/ at Improper/convolution.hpp and ImgProc/convolution.cpp files.

**The PDF version of the article can be found below**