DeNoise() 使彩纸扫描变得更差
DeNoise() 使彩纸文档在扫描成黑白时噪声更大,而不是更清晰。页面变成一致的灰色颗粒,默认滤波器误将该颗粒读取为斑点。
DeNoise()(在内部别名为Despeckle())专为一项任务而构建:去除在其他干净白色背景上的小而孤立的黑色斑点。 它不适用于连续纹理。 当彩纸页面以黑白扫描时,它失去了色彩对比,变成了整个页面一致的灰色调颗粒。 固定的全局阈值将其解释为广泛的斑点,而不是孤立的噪声,所以它放大了背景而不是去除它。 这是默认DeNoise()针对该输入类型的设计限制,而不是特定环境的漏洞。
解决方案
选项1:自适应DeNoise() (v2026.10.2+)
传递adaptive: true以将DeNoise()切换为本地(Sauvola)阈值化,这专为具有连续背景纹理的页面设计,例如扫描为黑白的彩纸页面。
input.DeNoise(use3x3: false, adaptive: true);
普通DeNoise()保持其原始行为,因此必须显式启用此模式。 在早期版本中,或者如果结果仍然有噪音,请回退到AdaptiveThreshold()。
选项2:AdaptiveThreshold()
将DeNoise()替换为AdaptiveThreshold()以用于此文档类型。
using (var input = new OcrInput())
{
foreach (var imagePath in pageImagePaths)
{
input.LoadImage(imagePath);
}
// Replaces input.DeNoise() for this document type
input.AdaptiveThreshold(0.15f);
var ocrResult = ocr.Read(input);
ocrResult.SaveAsSearchablePdf(outputPath);
}Using input As New OcrInput()
For Each imagePath In pageImagePaths
input.LoadImage(imagePath)
Next
' Replaces input.DeNoise() for this document type
input.AdaptiveThreshold(0.15F)
Dim ocrResult = ocr.Read(input)
ocrResult.SaveAsSearchablePdf(outputPath)
End UsingUsing input As New OcrInput()
For Each imagePath In pageImagePaths
input.LoadImage(imagePath)
Next
' Replaces input.DeNoise() for this document type
input.AdaptiveThreshold(0.15F)
Dim ocrResult = ocr.Read(input)
ocrResult.SaveAsSearchablePdf(outputPath)
End UsingAdaptiveThreshold() 针对本地阈值进行二值化,因此处理的是整个页面的颗粒,这会使固定阈值滤波器失效。 一个适合thresholdLimit的调整范围是0.10到0.20。
如果单独AdaptiveThreshold()不能完全清理批处理中其他文档,请先应用Contrast() 在二值化之前加宽文字和背景之间的分割。
input.Contrast(1.3f); // try a range of 1.3f-1.4f
input.AdaptiveThreshold(0.15f);
DeNoise(),在管道中没有Deskew或其他滤波器,已证实对这种输入无效:它通过放大背景噪声使图像变得更差。Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。