Closed leeoniya closed 2 years ago
Hi Leon,
Thanks for your suggestions. It seems a global problem to name methods/classes in such way that user is able to use them intuitively.
I'm dreaming for web site where I can describe problem or insert piece of source code and take intuitive names :)
in readme sample: paletteQuantizer -> paletteBuilder paletteQuantizer.quantize() -> paletteBuilder.build()
Some additional research: 1) nQuant project: https://nquant.codeplex.com/ uses WuQuantizer class name for palette builder and palette-to-image applier.
However I think It is incorrect to say "Quantize Image" because image is not quantized by ditherers/palette appliers. Only palette (color) can be quantized. It is possible to say Quantize Image Colors, but in case of our libraries we have two separate processes (A. palette building, B. applying palette to image), so Quantize Image Colors is not useful for us.
2) ImageMagik: http://www.imagemagick.org/Usage/quantize/#dither color quantization, and what is used internally for all automatic color reduction
so, color quantization/color reduction phrases are used
3) Google A. Phrase "palette builder": It looks like this phrase most often used for color scheme builders
B. Phrases "palette quantizer" / "color quantizer" / "image quantizer" looks more appropriate.
So, I prefer to stay with "paletteQuantizer" naming
new IQ.Image.NearestNeighbour(distanceCalculator) -> new IQ.Reducer.NearestColor(distanceCalculator)
You are right! (for example, http://docs.gimp.org/en/glossary.html, Quantization paragraph)
imageDitherer -> imageReducer (or imageQuantizer), because not all reduction strategies use dithering imageQuantizer.quantize -> imageReducer.quantize(pointContainer, palette) (or imageReducer.reduce(...))
Good catch about ditherer! However imageReducer sounds for me like image dimensions reducer. For imageQuantizer please see above.
So I see some options here: imageDither -> imageColorReducer imageDither -> paletteToImageApplier imageDither -> paletteApplier
But both options looks ugly for me, may be you can suggest something better
What do you think?
Many Thanks
Hey Leon,
1st - thanks again for RgbQuant, without it Image-Quantization library was not possible I think :) Also thanks for beautiful picture I took for my README.md and for your support at times when github allowed to write personal private messages :)
Answering on https://github.com/ibezkrovnyi/image-quantization/pull/11#issuecomment-366856348:
Personally I don't like Builder
for reasons in book https://www.amazon.com/dp/0132350882.
all variations use the same function names of original implementation
buildColormap
https://github.com/jnordberg/gif.js/blob/master/src/TypedNeuQuant.jsprocess
because it has no special step "sample"/"learn" and "process" means learn & build color map https://github.com/timoxley/neuquantgetColormap
while class or entry function is always NeuQuant
color quantizer
http://www.ece.mcmaster.ca/~xwu/ palette quantizer
http://www.codeproject.com/Articles/66341/A-Simple-Yet-Quite-Powerful-Palette-Quantizer-in-CWuQuantizer
, GetQuantizedPalette
https://code.msdn.microsoft.com/windowsdesktop/Convert-32-bit-PNGs-to-81ef8c81/view/SourceCode#contentHere quantization
/quantizer
/quantized
words are used everywhere. Class is named as WuQuantizer
and function is GetQuantizedPalette
.
Btw, re using colormap
instead of palette: color map
is just palette
I hope I get your point right.
p.s. still confused that guide styles say me to rename:
NeuQuant
(not changed) - Neu is in Pascal Case
RGBQuant
(from RgbQuant
) - Because RGB is initialism
p.p.s. may be you have more ideas on project? What do you think about progress notification?
p.p.s. may be you have more ideas on project? What do you think about progress notification?
i think this project (as all image processing) is ripe for asm.js, WASM or something like http://evanw.github.io/thinscript/, http://gpu.rocks/, https://github.com/turbo/js rather than progress notifications (which would be unnecessary if perf was suddenly 10x ;)
@leeoniya for me it is possibility to finally use ES6 generators, ha-ha)
Re tools you mentioned, there is also https://github.com/AssemblyScript/assemblyscript (which is modified TypeScript which (with some assumptions) will generate WebAssembly (because of types presence)
performance is not so important if we are using library not in real time, but as automated tool to reduce colors in our image assets for example, or e.g. we are using it in another tool (like https://github.com/ibezkrovnyi/texturer)
@leeoniya hm, need to investigate turbo.js and gpu.js :) Thanks!
Regarding Rust or WASM: Maybe you don't need Rust and WASM to speed up your JS
@igor-bezkrovny, Here is some input on your naming conventions and possible renaming:
in readme sample:
paletteQuantizer -> paletteBuilder paletteQuantizer.quantize() -> paletteBuilder.build()
NearestNeighbour is a scaling method, so this name is not correct for this application, you should use another name. I was thinking maybe NearestColor, but even dithering methods use nearest color distance, maybe NoDither. I would also move all reducers to a Reducer namespace, so:
imageDitherer -> imageReducer (or imageQuantizer), because not all reduction strategies use dithering imageQuantizer.quantize -> imageReducer.quantize(pointContainer, palette) (or imageReducer.reduce(...))
new IQ.Image.NearestNeighbour(distanceCalculator) -> new IQ.Reducer.NearestColor(distanceCalculator)
for dithering you can use similar:
new IQ.Reducer.DitherDiffusion(distanceCalculator, kernel, strength,..) new IQ.Reducer.DitherOrdered(distanceCalculator, kernel,..) new IQ.Reducer.DitherPattern(distanceCalculator, kernel,..)