Professional Documents
Culture Documents
Pi19404
February 18, 2014
Contents
Contents
Linear Channel Filter
0.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0.2 Channel Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3
3 3 4
2|4
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
} }
#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