ibezkrovnyi / image-quantization

Image Quantization Library with alpha support (based on https://github.com/leeoniya/RgbQuant.js, https://github.com/timoxley/neuquant and http://www.ece.mcmaster.ca/~xwu/cq.c)
141 stars 11 forks source link

CIEDE2000 quality is poor after xyz2lab fix #5

Open ibezkrovnyi opened 8 years ago

ibezkrovnyi commented 8 years ago

Fixed many issues

  1. xyz2rgb.ts - result should not be truncated (intInRange), but rounded (roundIn8bit)
  2. lab2xyz.ts - refY should be 1.0000, not 0.1000
  3. xyz2lab.ts - refY should be 1.0000, not 0.1000
  4. CIEDE2000 was incorrectly optimized, found it after tests being added. Optimizations removed.

Before xyz2lab fix: image

After xyz2lab fix (change 3) quality of CIEDE2000 so poor now: image

What do you think, @Nommyde, @leeoniya? xyz2lab is used in rgb2lab, why incorrect xyz2lab produced good images, and correct one creates ugly?

leeoniya commented 8 years ago

@igor-bezkrovny sorry i'm pretty busy with other work these days and cannot dig into this further.

the shitty perf vs quality boost tradeoff for CIEDE2000 was too poor for me to pursue it to any great extent.

ibezkrovnyi commented 8 years ago

@leeoniya my vacation is also ended, so I will not be able to spend much time for projects

I agree with you, I think half of settings/distance formulas can be removed from code. But anyway, why formula with the best psycho-visual characteristics gives so poor results? Will leave it for education reasons, but will note in README about this.

Have you seen better algorithms (color distance/palette quantizers/...)? What do you think about scolorq (Spatial Color Quantizer)? Does it produce best palettes for less than 16 colors only? I tried it (windows/C++ version) for baby.jpg/256 colors and aborted it after 4 hours. How slow it will be in JS :)