From b731aed0a917db08b41cee3a239a4df897264640 Mon Sep 17 00:00:00 2001 From: Peihong Guo Date: Thu, 28 Nov 2013 03:14:22 -0600 Subject: [PATCH] added histogram equalization --- index.html | 5 +++++ pixastic.effects.js | 48 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/index.html b/index.html index 9dc5884..b09efe3 100644 --- a/index.html +++ b/index.html @@ -143,6 +143,11 @@ options : { blockSize : 8 } + }, + { + effect : 'equalize', + options : { + } } ]; diff --git a/pixastic.effects.js b/pixastic.effects.js index 9789e61..3cc3083 100644 --- a/pixastic.effects.js +++ b/pixastic.effects.js @@ -1222,6 +1222,54 @@ Pixastic.Effects = (function() { } y0 = y1; } + }, + + equalize : function(inData, outData, width, height, options, progress) { + var n = width * height, p, i, level, ratio, + prog, lastProg; + var round = Math.round; + // build histogram + var pdf = new Array(256); + for (i=0;i<256;i++) { + pdf[i] = 0; + } + + for (i=0;i> 0) / 100; + if (prog > lastProg) { + lastProg = progress(prog); + } + } + } } };