Image processing (vi) Recursive bilateral filter grinding-image processing

Source: Internet
Author: User
Tags abs

The recursive two-sided filtering is a kind of acceleration algorithm of the bilateral filtering, the acceleration ratio is very large, just like the Gaussian fuzzy fast algorithm, the speed is increased more than 10 times times compared with the original algorithm. The acceleration algorithm of the bilateral filter many, the literature is older, my side mainly talk about the comparison of the new algorithm: recursive bilateral filtering, corresponding to the paper: "Recursive bilateral filtering"

This algorithm is a bit faster than the two-exponential filter I have in my other blog post, and the basic idea of two documents is the same:


The recursive formula is basically the same as the recursive formula of the double exponent. So the code is easy to write, before the two-exponential algorithm, then as long as on the basis of the double index, the code to change the OK, here is not a detailed explanation of the algorithm flow, interested students can go to paper's author homepage, there are code, but his code seems to be to achieve stereo matching, It's OK to button up the relevant code inside, and here is the code for some important functions.

[cpp]  View Plain  copy void cbrf::recursive_bilateral_filter (double *data,unsigned char* *disparity,double***in,unsigned char***texture,double sigma_spatial,double sigma_range,int  height,int width,int nr_channel,double***temp,double***temp_2w)    {        double yp[100];       double alpha=exp (-SQRT (2.0)/( sigma_spatial*width));//filter kernel size       double inv_alpha= (1-alpha);       double range_table[256];        for (int i=0;i<=255;i++)             range_ Table[i]=exp (-double (i)/(sigma_range*255));             byte*  p0 =m_pImage;       const int nChannel = 4;    &NBsp;   int m_length =m_nwidth*m_nheight;  //Horizontal iterative filtering         //double***in_=in;/*horizontal filtering*/       //double***out_ =temp;       double ***out=new double**[m_nHeight];        for  (int i=0;i<m_nheight;i++)        {           out[i]=new double*[m_nWidth];        }       for  (int i=0;i<m_nheight;i++)         {           for  (int j=0;j<m_ nwidth;j++)            {                out[i][j]=new double [3];            }       }       double  out=new double**[m_nheight];          for (int i=0;i<m_ nheight;i++)        {            byte* p0 =m_pimage+i*m_nwidth;           memcpy (out I [0],p0,sizeof (double) *m_nwidth*nchannel);           for (int  j=1;j<width;j++)             {                double weight=range_table[euro_dist_rgb _max (Out[i][j],out[i][j-1])];                double alpha_=weight*alpha;              &nbSp; for (int k=0;k<nchannel;k++)                  {                    double ycc=inv_alpha*m_pImage[i*m_nWidth*nChannel+j*nChannel+k]+alpha_*yp[k];                     out[i][j][k]=ycc                    yp[k]=ycc;                }           }                  int w1=width-1;            for (int c=0;c<nr_channel;c++)                  out[y][w1][c]=0.5* (Out[y][w1][c]+in[y][w1][c]);            memcpy (yp,out_[y][w1],sizeof (double) *nr_channel);            for (int x=width-2;x>=0;x--)              {               double weight= Range_table[euro_dist_rgb_max (texture[y][x],texture[y][x+1])];                double alpha_=weight*alpha;                for (int c=0;c<nr_channel;c++)                  {                    double ycc=inv_alpha*in_[y][x][c]+alpha_*yp[c ];                   out_[y][ x][c]=0.5* (OUT_[Y][X][C]+YCC);                    yp[c]=ycc;                }           }        }              //Vertical iterative filter         /*in_=temp;      alpha=exp (-SQRT (2.0)/(sigma_spatial*height));//filter  kernel size      inv_alpha= (1-alpha);      double**ycy,** ypy,**xcy,**xpy;      unsigned char**tcy,**tpy;       memcpy (out[0][0],in_[0][0],sizeof (double) *width*nr_channel);      for (int y=1;y

Look at some of the test results I wrote with this algorithm:


Original


Mei Mito


Recursive bilateral filtering

The last person must depend on oneself, want to understand an algorithm deeply, let the memory is deeper, must oneself the code knocks over again, since chooses it, must insist to write code. This article address: http://blog.csdn.net/hjimce/article/details/45421207 Author: hjimce Contact qq:1393852684 More resources please pay attention to my blog: http://blog.csdn . NET/HJIMCE original article, reprint please keep these lines of information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.