mattdesl / atcq Goto Github PK
View Code? Open in Web Editor NEWAn implementation of Ant-Tree Color Quantization
License: MIT License
An implementation of Ant-Tree Color Quantization
License: MIT License
This is super cool and I'm excited that you open-sourced it! I'm coming from a python background and I'd like to use the output somehow as a starting point for other programs. Is there a way to call this from the command line so I can script it? I tried using nodejs, but I got stuck trying to require the library properly.
Feel free to close it as this may be out of scope for supporting this use case.
const ATCQ = require('./atcq.js');
var getPixels = require("get-pixels");
var f_image = "./sample_image_small.jpg";
var pixels = getPixels(f_image, function(err, pixels) {
if(err) {
console.log("Bad image path")
return;
}
console.log("got pixels", pixels)
const palette = ATCQ.quantizeSync(pixels, {
maxColors: 32
});
console.log(palette);
});
Which gave:
nodejs demo.js
got pixels View3dbuffer {
data: <Buffer fe f9 f1 ff fe f9 ef ff fe f9 ef ff fc fa ed ff fd fb ee ff fe fc f1 ff fe fc f3 ff fd fb f2 ff fb fb ef ff fb fb ef ff fb fb f1 ff fb fb f1 ff fb fb ... >,
shape: [ 200, 284, 4 ],
stride: [ 4, 800, 1 ],
offset: 0 }
/home/hoppeta/projects/palette/atcq/atcq.js:16
atcq.quantize();
^
TypeError: atcq.quantize is not a function
at Function.quantizeSync (/home/hoppeta/projects/palette/atcq/atcq.js:16:8)
at /home/hoppeta/projects/palette/atcq/demo.js:19:26
at handleJPEG (/home/hoppeta/projects/palette/atcq/node_modules/get-pixels/node-pixels.js:44:3)
at doParse (/home/hoppeta/projects/palette/atcq/node_modules/get-pixels/node-pixels.js:114:7)
at /home/hoppeta/projects/palette/atcq/node_modules/get-pixels/node-pixels.js:190:7
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:511:3)
I'm using the library to generate a palette for every image in a movie. For most images with a diverse palette the computation time is 4-5 seconds. However, for images with very little variation, like the credits at the end of a movie, the computation can take a minute or more. Is there a way to shortcut the algorithm if it can't build a proper palette?
>> time nodejs extract.js baboon.png
real 0m4.877s
user 0m5.145s
sys 0m0.102s
>> time nodejs extract.js 00000000.jpg
[{"weight":1,"hex":"#000000","R":0,"G":0,"B":0}]
real 1m41.776s
user 1m36.971s
sys 0m0.092s
The input image is attached here, the worst-case scenario for an all black screen
Experimenting with maxColors
or targetColors
doesn't seem to make a difference in the output.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.