mct

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package mct implements the Multi-Component Transform (MCT) defined by ISO/IEC 15444-1 §F.4.9 for JPEG 2000.

Two transforms are specified:

  • RCT (Reversible Component Transform): integer-to-integer, used in conjunction with the 5/3 reversible wavelet. It is exactly reversible on integer inputs of arbitrary precision.
  • ICT (Irreversible Component Transform): floating-point, used with the 9/7 irreversible wavelet. It is the standard BT.601 / JFIF Y'CbCr matrix and is round-trip accurate to within float64 rounding.

Both transforms operate on three components (R, G, B). The JPEG 2000 codestream COD marker's MCT flag indicates whether to apply them; the choice of transform is derived from the wavelet kernel: 5/3 → RCT, 9/7 → ICT.

Reference: ISO/IEC 15444-1:2019 §F.4.9 (Equations F.25 through F.32).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForwardICT

func ForwardICT(r, g, b, y, cb, cr []float64)

ForwardICT applies the irreversible component transform (BT.601 / JFIF matrix) to R, G, B producing Y, Cb, Cr floating-point components. All slice arguments must have the same length.

Y  =  0.299*R + 0.587*G + 0.114*B
Cb = -0.16875*R - 0.33126*G + 0.5*B
Cr =  0.5*R - 0.41869*G - 0.08131*B

func ForwardICTInPlace

func ForwardICTInPlace(r, g, b []float64)

ForwardICTInPlace is the float64 analogue of ForwardRCTInPlace.

func ForwardRCT

func ForwardRCT(r, g, b, y, u, v []int32)

ForwardRCT applies the reversible component transform to interleaved or planar R, G, B components and writes the results into y, u, v. All four slice arguments must have the same length (the number of samples per component).

Y = ⌊(R + 2G + B) / 4⌋
U = B − G
V = R − G

The transform is exactly invertible by InverseRCT.

func ForwardRCTInPlace

func ForwardRCTInPlace(r, g, b []int32)

ForwardRCTInPlace is a convenience wrapper that rewrites the R, G, B component slices with the Y, U, V output. The caller passes the same three slices; on return r holds Y, g holds U, b holds V.

func InverseICT

func InverseICT(y, cb, cr, r, g, b []float64)

InverseICT applies the inverse irreversible component transform, recovering R, G, B from Y, Cb, Cr. All slice arguments must have the same length.

R = Y + 1.402*Cr
G = Y - 0.34413*Cb - 0.71414*Cr
B = Y + 1.772*Cb

func InverseICTInPlace

func InverseICTInPlace(r, g, b []float64)

InverseICTInPlace is the in-place inverse of ForwardICTInPlace.

func InverseRCT

func InverseRCT(y, u, v, r, g, b []int32)

InverseRCT applies the inverse reversible component transform, recovering R, G, B from Y, U, V components. All six slice arguments must have the same length.

G = Y − ⌊(U + V) / 4⌋
R = V + G
B = U + G

InverseRCT(ForwardRCT(R,G,B)) is the identity for every int32 input.

func InverseRCTInPlace

func InverseRCTInPlace(r, g, b []int32)

InverseRCTInPlace is the in-place inverse of ForwardRCTInPlace. On entry r holds Y, g holds U, b holds V; on return r/g/b hold the recovered R/G/B.

Types

This section is empty.

Jump to

Keyboard shortcuts

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