Adptive Thresholding Using the Integral Image

來源:互聯網
上載者:User

論文作者 Derek Bradley*   Gerhard Roth

論文給的虛擬碼:

void vvAdaptiveThreshold( IplImage* inImg, IplImage* outImg){int S = inImg->width >> 5;int T = 10;char *input, *bin;input = inImg->imageData;bin = outImg->imageData;int width = inImg->width;int height = inImg->height;unsigned long* integralImg = 0;int i, j;long sum=0;int count=0;int index;int x1, y1, x2, y2;int s2 = S/2;//bin = new unsigned char[width*height];// create the integral imageintegralImg = (unsigned long*)malloc(width*height*sizeof(unsigned long*));for (i=0; i<width; i++){// reset this column sumsum = 0;for (j=0; j<height; j++){index = j*width+i;sum += input[index];if (i==0)integralImg[index] = sum;elseintegralImg[index] = integralImg[index-1] + sum;}}// perform thresholdingfor (i=0; i<width; i++){for (j=0; j<height; j++){index = j*width+i;// set the SxS regionx1=i-s2; x2=i+s2;y1=j-s2; y2=j+s2;// check the borderif (x1 < 0) x1 = 0;if (x2 >= width) x2 = width-1;if (y1 < 0) y1 = 0;if (y2 >= height) y2 = height-1;count = (x2-x1)*(y2-y1);// I(x,y)=s(x2,y2)-s(x1,y2)-s(x2,y1)+s(x1,x1)sum = integralImg[y2*width+x2] -integralImg[y1*width+x2] -integralImg[y2*width+x1] +integralImg[y1*width+x1];if ((long)(input[index]*count) < (long)(sum*(100-T)/100))bin[index] = 0;elsebin[index] = 255;}}free (integralImg);}

這個源碼請參考  http://blog.csdn.net/hhygcy/article/details/4280165

+++++++++++++++++++++++++

論文效果

而  我跑了下:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.