ycbcr

package
v0.0.0-...-e758773 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2011 License: BSD-3-Clause Imports: 1 Imported by: 0

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

View Source
var YCbCrColorModel image.ColorModel = image.ColorModelFunc(toYCbCrColor)

YCbCrColorModel is the color model for YCbCrColor.

Functions

func RGBToYCbCr

func RGBToYCbCr(r, g, b uint8) (uint8, uint8, uint8)

RGBToYCbCr converts an RGB triple to a YCbCr triple. All components lie within the range [0, 255].

func YCbCrToRGB

func YCbCrToRGB(y, cb, cr uint8) (uint8, uint8, uint8)

YCbCrToRGB converts a YCbCr triple to an RGB 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) At

func (p *YCbCr) At(x, y int) image.Color

func (*YCbCr) Bounds

func (p *YCbCr) Bounds() image.Rectangle

func (*YCbCr) ColorModel

func (p *YCbCr) ColorModel() image.ColorModel

func (*YCbCr) Opaque

func (p *YCbCr) Opaque() bool

func (*YCbCr) SubImage

func (p *YCbCr) SubImage(r image.Rectangle) image.Image

SubImage returns an image representing the portion of the image p visible through r. The returned value shares pixels with the original image.

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.

func (YCbCrColor) RGBA

func (c YCbCrColor) RGBA() (uint32, uint32, uint32, uint32)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL