Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 从扫描图像中去除背景梯度_Image Processing - Fatal编程技术网

Image processing 从扫描图像中去除背景梯度

Image processing 从扫描图像中去除背景梯度,image-processing,Image Processing,我正在寻找一个很好的方法来做各种扫描图像的批处理图像。图像相当大(a4时为300dpi),但图像处理时间不应受到关注 一般的问题是:图像可能是彩色的,但不一定是彩色的,其中一些是黑白的。它们在扫描书籍中有相当典型的折痕。我想要的是一张没有褶皱痕迹的图像,看起来像是渐变,并且(作为额外的奖励)颜色发生了变化,使得实际背景看起来是白色/浅灰色。示例图像如下(来源为Haeckel's,供感兴趣的人参考): 我考虑过用Python做一个自适应对比度过滤器,但还没有找到好的解决方案;几乎任何框架/工具/

我正在寻找一个很好的方法来做各种扫描图像的批处理图像。图像相当大(a4时为300dpi),但图像处理时间不应受到关注

一般的问题是:图像可能是彩色的,但不一定是彩色的,其中一些是黑白的。它们在扫描书籍中有相当典型的折痕。我想要的是一张没有褶皱痕迹的图像,看起来像是渐变,并且(作为额外的奖励)颜色发生了变化,使得实际背景看起来是白色/浅灰色。示例图像如下(来源为Haeckel's,供感兴趣的人参考):

我考虑过用Python做一个自适应对比度过滤器,但还没有找到好的解决方案;几乎任何框架/工具/语言的输入都可以帮助我。

这里有一个快速的黑客使用。它做了一个巨大的模糊(高斯加sigma 200)来获得背景,然后根据图像的暗度放大图像

#!/usr/bin/env python

import sys

import gi
gi.require_version('Vips', '8.0')
from gi.repository import Vips

image = Vips.Image.new_from_file(sys.argv[1])

# huge gaussian blur to remove all high frequences ... we will just be left with
# the changes in the background
smooth = image.gaussblur(200)

# scale up the darker areas of the original ... we scale up by the proportion they
# are darker than white by
image *= smooth.max() / smooth

# that'll make rather a dazzling white ... knock it back a bit
image *= 0.9

image.write_to_file(sys.argv[2])
像这样跑:

$ time ./remove_gradient.py ~/Desktop/orig.jpg x.jpg
real    0m16.369s
user    0m55.704s
sys 0m0.218s
还有一些小插曲,但在我看来,它似乎减少了


我不明白您想删除什么,您能添加一些带注释的示例吗。好的,我想我看到了。内部结构的左侧比右侧暗。整个背景颜色不均匀。它的边缘越来越暗;理想情况下,在保留细节的同时更接近纯色(见文字和图纸)。您的示例没有折叠标记,您也有吗?折叠标记没有比这更强烈。实际上你看不到褶皱,但是你看到扫描不是完全直的。