image-lut
Image Lookup Table library for Node.js
Install
$ npm install image-lut
Examples
See the examples folder or test.js for how to use the image-lut.
Countries Lookup by Lat/Lon
An image with the countries of the world is used to look up country names by latitude/langitude. The image has to be equirectangular projected and every country has to have an unique RGB value.
var ImageLUT = ImageLUT;var lut = ; var countries = // "R/G/B/A" -> value "138/138/138/255": "Luxembourg" "82/82/82/255": "United Kingdom"; lut;
(examples/countries.js)
API
ImageLUT
.init(dict, imagePath, callback)
.initSync(dict, imagePath)
.domain(xStart, xEnd, yStart, yEnd)
optional, like d3.domain to set the input domain of the coordinates of the image.lookup(x,y)
-> value.color(x,y)
-> [r,g,b,a] array.size()
-> image width, hight and channels count.pixel(x,y)
-> RBGA values 4 x 8bit encoded into a single number
Helpers
numberToRgb(rgba)
-> [r,g,b,a] arrayrgbToNumber(r, g, b, a)
-> rgba number
Tests
$ npm install
$ npm test
Acknowledgments
- image-lut is based on the ideas of Images as datastore by Moritz Stefaner and Stephan & Steffen from Studio NAND
- png reading via pngparse