From 1172ab5d3ea286270df08e393968a9ba0380c8b7 Mon Sep 17 00:00:00 2001 From: ataata107 Date: Sun, 12 Jan 2020 02:49:04 +0530 Subject: [PATCH] Show histogram values --- src/modules/Histogram/Module.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/modules/Histogram/Module.js b/src/modules/Histogram/Module.js index e556911fd6..fb0122a03a 100644 --- a/src/modules/Histogram/Module.js +++ b/src/modules/Histogram/Module.js @@ -18,15 +18,15 @@ module.exports = function Channel(options, UI) { var step = this, hist = new Array(256).fill(0); - function changePixel(r, g, b, a) { - let pixVal = Math.round((r + g + b) / 3); - hist[pixVal]++; - return [r, g, b, a]; - } - function extraManipulation(pixels) { // if (!options.inBrowser) // require('fs').writeFileSync('./output/histo.txt', hist.reduce((tot, cur, idx) => `${tot}\n${idx} : ${cur}`, ``)); + for (let x = 0; x < pixels.shape[0]; x++) { + for (let y = 0; y < pixels.shape[1]; y++) { + let pixVal = Math.round(pixels.get(x, y, 0) + pixels.get(x, y, 1) + pixels.get(x, y, 2)) / 3; + hist[pixVal]++; + } + } var newarray = new Uint8Array(4 * 256 * 256); pixels.data = newarray; pixels.shape = [256, 256, 4]; @@ -70,7 +70,6 @@ module.exports = function Channel(options, UI) { return require('../_nomodule/PixelManipulation.js')(input, { output: output, ui: options.step.ui, - changePixel: changePixel, extraManipulation: extraManipulation, format: input.format, image: options.image,