Giter Club home page Giter Club logo

apply-cube-lut's Introduction

apply-cube-lut

Apply a Cube (IRIDAS/Adobe) LUT to an image

Applies a Cube LUT to an image. See parse-cube-lut for Cube LUT parsing.

LUT files are useful for color grading, encapsulating complex color-space transforms or emulating film stock for photography and video.

Example

Photograph transformed with a Fuji 400H stock emulation LUT.

Install

$ npm install apply-cube-lut

Usage

var applyCubeLUT = require('apply-cube-lut');
var parseCubeLUT = require('parse-cube-lut');
var ndarrayFromImage  = require('ndarray-from-image');
var canvasFromNdarray = require('canvas-from-ndarray');
var ops = require('ndarray-ops');

var lutURL = 'test.cube';
var imgURL = 'test.jpg';

var req = new XMLHttpRequest();
var img = new Image();

req.onload = function() {
  img.onload = function() {

    // once both the image and LUT data are loaded
    var lut = parseCubeLUT(req.responseText);
    var arr = ndarrayFromImage(img, 'float32');

    // convert RGBA components to 0.0 -> 1.0
    ops.mulseq(arr, 1.0 / 255.0);

    // apply LUT
    applyCubeLUT(arr /* dest */, arr /* src */, lut);

    // convert back to 0.0 -> 255.0
    ops.mulseq(arr, 255.0);

    // display transformed image
    var canvas = canvasFromNdarray(arr);
    document.body.appendChild(canvas);
  };
  
  img.src = imgURL;
};

req.open('GET', lutURL, true);
req.send();

apply-cube-lut's People

Contributors

thibauts avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.