From 007371e4c867d9dd5b9d1c6f636e70e55a18c31f Mon Sep 17 00:00:00 2001 From: Dor-sketch Date: Fri, 28 Jun 2024 12:56:16 +0300 Subject: [PATCH] Fixed bug in not binarizing the input data --- docs/index.html | 7 ++++++- docs/js/parser.js | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 3f4fae3..47ba4a0 100644 --- a/docs/index.html +++ b/docs/index.html @@ -129,7 +129,6 @@ - + + \ No newline at end of file diff --git a/docs/js/parser.js b/docs/js/parser.js index de1c379..1faa139 100644 --- a/docs/js/parser.js +++ b/docs/js/parser.js @@ -170,6 +170,8 @@ function processImage(src) { reject(new Error("No image source provided.")); return; } + // make black and white and extream contrast (black and white) + const img = new Image(); img.onload = function () { @@ -181,7 +183,10 @@ function processImage(src) { ctx.drawImage(img, 0, 0, targetWidth, targetHeight); // Binarize and enhance the image + let imageData = ctx.getImageData(0, 0, canvas.width, canvas.height); + imageData = binarizeImage(imageData); + ctx.putImageData(imageData, 0, 0); const processedImageSrc = canvas.toDataURL();