996 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

2D Seperable Symmetric/Anti-Symmmetric Convolution

**2D Seperable Symmetric/Anti-Symmmetric Convolution
**

0.1 Introduction

In the article we will look at algorithm for Fast 2D Convolution.

0.1.1 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

3 | 7

2D Seperable Symmetric/Anti-Symmmetric Convolution

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

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); };

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

k

dst(x; y )

=

X

=

N

i;k

=

g (k

+ N )I (x; y + k )

(1)

N

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.

4 | 7

2D Seperable Symmetric/Anti-Symmmetric Convolution

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

The resultant sum of accumulated,this is performed for all the rows.

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

2D Seperable Symmetric/Anti-Symmmetric Convolution

}

}

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

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

2D Seperable Symmetric/Anti-Symmmetric Convolution

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

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

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

- Concept ModellingUploaded byStella-Jebas
- Busn 135 SyllabusUploaded byrizofpicic
- Online Library SystemUploaded byArora_Raj
- Advanced Search TipsUploaded byRedalkemi
- Ral, Reymart j. Bio Data - For MergeUploaded byJun Rey Poblete
- folleto_setas_region_murcia.pdfUploaded bycbfodrtf
- MRUUploaded byAnonymous dXQs1Ncv4
- List of startups for 2018 AutoMobili-DUploaded byWXYZ-TV Channel 7 Detroit
- America Latina y Colombia en El Medio SigloUploaded byNPILarA
- skol brochure.pdfUploaded byAnonymous 2evaoXKKd
- Los HomínidosUploaded byvictorchv
- El_Horno_de_BarroUploaded byQuique Paladino
- Paper EnergiaUploaded byNimer Tk
- Taller de Habilidades Para Fomentar El Trabajo en Equipo DocxUploaded byPamela Velasquez
- Introdução à Teoria Da Ressonância Harmônica Por Onda (1)Uploaded byAndreiaa Ca Thomazz
- 3B_Rusting as a Redox ReactionUploaded byCheq Chenta
- Como Las Propiedades de Los Metales Afectan La DistorsionUploaded byLilianitaRizo
- UNIDAD 3Uploaded byBette Flo
- acido-ascorbico-NUEVO (1)Uploaded byJuniorSiguasPeña
- UntitledUploaded bymojeprawo
- Read Write Srs Mcu Can EngUploaded bydongvac
- Professional Development OutlineUploaded byAmisi Bowe-Monfiston
- EN-GJL-250Uploaded byStefanoDelTedesco
- Preguntas - Leccion No.7 Mercadotecnia -- 3er ParcialUploaded byVanessa Garcia
- R831 Air Water Heat PumpUploaded byRodrigoCisneros
- Analyzing the Circular Flow ModelUploaded byJohn Johnson
- Mapa Geol ApiaiUploaded byFlávio N. De Almeida Jr.
- General Knowledge Supplement - 1Uploaded byVAIBHAV KUMAR
- Smartvox - Using Shared Line Appearances (SLA) on Asterisk v1Uploaded byAthanasios Koumbogiannis
- Marco Teorico de La RegulacionUploaded byMillen Melgarejo Reyes