node.js - 去除图像文本nodejs中的噪声

标签 node.js

如何去除背景噪音并只留下文字? 示例图片:

enter image description here

我的代码:

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);
});

我得到了这个结果:

enter image description here

那么,我怎样才能消除背景噪音呢? 谢谢!

最佳答案

通过删除 brigthen 转换,我获得了更好的结果。 此外,去饱和似乎比灰度效果更好。

image
    .color([{apply: 'desaturate', params: [90]}])
    .contrast(1)
    .write("img-opt.jpg");

result

您只需要一点点尝试和错误。

关于node.js - 去除图像文本nodejs中的噪声,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53109734/

相关文章:

node.js - Angular 2 Firebase 应用程序中的 net::ERR_CONNECTION_CLOSED

node.js - nodejs 和express 与heroku 我得到了R10

node.js - 尽管 Lambda 日志报告成功,但客户端仍收到 502 错误

node.js - VS2013 R3 NodeJS项目加载慢

node.js - Nodejs 在路由器页面中包含 socket.io

javascript - Mongod 无法正常运行

javascript - 使用 NAN 将数组从 node.js 传递到 c++ v8

javascript - Controller 中需要模块错误

node.js - 如何将我通过 Node 下载并解压缩的文件上传到 S3

node.js - 使用 nw-gyp 构建 node-sqlite3