Socket
Socket
Sign inDemoInstall

color-space

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-space - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

jpeg.js

1

index.js

@@ -24,2 +24,3 @@ /**

ypbpr: require('./ypbpr'),
ycbcr: require('./ycbcr'),
lab: require('./lab'),

@@ -26,0 +27,0 @@ labh: require('./labh'),

2

package.json
{
"name": "color-space",
"description": "Color space conversions and data",
"version": "1.7.0",
"version": "1.8.0",
"author": "Deema Yvanow <dfcreative@gmail.com>",

@@ -6,0 +6,0 @@ "keywords": [

@@ -62,6 +62,8 @@ # Color-space [![Build Status](https://travis-ci.org/dfcreative/color-space.svg?branch=master)](https://travis-ci.org/dfcreative/color-space) [![Code Climate](https://codeclimate.com/github/dfcreative/color-space/badges/gpa.svg)](https://codeclimate.com/github/dfcreative/color-space) [![stable](http://badges.github.io/stability-badges/dist/stable.svg)](http://github.com/badges/stability-badges)

* [x] [YIQ](https://en.wikipedia.org/?title=YIQ)
* [x] [YDbDr](https://en.wikipedia.org/wiki/YDbDr)
* [x] [YPbPr](https://en.wikipedia.org/wiki/YPbPr)
* [ ] [YCbCr](https://en.wikipedia.org/wiki/YCbCr)
* [ ] [YCgCo](https://en.wikipedia.org/wiki/YCgCo)
* [ ] [YC<sub>g</sub>C<sub>o</sub>](https://en.wikipedia.org/wiki/YCgCo)
* [x] [YD<sub>b</sub>D<sub>r</sub>](https://en.wikipedia.org/wiki/YDbDr)
* [x] [YP<sub>b</sub>P<sub>r</sub>](https://en.wikipedia.org/wiki/YPbPr)
* [x] [YC<sub>b</sub>C<sub>r</sub>](https://en.wikipedia.org/wiki/YCbCr)
* [ ] [Y<sub>c</sub>C<sub>bc</sub>C<sub>rc</sub>](https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.2020_conversion)
* [ ] [JPEG](https://en.wikipedia.org/wiki/YCbCr#JPEG_conversion)
* [ ] [XvYCC](https://en.wikipedia.org/wiki/XvYCC)

@@ -68,0 +70,0 @@ * [ ] [UVW](https://en.wikipedia.org/wiki/CIE_1964_color_space)

/**
* https://en.wikipedia.org/?title=YCbCr
*
* YCbCr is a digital form of YPbPr conversion
* Thence limits are [16...235], according to the ITU-R BT.709 or ITU-R BT.601
*
* @module color-space/ycbcr

@@ -8,9 +11,10 @@ */

var rgb = require('./rgb');
var ypbpr = require('./ypbpr');
var ycbcr = module.exports = {
name: 'ycbcr',
min: [0,-0.5,-0.5],
max: [1, 0.5, 0.5],
min: [16, 16, 16],
max: [235, 240, 240],
channel: ['Y','Cb','Cr'],
alias: ['YCbCr']
alias: ['YCbCr', 'YCC']
};

@@ -20,10 +24,43 @@

/**
* UVW to RGB
* From analog to digital form.
* Simple scale to min/max ranges
*
* @return {Array} Resulting digitized form
*/
ypbpr.ycbcr = function (ypbpr) {
var y = ypbpr[0], pb = ypbpr[1], pr = ypbpr[2];
return [
16 + 219 * y,
128 + 224 * pb,
128 + 224 * pr
];
}
/**
* From digital to analog form.
* Scale to min/max ranges
*/
ycbcr.ypbpr = function (ycbcr) {
var y = ycbcr[0], cb = ycbcr[1], cr = ycbcr[2];
return [
(y - 16) / 219,
(cb - 128) / 224,
(cr - 128) / 224
];
}
/**
* YCbCr to RGB
* transform through analog form
*
* @param {Array} ycbcr RGB values
*
* @return {Array} UVW values
* @return {Array} YCbCr values
*/
ycbcr.rgb = function(ycbcr) {
ycbcr.rgb = function (arr, kb, kr) {
return ypbpr.rgb(ycbcr.ypbpr(arr), kb, kr);
};

@@ -33,10 +70,11 @@

/**
* RGB to UVW
* RGB to YCbCr
* transform through analog form
*
* @param {Array} ycbcr UVW values
* @param {Array} ycbcr YCbCr values
*
* @return {Array} RGB values
*/
rgb.ycbcr = function(rgb) {
rgb.ycbcr = function(arr, kr, kb) {
return ypbpr.ycbcr(rgb.ypbpr(arr, kb, kr));
};
/**
* https://en.wikipedia.org/?title=YPbPr
*
* HDTV conversion is used
* YPbPr is analog form of YCbCr
* hence limits are [0..1]
*
* Default conversion is ITU-R BT.709
*
* @module color-space/ypbpr

@@ -13,4 +16,4 @@ */

name: 'ypbpr',
min: [0,-1.333,-1.333],
max: [1, 1.333, 1.333],
min: [0,-0.5,-0.5],
max: [1, 0.5, 0.5],
channel: ['Y','Pb','Pr'],

@@ -28,14 +31,14 @@ alias: ['YPbPr', 'Y/PB/PR', 'YPRPB', 'PRPBY', 'PBPRY', 'Y/Pb/Pr', 'YPrPb', 'PrPbY', 'PbPrY', 'Y/R-Y/B-Y', 'Y(R-Y)(B-Y)', 'R-Y', 'B-Y']

*/
ypbpr.rgb = function(ypbpr) {
ypbpr.rgb = function(ypbpr, kb, kr) {
var y = ypbpr[0], pb = ypbpr[1], pr = ypbpr[2];
var r = pr + y;
var b = pb + y;
var g = (y - 0.2126*r - 0.0722*b) / 0.7152;
//default conversion is ITU-R BT.709
kb = kb || 0.0722;
kr = kr || 0.2126;
return [
r * 255,
g * 255,
b * 255
];
var r = y + 2 * pr * (1 - kr);
var b = y + 2 * pb * (1 - kb);
var g = (y - kr * r - kb * b) / (1 - kr - kb);
return [r*255,g*255,b*255];
};

@@ -51,12 +54,14 @@

*/
rgb.ypbpr = function(rgb) {
rgb.ypbpr = function(rgb, kb, kr) {
var r = rgb[0]/255, g = rgb[1]/255, b = rgb[2]/255;
var y = 0.2126 * r + 0.7152 * g + 0.0722 * b;
//ITU-R BT.709
kb = kb || 0.0722;
kr = kr || 0.2126;
return [
y,
b - y,
r - y
];
var y = kr*r + (1 - kr - kb)*g + kb*b;
var pb = 0.5 * (b - y) / (1 - kb);
var pr = 0.5 * (r - y) / (1 - kr);
return [y, pb, pr];
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc