Skip to content

Commit c1ae67c

Browse files
committed
Increase to 30 bins
1 parent a9332e4 commit c1ae67c

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

index.html

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,12 @@
275275

276276
let sum = 0;
277277
let count = 0;
278-
let hist = [0,0,0,0,0,0,0,0,0,0];
278+
let bin_width = 255/30
279+
let hist = [
280+
0,0,0,0,0,0,0,0,0,0,
281+
0,0,0,0,0,0,0,0,0,0,
282+
0,0,0,0,0,0,0,0,0,0,
283+
];
279284
for (let j = 0; j < radius * 2; j++) {
280285
for (let i = 0; i < radius * 2; i++) {
281286
const dx = i - radius;
@@ -288,7 +293,7 @@
288293
const g = data[idx + 1];
289294
const b = data[idx + 2];
290295
const gray = 0.299 * r + 0.587 * g + 0.114 * b;
291-
const grayIdx = Math.floor(gray/25.5)
296+
const grayIdx = Math.floor(gray/bin_width)
292297
sum += gray;
293298
hist[grayIdx]++;
294299
count++;

0 commit comments

Comments
 (0)