tensorflowjs-binarization
Version:
Realization of binarization algorithms with Tensorflowjs
31 lines (15 loc) • 665 B
JavaScript
const tf = require('@tensorflow/tfjs-node-gpu');
const fs = require("fs");
const threshold = require('./src/threshold');
const thresh = new threshold(tf);
async function test(){
let img1 = fs.readFileSync("./test_images/wow.png");
const imageToPixel = await tf.node.decodePng(img1, 1);
let bin = await thresh.binary(imageToPixel, 0.6, false);
let otsuz = await thresh.otsu(imageToPixel);
let newImg = await tf.node.encodePng(bin,1);
let newImg_otsuz = await tf.node.encodePng(otsuz,1);
fs.writeFileSync("./test_images/result/bin.png", newImg)
fs.writeFileSync("./test_images/result/otsuz.png", newImg_otsuz)
}
test();