use the raw luma
This commit is contained in:
parent
a2d496118e
commit
0ea766a5a6
1 changed files with 6 additions and 14 deletions
|
@ -247,21 +247,13 @@ function colorize(input) {
|
||||||
// Try dithering with this palette.
|
// Try dithering with this palette.
|
||||||
for (let x = 0; x < width; x++) {
|
for (let x = 0; x < width; x++) {
|
||||||
let rgb = inputPixel(x, error);
|
let rgb = inputPixel(x, error);
|
||||||
|
let luma = Math.round(rgb.luma() / 15);
|
||||||
|
let pick = luma;
|
||||||
|
|
||||||
// find the closest possible color
|
let diff = rgb.difference(atariRGB[palette[pick]]);
|
||||||
// @todo consider doing the difference scoring in luminance and hue spaces
|
|
||||||
shortest = Infinity;
|
|
||||||
let pick = 1;
|
|
||||||
|
|
||||||
for (let i = 0; i < palette.length; i++) {
|
|
||||||
let diff = rgb.difference(atariRGB[palette[i]]);
|
|
||||||
let dist = diff.magnitude();
|
let dist = diff.magnitude();
|
||||||
if (dist < shortest) {
|
|
||||||
nextError = diff;
|
nextError = diff;
|
||||||
shortest = dist;
|
shortest = dist;
|
||||||
pick = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output[x] = pick;
|
output[x] = pick;
|
||||||
distance += shortest;
|
distance += shortest;
|
||||||
|
|
Loading…
Reference in a new issue