如何去除背景噪音并只留下文字? 示例图片:
我的代码:
var Tesseract = require('tesseract.js');
var Jimp = require("jimp");
Jimp.read("12.png").then(function (image) {
image
.color([
{ apply: 'brighten', params: [20] }
])
.contrast(1)
.greyscale()
.write("img-opt.jpg");
})
.then(function() {
Tesseract.recognize('img-opt.jpg', {
tessedit_char_whitelist: 'AN%D%P'
})
.progress(function(message){console.log(message)})
.catch(function(err){console.error(err)})
.then(function(result){console.log(result.text)})
})
.catch(function (err) {
console.error(err);
});
我得到了这个结果:
那么,我怎样才能消除背景噪音呢? 谢谢!
最佳答案
通过删除 brigthen
转换,我获得了更好的结果。
此外,去饱和
似乎比灰度
效果更好。
image
.color([{apply: 'desaturate', params: [90]}])
.contrast(1)
.write("img-opt.jpg");
您只需要一点点尝试和错误。
关于node.js - 去除图像文本nodejs中的噪声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53109734/