Documentation ¶
Overview ¶
Package ycbcr provides images from the Y'CbCr color model.
JPEG, VP8, the MPEG family and other codecs use this color model. Such codecs often use the terms YUV and Y'CbCr interchangeably, but strictly speaking, the term YUV applies only to analog video signals.
Conversion between RGB and Y'CbCr is lossy and there are multiple, slightly different formulae for converting between the two. This package follows the JFIF specification at http://www.w3.org/Graphics/JPEG/jfif3.pdf.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var YCbCrColorModel image.ColorModel = image.ColorModelFunc(toYCbCrColor)
YCbCrColorModel is the color model for YCbCrColor.
Functions ¶
func RGBToYCbCr ¶
RGBToYCbCr converts an RGB triple to a YCbCr triple. All components lie within the range [0, 255].
Types ¶
type SubsampleRatio ¶
type SubsampleRatio int
SubsampleRatio is the chroma subsample ratio used in a YCbCr image.
const ( SubsampleRatio444 SubsampleRatio = iota SubsampleRatio422 SubsampleRatio420 )
type YCbCr ¶
type YCbCr struct { Y []uint8 Cb []uint8 Cr []uint8 YStride int CStride int SubsampleRatio SubsampleRatio Rect image.Rectangle }
YCbCr is an in-memory image of YCbCr colors. There is one Y sample per pixel, but each Cb and Cr sample can span one or more pixels. YStride is the Y slice index delta between vertically adjacent pixels. CStride is the Cb and Cr slice index delta between vertically adjacent pixels that map to separate chroma samples. It is not an absolute requirement, but YStride and len(Y) are typically multiples of 8, and:
For 4:4:4, CStride == YStride/1 && len(Cb) == len(Cr) == len(Y)/1. For 4:2:2, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/2. For 4:2:0, CStride == YStride/2 && len(Cb) == len(Cr) == len(Y)/4.
func (*YCbCr) ColorModel ¶
func (p *YCbCr) ColorModel() image.ColorModel
type YCbCrColor ¶
type YCbCrColor struct {
Y, Cb, Cr uint8
}
YCbCrColor represents a fully opaque 24-bit Y'CbCr color, having 8 bits for each of one luma and two chroma components.