Adptive Thresholding Using the Integral Image


论文作者 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 image
	integralImg = (unsigned long*)malloc(width*height*sizeof(unsigned long*));
	for (i=0; i<width; i++)
	{
		// reset this column sum
		sum = 0;
		for (j=0; j<height; j++)
		{
			index = j*width+i;
			sum += input[index];
			if (i==0)
				integralImg[index] = sum;
			else
				integralImg[index] = integralImg[index-1] + sum;
		}
	}
	// perform thresholding
	for (i=0; i<width; i++)
	{
		for (j=0; j<height; j++)
		{
			index = j*width+i;
			// set the SxS region
			x1=i-s2; x2=i+s2;
			y1=j-s2; y2=j+s2;
			// check the border
			if (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;
			else
				bin[index] = 255;
		}
	}
	free (integralImg);
}
这个源码请参考  http://blog.csdn.net/hhygcy/article/details/4280165


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

论文效果





而  我跑了下:




Image denoising is the process of removing noise from an image while preserving its important features. One popular method for image denoising is non-local means (NLM), which is based on the idea that similar patches in an image have similar signal characteristics. NLM works by averaging the pixel values of similar patches in the image, thus reducing the noise without affecting the image structure. Another popular method for image denoising is wavelet shrinkage, which is based on the concept of wavelet transform. Wavelet transform decomposes an image into multi-resolution subbands, each of which captures different frequency components of the image. Wavelet shrinkage works by thresholding the wavelet coefficients in the high-frequency subbands, thus reducing the noise while preserving the image details. Combining NLM and wavelet shrinkage can improve the performance of image denoising. The NLM method can effectively remove the noise in the low-frequency subbands of the image, while the wavelet shrinkage method can remove the noise in the high-frequency subbands. The combination of these two methods can lead to a significant improvement in image denoising performance, especially for images with complex and heterogeneous noise patterns. In summary, image denoising using non-local means and wavelet shrinkage is a powerful technique for removing noise from images while preserving their important features. This method can be used in a variety of applications, including medical imaging, remote sensing, and image processing.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值