Skip to content

HSI out of bounds values and hue shifting #38

Open
@jtlapp

Description

@jtlapp

The HSI conversion will take valid intensity values and convert them to RGB bytes > 255.

Also, shifting the intensity by a small amount can produce a rather large change in hue.

const cs = require('color-space');

console.log('HSI:');
let rgb1 = [ 0xb7, 0xc7, 0xff ];
let hsi = cs.rgb.hsi(rgb1);
let rgb2 = cs.hsi.rgb(hsi);
console.log(`     from RGB ${round(rgb1)} to HSI ${round(hsi)}`);
console.log(`  back to RGB ${round(rgb2)}`);
hsi[2] += 6;
let rgb3 = cs.hsi.rgb(hsi);
console.log(`  i+=6 to RGB ${round(rgb3)}`);

function round(vals) {
    return [Math.round(vals[0]), Math.round(vals[1]), Math.round(vals[2])];
}

Yields:

HSI:
     from RGB 183,199,255 to HSI 228,14,212
  back to RGB 183,199,255
  i+=6 to RGB 188,205,262

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions