You are on page 1of 4

Linear Channel Filter

Pi19404
February 18, 2014

Contents

Contents
Linear Channel Filter
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.2 Channel Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

3
3 3 4

2|4

Linear Channel Filter

Linear Channel Filter


0.1 Introduction
In this article we will look implementation of channel filter.

0.2 Channel Filter


 Point wise image processing operation are applied at each point of image  Some time transformation if pixel intensity at a point in a multi channel image is dependent on pixel intensity at other point in the image.  The present implementation of channel filter is used in case the channel transformation is linear as in the case of color space conversion ,matrix inversion applied across each channels of image etc.  A generic channel kernel is define whose column and/or row dimension equals the number of channels in the image  We just iterate over the pixel values,apply the kernel and then proceed to next pixel value.
1 2 3 4 5 6 7 8 9 10 11 12 13

void apply(Mat &src,Mat &dst) { int ch=src.channels(); Mat row=Mat(ch,1,CV_32F); dst.create(src.rows,src.cols,CV_32FC(ch)); //iterate over rows for(int i=0;i<src.rows;i++) { float *ptr=src.ptr<float>(i); float *dptr=dst.ptr<float>(i); //iterate over columns for(int j=0;j<src.cols*ch;j=j+ch) {

3|4

Linear Channel Filter


14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

} }

#pragma unroll for(int k=0;k<ch;k++) { row.at<float>(k)=ptr[j+k]; } //apply the kernel as dot product Mat res=kernel*row; #pragma unroll //store the result for(int k=0;k<ch;k++) { dptr[j+k]=res.at<float>(k); }

code The code for the same can be found at git repository https://github.com/pi19404/OpenVision in files ImgProc/channelfilter.cpp and ImgProc/channelfilter.hpp files.

4|4