YCbCr
Digital video component signals
Also written Y'CbCr, Y Pb/Cb Pr/Cr, YCBCR, or Y'CBCR.
- Y' = luma and sync (brightness/luminance and syncrhonization)
- Cb = difference between blue and luma (B - Y)
- Cr = difference between red and luma (R - Y)
YCbCr conversions require Kb and Kr constants with the exception of converting to YPbPr. These values are not yet included in this package.
- Kb = constant defined from target color space, such that Kb + Kr + Kg = 1
- Kr = constant defined from target color space, such that Kb + Kr + Kg = 1
Upper and lower bounds vary with color space. It's recommended to always supply these values.
New Color
Color.from('ycbcr', [y, cb, cr], {
yLower: number, // optional, default = 16, lower bounds of Y'
yUpper: number, // optional, default = 235, upper bounds of Y'
cLower: number, // optional, default = 16, lower bounds of Cb and Cr
cUpper: number // optional, default = 240, upper bounds of Cb and Cr
)
Conversion to
.to('ycbcr',{
kb: number, // REQUIRED
kr: number // REQUIRED
})
YPbPr conversion
.to('ypbpr',{
yLower: number, // optional, default = 16, lower bounds of Y'
yUpper: number, // optional, default = 235, upper bounds of Y'
cLower: number, // optional, default = 16, lower bounds of Cb and Cr
cUpper: number // optional, default = 240, upper bounds of Cb and Cr
})
Get methods
.getY(): number
.getCb(): number
.getCr(): number
.getYLower(): number
.getYUpper(): number
.getCLower(): number
.getCUpper(): number
JavaScript
const Color = require('chromaticity-color-utilities')
const color1 = Color.from('ycbcr', [73, 226, 243])
const color3 = color2.to('ycbcr', {
kb: 0.0722, // Rec709
kr: 0.2126, // Rec709
})
const color4 = color1.to('ypbpr')
const color5 = color1.to('ypbpr', {
yLower: 0,
yUpper: 255,
cLower: 0,
cUpper: 255,
})
TypeScript
import Color from 'chromaticity-color-utilities'
const c: Color.ycbcr = Color.from('ycbcr', [73, 226, 243])