roiDetector::roiDetector(const CameraPrx& camera , RoboCompVision::TCamParams params_, int nCam_, QObject *parent): QObject(parent), _camera(camera), nCam(nCam_), params(params_) { qDebug() << "roiDetector::roiDetector() -> Initiating roiDetector number " << nCam; Umbral_Harris=UMBRAL_HARRIS; Umbral_Harris_Min=UMBRAL_HARRIS_MIN; Umbral_Hess=UMBRAL_HESS; Umbral_Laplacian=(uchar)UMBRAL_LAPLACIAN; sizePir=(IppiSize *) malloc(params.pyrLevels*sizeof(IppiSize)); infoPrisma=(PrismaROI *) malloc(params.pyrLevels*sizeof(PrismaROI)); imagen = ippsMalloc_8u(params.size); imagenV.resize(params.size); iniPiramide(); IppiSize sizeImage; sizeImage.width=PAN_RANK; sizeImage.height=TILT_RANK; Mapa_Umbral_Harris1=(Ipp32f *) ippsMalloc_32f(PAN_RANK*TILT_RANK*sizeof(Ipp32f)); Mapa_Umbral_Harris2=(Ipp32f *) ippsMalloc_32f(PAN_RANK*TILT_RANK*sizeof(Ipp32f)); ippiSet_32f_C1R(-1.,Mapa_Umbral_Harris1,PAN_RANK*sizeof(Ipp32f),sizeImage); ippiSet_32f_C1R(-1.,Mapa_Umbral_Harris2,PAN_RANK*sizeof(Ipp32f),sizeImage); Mapa_Umbral_Harris_Act=Mapa_Umbral_Harris1; Mapa_Umbral_Harris_Ant=Mapa_Umbral_Harris2; //LogPolar // lp = new LPolar(64,200,height,height); }
IppStatus FindLocalMax_2D(Image2D &image_bpass, Image2D &image_bpass_thresh, Image2D &image_subtracted, const int intensity_threshold, const int dilation_radius) { IppStatus status; Image2D image_dilated(image_bpass.get_length(), image_bpass.get_width()); Dilation_Kernel DilationKernel(dilation_radius, image_bpass.get_width(), image_bpass.get_length()); //Threshold darker pixels in bandpassed image (in preparation for later subtraction) RecenterImage(image_bpass); status = ippiThreshold_LTVal_32f_C1R(image_bpass.get_image2D(), image_bpass.get_stepsize(), image_bpass_thresh.get_image2D(), image_bpass_thresh.get_stepsize(), image_bpass.get_ROIfull(), intensity_threshold, intensity_threshold); //Dilate Bandpassed image with a circular kernel status = ippiSet_32f_C1R(intensity_threshold, image_dilated.get_image2D(), image_dilated.get_stepsize(), image_dilated.get_ROIfull()); status = ippiDilate_32f_C1R( //image_bpass.get_image2D() + DilationKernel.get_offset(), image_bpass.get_stepsize(), image_bpass_thresh.get_image2D() + DilationKernel.get_offset(), image_bpass_thresh.get_stepsize(), image_dilated.get_image2D()+ DilationKernel.get_offset(), image_dilated.get_stepsize(), DilationKernel.get_ROI_size(), DilationKernel.get_dilation_kernel(), DilationKernel.get_mask_size(), DilationKernel.get_anchor_point()); //subtract, such that resulting array is negative to zero (for later exponentation) status = ippiSub_32f_C1R( image_dilated.get_image2D(), image_dilated.get_stepsize(), image_bpass.get_image2D(), image_bpass.get_stepsize(), image_subtracted.get_image2D(), image_subtracted.get_stepsize(), image_bpass.get_ROIfull()); //exponentiate subtracted array, then threshold status = ippiExp_32f_C1IR(image_subtracted.get_image2D(), image_subtracted.get_stepsize(), image_subtracted.get_ROIfull()); status = ippiThreshold_LTValGTVal_32f_C1IR(image_subtracted.get_image2D(), image_subtracted.get_stepsize(), image_subtracted.get_ROIfull(), 1-epsilon, 0, 1-epsilon, 1); 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; }