我写了一个相机应用程序,允许用户捕获纸币的图像,发送到服务器,它将被打印。
问题:打印图像时,由于拍摄图像中的噪点,背景会变黑。 我只想要一个干净的白色背景。 我尝试过Bitmap的压缩方法,以不同的比例(1-100)保存JPEG / PNG格式的图像,但没有多大帮助。 我已经看到camscanner应用程序这样做非常奇妙,但不知道如何。
任何实现这一目标的指针都会有所帮助。
谢谢。
I've written a camera app which allow users to capture image of paper bills, send to server where it'll be printed.
Problem: when I print the image, the background is blackish due to noise in captured image. All I want is a clean white background. I've tried Bitmap's compress method to save the image in JPEG/PNG format on different scales (1-100) but not much helpful. I've seen camscanner app doing this fantastically but have no clue how.
Any pointer to achieve this will be helpful.
thanks.
最满意答案
如果问题是一些随机噪声,那么你可以使用一些去噪滤波器(即中值滤波器或双边滤波器)。
图像是否已经二值化(转换为严格的黑白像素)? 你想在此之前进行过滤。
编辑(在深灰色澄清之后):由于背景是深灰色,我猜测问题只是它是低对比度,因为它将是一个自然的图像,对比度的差异会有变化。 我建议使用Sauvola二值化,将黑色和深灰色分为黑色和白色。 以下是Sauvola的一些细节和示例结果: http : //www.leptonica.com/binarization.html 。 要运行一些测试以查看哪种二值化算法最佳,您可以在此处找到库
If the issue is some random noise, there are some noise removing filters out there you can use (i.e. median filter or a bilateral filter).
Is the image already binarized (converted to strictly black and white pixels)? You'd want to do the filtering before this.
EDIT(after clarification on dark gray): Since the background is a dark gray I'm guessing the problem is just that it is a low contrast and since it will be a natural image, there will be variation on how bad the contrast is. I suggest using Sauvola binarization for this which will separate out the black and the dark gray to black and white. Here is some detail and example results of Sauvola: http://www.leptonica.com/binarization.html. To run some tests to see which binarization algorithm would be best you can find a library here
更多推荐
发布评论