1.0K views

Uploaded by pi194043

Fast 2D Separable Symmetric/Anti-Symmmetric Convolution.Code available at code repository
https://github.com/pi19404/OpenVision

save

You are on page 1of 7

Pi19404

February 17, 2014

Contents

Contents

2D Seperable Symmetric/Anti-Symmmetric Convolution 3

0.1

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 0.1.1 Separable Symmetric/Anti-Symmetric 0.1.2 Vertical Convolution . . . . . . . . . . . . . 0.1.3 Horizontal Convolution . . . . . . . . . . . 0.1.4 Code . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . Convolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3 3 4 6 7

2 | 7

0.1 Introduction

In the article we will look at algorithm for Fast 2D 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

3 | 7

Let

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

class SeperableSConvolution { public: SeperableSConvolution(); vector<Mat> rowk;//vector of row filter vector<Mat> colk;//vector of column filters vector<bool> symmetric; //info if filter is symmetric or not int N;//number of channels in the output image //function to set the filter parameters void setKernel(Mat row,Mat col,bool symm); //function to clear the filter parameters void clearKernel(); //apply a set of separable symmetric/anti-symmetric filters on //the source image and return a multi channel destination image ////function to perform separable filtering void apply(Mat &src,Mat &dst); };

2N + 1

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 2 0::N

k

dst(x; y )

X

=

N

i;k

g (k

+ N )I (x; y + k )

(1)

(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.

4 | 7

Each of the rows need to be multiplied with suitable filter coefficients. since the filter is symmetric or anti symmetric the filter coefficients g is multiplied with elements of rows j k and j + k

k

for(int y=0;y<s.height;y++) { //pointer to the source and destination float *srow0 = (float*)(src.data + src.step*y),*srow1=0; float *drow = (float*)(dst.data + dst.step*y); //performing vertical convolution //using the row kernel //computing g[0]*f(x,y) for( x = 0; x < s.width; x++ ) { for(int l=0;l<ch;l++) { row[x*ch+l] = srow0[x]*rowk[l].at<float>(n); } } //computing g[-n/2]*f(x,y-n/2) //performing vertical convolution accessing n rows about current row //accessing a 2 rows at a time,performing computation for(int k=1;k<=n;k++) { //accessing the vertical abouts about the current row srow0 = (float*)(src.data + src.step*std::max(y-k,0)); srow1 = (float*)(src.data + src.step*std::min(y+k,s.height-1)); for(int x=0;x<s.width;x++) { //applying different vertical kernels //accumulating the sum for(int l=0;l<ch;l++) { float p=srow0[x]+(1*(symmetric[l]?1:-1))*srow1[x]; row[x*ch+l]+=rowk[l].at<float>(k)*(p); }

5 | 7

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.

for(x=0;x<s.width;x++) { //apply horizontal kernels //g[0]*f(x,y) for(int l=0;l<ch;l++) { res[l]=row[x*ch+l]*colk[l].at<float>(n); } //accumulating the sum for g[-N/2+k]f(x-n/2+k) for(int k=1;k<=n;k++) { for(int l=0;l<ch;l++) { float p=(row[(x+k)]+(1*symmetric[l]?1:-1) *row[(x-k)])*colk[l].at<float>(k); res[l]=res[l]+p; }

} //storing the result of convolution //output image contains number of channels as different input filte for(int l=0;l<ch;l++) { drow[x*ch+l]=res[l]; }

6 | 7

0.1.4 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.

7 | 7

- Dense optical flow expansion based on polynomial basis approximationUploaded bypi194043
- Continuous Emission Hidden Markov Model for sequence classificationUploaded bypi194043
- Adaptive Skin Color DetectorUploaded bypi194043
- A linear channel filterUploaded bypi194043
- ARM Neon Optimization for image interleaving and deinterleavingUploaded bypi194043
- Normalized convolution for image interpolationUploaded bypi194043
- Polynomial Approximation of 1D signalUploaded bypi194043
- polynomial approximation of a 2D signalUploaded bypi194043
- Modified Canny Edge DetectionUploaded bypi194043
- Fast 3D Extension of Fast Feature Detection for SpatioTemporal Corner DetectionUploaded bypi194043
- Fast Asymmetric Learning for Cascade Face Detection Training/Testing UtilityUploaded bypi194043
- Gaussian Multivariate Distribution -Part 1Uploaded bypi194043
- Multi Class Logistic Regression Training and TestingUploaded bypi194043
- Random Ferns for Patch DescriptionUploaded bypi194043
- SubPixel Corner Localization AlgorithmUploaded bypi194043
- Control Limited Adaptive Histogram Equalization for Image EnhancementUploaded bypi194043
- Spatio Temporal Feature extraction using harris 3d corner detectorUploaded bypi194043
- Android OpenCV Simple Face TrackerUploaded bypi194043
- A detailed descriptions and results for different color constancy algorithmsUploaded bypi194043
- OpenCL Heterogenenous program for Image Processing - ColorSpace conversion BGR-HSV,HSV-BGR,BGR-GRAYUploaded bypi194043
- Feature Detection - Overview of Harris Corner Feature DetectionUploaded bypi194043
- Computing Rectangular Haar Features for Cascade Detection TrainingUploaded bypi194043
- Local Binary PatternUploaded bypi194043
- OpenCL 2D Convolution Using Separable Filters -Box FilterUploaded bypi194043
- Android OpenCV Face detectionUploaded bypi194043
- OpenCL Image Convolution Filter - Box FilterUploaded bypi194043
- A simple color balance algorithmUploaded bypi194043
- Polynomial Approximation of 2D image patch -Part 2Uploaded bypi194043
- Uniform Color QuantizationUploaded bypi194043
- Image enhancement using FusionUploaded bypi194043

- OpenVision Library Gaussian Mixture Model ImplementationUploaded bypi194043
- Markov chain implementation in C++ using EigenUploaded bypi194043
- Implementation of discrete hidden markov model for sequence classification in C++ using EigenUploaded bypi194043
- Polynomial Approximation of 1D signalUploaded bypi194043
- polynomial approximation of a 2D signalUploaded bypi194043
- Modified Canny Edge DetectionUploaded bypi194043
- Gaussian Multivariate Distribution -Part 1Uploaded bypi194043
- Multi Class Logistic Regression Training and TestingUploaded bypi194043
- Compiling Native C/C++ library for AndroidUploaded bypi194043
- Polynomial Approximation of 2D image patch -Part 2Uploaded bypi194043
- C++ static members and functionUploaded bypi194043
- C++ virtual functions and abstract classUploaded bypi194043
- Normalized convolution for image interpolationUploaded bypi194043
- Tan and Triggs Illumination normalizationUploaded bypi194043
- Mean Shift TrackingUploaded bypi194043
- Uniform Local Binary Pattern and Spatial Histogram ComputationUploaded bypi194043
- C++ Const,Volatile Type QualifiersUploaded bypi194043
- Mean Shift AlgorithmUploaded bypi194043
- Local Binary PatternUploaded bypi194043
- C++ InheritanceUploaded bypi194043
- Embedded Systems Programming with ARM on Linux - Blinking LEDUploaded bypi194043
- C++ Class Members and friendsUploaded bypi194043
- Integral Image for Computation of Mean And VarianceUploaded bypi194043
- Random Ferns for Patch DescriptionUploaded bypi194043

- Hiroshi Terashima and Grétar Tryggvason- A front-tracking/ghost-fluid method for fluid interfaces in compressible flowsUploaded byWhiteLighte
- AguaUploaded byJhonMüller
- Señalizacion HorizontalUploaded byjuanjtc77
- Catologo PanduitUploaded byfvarela8053
- 090130_Apresentação_sobre_o_GeodatabaseUploaded byotrocado
- Special Purpose AntennaUploaded byLear Soyon
- plan de negocio hotelUploaded byFrancisco Gatica
- CT-T30.pdfUploaded bymontassar
- Coil32 - Ferrite Toroid CoreUploaded byrommel duran
- 10 MOLAS Elementos de MaquinasUploaded byNayara Fernanda De Queiroz Ramos
- Synthesis and Property Comparison of Silicone polymersUploaded byDaniel Rodman
- T865e - Boat Davit Limit SwitchesUploaded bymorgoths
- CCMS Vendors - The Rockley GroupUploaded byJohn Melendez
- Getting to Grips With AlarUploaded bysopilot446
- DESTILACIÓN ATMOSFÉRICA DE PETRÓLEOUploaded byTito Hoover Nuñez Wayar
- Section 1Uploaded byJoki Dewa Putra
- 2do ParcialUploaded byjazmin morales
- 02 Segunda Unidad Procesos OrganziacionalesUploaded byBravo Ojeda Chris
- Fault-Location-Algorithm-in-Transmission-Grid.pdfUploaded byVin Zhen Low
- Fichas de Seguridad IrisUploaded byIriz Gonzalez
- lista 1.2Uploaded byThales Souza
- Comprobador de condensadores.docUploaded bySamuel JACOBBO
- Aggregation Order Item - Order Fulfillment - SAP LibraryUploaded byyaswanthrdy
- Estudos Dos SolosUploaded byRafael Gama
- Laboratorio sobre sistema de dirección en vehículosUploaded byjosuedanny0077jd
- Practica Calificada 02 - Diseño Del ServicioUploaded byRubenTorresBazan
- Mechanical Properties of Clear Wood From Norway SpruceUploaded byVictor Solis Brevis
- Calculo Espesor Tuberia b31.3Uploaded byramiveliz
- Sistemas de InformaciónUploaded byJose Alberto Alves Martinez
- QUANTIFYING THE EFFECT OF ROCK MASS QUALITY ON PEAK PARTICLE VELOCITY FOR UNDERGROUND DRIFT DEVELOPMENTUploaded byJonathan Tomás Josué Chipana Ajnota