IppStatus BandPass_2D(Image2D &image_in, Image2D &image_bandpassed, const int feature_radius, const int hwhm_length) { //set status variable IppStatus status; Gaussian_Kernel GaussKernel(feature_radius, hwhm_length, image_in.get_width(), image_in.get_length()); Convolution_Kernel ConvolutionKernels(feature_radius, image_in.get_width(), image_in.get_length()); Tophat_Kernel TopHatKernel(feature_radius, image_in.get_width(), image_in.get_length()); int number_of_pixels = image_in.get_numberofpixels(); int step_size = image_in.get_stepsize(); //Create and initialize intermediate images Image2D image_gauss_col(image_in.get_length(), image_in.get_width()); Image2D image_gauss_rowcol(image_in.get_length(), image_in.get_width()); Image2D image_tophat(image_in.get_length(), image_in.get_width()); //Gaussian kernel convolution status = ippiFilterColumn_32f_C1R(image_in.get_image2D() + GaussKernel.get_offset(), step_size, image_gauss_col.get_image2D() + GaussKernel.get_offset(), step_size, GaussKernel.get_ROI_size(), GaussKernel.get_gaussian_kernel(), GaussKernel.get_kernel_length(), GaussKernel.get_anchor_point()); status = ippiFilterRow_32f_C1R(image_gauss_col.get_image2D() + GaussKernel.get_offset(), step_size, image_gauss_rowcol.get_image2D() + GaussKernel.get_offset(), step_size, GaussKernel.get_ROI_size(), GaussKernel.get_gaussian_kernel(), GaussKernel.get_kernel_length(), GaussKernel.get_anchor_point()); /* //tophat kernel convolution/filterbox operation status = ippiFilterBox_32f_C1R(image_in.get_image2D() + TopHatKernel.get_offset(), step_size, image_tophat.get_image2D() + TopHatKernel.get_offset(), step_size, TopHatKernel.get_ROI_size(), TopHatKernel.get_mask_size(), TopHatKernel.get_anchor_point()); */ //change by Eli Sloutskin: take away bias of square filtering kernel status = ippiConvValid_32f_C1R(image_in.get_image2D(), step_size, image_in.get_ROIfull(), ConvolutionKernels.get_circle_kernel(), ConvolutionKernels.get_kernel_step(), ConvolutionKernels.get_kernel_size(), image_tophat.get_image2D() + ConvolutionKernels.get_offset(), step_size); ippiDivC_32f_C1IR(3*feature_radius*feature_radius, image_tophat.get_image2D(),image_tophat.get_stepsize(),image_tophat.get_ROIfull()); //subtract the two images status = ippiSub_32f_C1R(image_tophat.get_image2D() + TopHatKernel.get_offset(), step_size, image_gauss_rowcol.get_image2D()+TopHatKernel.get_offset(), step_size, image_bandpassed.get_image2D() + TopHatKernel.get_offset(), step_size, TopHatKernel.get_ROI_size()); //cutoff values below zero status = ippiThreshold_LTVal_32f_C1IR(image_bandpassed.get_image2D() + TopHatKernel.get_offset(), step_size, TopHatKernel.get_ROI_size(),0,0); return status; }
void AtrousGabor::_process_level( IMAGE_PTR in, IMAGE_PTR out, int level) // can be used in place { const int filtersize = 5; const int filtercenter = 2; int r,c; //loop counters int step = (int)pow(2.0f,level-1); //size of the increments between non zero filter coefs int dim = step*(filtersize-1)+1; //dimension of the FIR filter at this scale int mid = dim/2; //filter center #ifdef USE_IPP int stride; IppiSize size = {m_i_colsext, m_i_linesext}; IppiSize horsize = {m_i_colsext-2*mid, m_i_linesext}; IppiSize versize = {m_i_colsext, m_i_linesext-2*mid}; Ipp32f *filter = ippiMalloc_32f_C1(dim,1,&stride); ippiSet_32f_C1R(0.0f, temp, m_i_strideext, size); for( r = 0; r < dim; r++ ) filter[r] = 0.0f; filter[0] = filter[dim-1] = (Ipp32f)fc; filter[step] = filter[dim-step-1] = (Ipp32f)fb; filter[2*step] = (Ipp32f)fa; ippiFilterRow_32f_C1R( in + mid, m_i_strideext, temp+mid, m_i_strideext, horsize, filter, dim, mid); ippiFilterColumn_32f_C1R( temp + mid*m_i_stridepix, m_i_strideext, out + mid*m_i_stridepix, m_i_strideext, versize, filter, dim, mid); ippiFree(filter); #else int height = m_i_linesext; int width = m_i_colsext; int ws = m_i_stridepix; //horizontal filtering for(r=0; r < height; r++ ) { //filtering the left border for(c = 0; c < step; c++) temp[r*ws+c] = fc*(in[r*ws]+in[r*ws+c+2*step]) + fb*(in[r*ws]+in[r*ws+c+step]) + fa*in[r*ws+c]; for(c = step; c < 2*step; c++) temp[r*ws+c] = fc*(in[r*ws]+in[r*ws+c+2*step]) + fb*(in[r*ws+c-step]+in[r*ws+c+step]) + fa*in[r*ws+c]; //filtering the valid part for(c = 2*step; c < width - 2*step; c++) temp[r*ws+c] = fc*(in[r*ws+c-2*step]+in[r*ws+c+2*step]) + fb*(in[r*ws+c-step]+in[r*ws+c+step]) + fa*in[r*ws+c]; //filtering the right border for(c = width-2*step; c < width-step; c++) temp[r*ws+c] = fc*(in[r*ws+c-2*step]+in[r*ws+width-1]) + fb*(in[r*ws+c-step]+in[r*ws+c+step]) + fa*in[r*ws+c]; for(c = width-step; c < width; c++) temp[r*ws+c] = fc*(in[r*ws+c-2*step]+in[r*ws+width-1]) + fb*(in[r*ws+c-step]+in[r*ws+width-1]) + fa*in[r*ws+c]; } //vertical filtering for(c=0; c < width; c++ ) { //filtering the top border for(r = 0; r < step; r++) out[r*ws+c] = fc*(temp[c]+temp[(r+2*step)*ws+c]) + fb*(temp[c]+temp[(r+step)*ws+c]) + fa*temp[r*ws+c]; for(r = step; r < 2*step; r++) out[r*ws+c] = fc*(temp[c]+temp[(r+2*step)*ws+c]) + fb*(temp[(r-step)*ws+c]+temp[(r+step)*ws+c]) + fa*temp[r*ws+c]; //filtering the valid part for(r = 2*step; r < height - 2*step; r++) out[r*ws+c] = fc*(temp[(r-2*step)*ws+c]+temp[(r+2*step)*ws+c]) + fb*(temp[(r-step)*ws+c]+temp[(r+step)*ws+c]) + fa*temp[r*ws+c]; //filtering the right border for(r=height-2*step; r < height-step; r++) out[r*ws+c] = fc*(temp[(r-2*step)*ws+c]+temp[(height-1)*ws+c]) + fb*(temp[(r-step)*ws+c]+temp[(r+step)*ws+c]) + fa*temp[r*ws+c]; for(r=height-step; r < height; r++) out[r*ws+c] = fc*(temp[(r-2*step)*ws+c]+temp[(height-1)*ws+c]) + fb*(temp[(r-step)*ws+c]+temp[(height-1)*ws+c]) + fa*temp[r*ws+c]; } #endif return; }