Documentation ¶
Index ¶
- func LMSToComps(l, m, s float32) (lc, mc, sc, lmc, lvm, svlm, grey float32)
- func LuminanceAdaptation(bgLum float32) float32
- func MacbethImage(img *tensor.Float32, width, height, bord int)
- func RGBImgToLMSComps(img image.Image, tsr *tensor.Float32, padWidth int, topZero bool)
- func RGBTensorToLMSComps(tsr *tensor.Float32, rgb *tensor.Float32)
- func ResponseCompression(val float32) float32
- func SRGBFromLinear(rl, gl, bl float32) (r, g, b float32)
- func SRGBFromLinearComp(lin float32) float32
- func SRGBLinToLMS_CAT02(rl, gl, bl float32) (l, m, s float32)
- func SRGBLinToLMS_HPE(rl, gl, bl float32) (l, m, s float32)
- func SRGBLinToXYZ(rl, gl, bl float32) (x, y, z float32)
- func SRGBToLMSComps(r, g, b float32) (lc, mc, sc, lmc, lvm, svlm, grey float32)
- func SRGBToLMS_CAT02(r, g, b float32) (l, m, s float32)
- func SRGBToLMS_HPE(r, g, b float32) (l, m, s float32)
- func SRGBToLinear(r, g, b float32) (rl, gl, bl float32)
- func SRGBToLinearComp(srgb float32) float32
- func SRGBToXYZ(r, g, b float32) (x, y, z float32)
- func XYZRenormD65(x, y, z float32) (xr, yr, zr float32)
- func XYZToLMS_CAT02(x, y, z float32) (l, m, s float32)
- func XYZToLMS_HPE(x, y, z float32) (l, m, s float32)
- func XYZToSRGB(x, y, z float32) (r, g, b float32)
- func XYZToSRGBLin(x, y, z float32) (rl, gl, bl float32)
- type LMSComponents
- func (i LMSComponents) Desc() string
- func (i LMSComponents) Int64() int64
- func (i LMSComponents) MarshalText() ([]byte, error)
- func (i *LMSComponents) SetInt64(in int64)
- func (i *LMSComponents) SetString(s string) error
- func (i LMSComponents) String() string
- func (i *LMSComponents) UnmarshalText(text []byte) error
- func (i LMSComponents) Values() []enums.Enum
- type Opponents
- func (i Opponents) Desc() string
- func (i Opponents) Int64() int64
- func (i Opponents) MarshalText() ([]byte, error)
- func (i *Opponents) SetInt64(in int64)
- func (i *Opponents) SetString(s string) error
- func (i Opponents) String() string
- func (i *Opponents) UnmarshalText(text []byte) error
- func (i Opponents) Values() []enums.Enum
- type SRGBToOp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LMSToComps ¶
LMSToComps converts Long, Medium, Short cone-based responses to components incl opponents: Red - Green (LvM) and Blue - Yellow (SvLM). Includes the separate components in these subtractions as well Uses the CIECAM02 color appearance model (MoroneyFairchildHuntEtAl02) https://en.wikipedia.org/wiki/CIECAM02
func LuminanceAdaptation ¶
LuminanceAdaptation implements the luminance adaptation function equals 1 at background luminance of 200 so we generally ignore it.. bgLum is background luminance -- 200 default.
func MacbethImage ¶
MacbethImage sets the Macbeth standard color test image to given tensor with given size and border width around edges. if img == nil it is created, and size enforced.
func RGBImgToLMSComps ¶
RGBImgLMSComps converts an RGB image to corresponding LMS components including color opponents, with components as the outer-most dimension. padWidth is the amount of padding to add on all sides. topZero retains the Y=0 value at the top of the tensor -- otherwise it is flipped with Y=0 at the bottom to be consistent with the emergent / OpenGL standard coordinate system
func RGBTensorToLMSComps ¶
RGBTensorToLMSComps converts an RGB Tensor to corresponding LMS components including color opponents, with components as the outer-most dimension, and assumes rgb is 3 dimensional with outer-most dimension as RGB.
func ResponseCompression ¶
ResponseCompression takes a 0-1 normalized LMS value and performs hyperbolic response compression. val must ALREADY have the luminance adaptation applied to it using the luminance adaptation function, which is 1 at a background luminance level of 200 = 2, so you can skip that step if you assume that level of background.
func SRGBFromLinear ¶
SRGBFromLinear converts set of sRGB components from linear values, adding gamma correction.
func SRGBFromLinearComp ¶
SRGBFromLinearComp converts an sRGB rgb linear component to non-linear (gamma corrected) sRGB value Used in converting from XYZ to sRGB.
func SRGBLinToLMS_CAT02 ¶
SRGBLinToLMS_CAT02 converts sRGB linear to Long, Medium, Short cone-based responses, using the CAT02 transform from CIECAM02 color appearance model (MoroneyFairchildHuntEtAl02) this is good for representing adaptation but NOT apparently good for representing appearances
func SRGBLinToLMS_HPE ¶
SRGBLinToLMS_HPE converts sRGB linear to Long, Medium, Short cone-based responses, using the Hunt-Pointer-Estevez transform. This is closer to the actual response functions of the L,M,S cones apparently.
func SRGBLinToXYZ ¶
SRGBLinToXYZ converts sRGB linear into XYZ CIE standard color space
func SRGBToLMSComps ¶
SRGBToLMSComps converts sRGB to LMS components including opponents using the HPE cone values: Red - Green (LvM) and Blue - Yellow (SvLM). Includes the separate components in these subtractions as well. Uses the CIECAM02 color appearance model (MoroneyFairchildHuntEtAl02) https://en.wikipedia.org/wiki/CIECAM02 using the Hunt-Pointer-Estevez transform.
func SRGBToLMS_CAT02 ¶
SRGBToLMS_CAT02 converts sRGB to Long, Medium, Short cone-based responses, using the CAT02 transform from CIECAM02 color appearance model (MoroneyFairchildHuntEtAl02)
func SRGBToLMS_HPE ¶
SRGBToLMS_HPE converts sRGB to Long, Medium, Short cone-based responses, using the Hunt-Pointer-Estevez transform. This is closer to the actual response functions of the L,M,S cones apparently.
func SRGBToLinear ¶
SRGBToLinear converts set of sRGB components to linear values, removing gamma correction.
func SRGBToLinearComp ¶
SRGBToLinearComp converts an sRGB rgb component to linear space (removes gamma). Used in converting from sRGB to XYZ colors.
func XYZRenormD65 ¶
#CAT_ColorSpace renormalize XZY values relative to the D65 outdoor white light values
func XYZToLMS_CAT02 ¶
XYZToLMS_CAT02 converts XYZ to Long, Medium, Short cone-based responses, using the CAT02 transform from CIECAM02 color appearance model (MoroneyFairchildHuntEtAl02)
func XYZToLMS_HPE ¶
XYZToLMS_HPE convert XYZ to Long, Medium, Short cone-based responses, using the Hunt-Pointer-Estevez transform. This is closer to the actual response functions of the L,M,S cones apparently.
func XYZToSRGBLin ¶
XYZToSRGBLin converts XYZ CIE standard color space to sRGB linear
Types ¶
type LMSComponents ¶
type LMSComponents int32 //enums:enum
LMSComponents are different components of the LMS space including opponent contrasts and grey
const ( // Long wavelength = Red component LC LMSComponents = iota // Medium wavelength = Green component MC // Short wavelength = Blue component SC // Long + Medium wavelength = Yellow component LMC // L - M opponent contrast: Red vs. Green LvMC // S - L+M opponent contrast: Blue vs. Yellow SvLMC // achromatic response (grey scale lightness) GREY )
const LMSComponentsN LMSComponents = 7
LMSComponentsN is the highest valid value for type LMSComponents, plus one.
func LMSComponentsValues ¶
func LMSComponentsValues() []LMSComponents
LMSComponentsValues returns all possible values for the type LMSComponents.
func (LMSComponents) Desc ¶
func (i LMSComponents) Desc() string
Desc returns the description of the LMSComponents value.
func (LMSComponents) Int64 ¶
func (i LMSComponents) Int64() int64
Int64 returns the LMSComponents value as an int64.
func (LMSComponents) MarshalText ¶
func (i LMSComponents) MarshalText() ([]byte, error)
MarshalText implements the encoding.TextMarshaler interface.
func (*LMSComponents) SetInt64 ¶
func (i *LMSComponents) SetInt64(in int64)
SetInt64 sets the LMSComponents value from an int64.
func (*LMSComponents) SetString ¶
func (i *LMSComponents) SetString(s string) error
SetString sets the LMSComponents value from its string representation, and returns an error if the string is invalid.
func (LMSComponents) String ¶
func (i LMSComponents) String() string
String returns the string representation of this LMSComponents value.
func (*LMSComponents) UnmarshalText ¶
func (i *LMSComponents) UnmarshalText(text []byte) error
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (LMSComponents) Values ¶
func (i LMSComponents) Values() []enums.Enum
Values returns all possible values for the type LMSComponents.
type Opponents ¶
type Opponents int32 //enums:enum
Opponents enumerates the three primary opponency channels: WhiteBlack, RedGreen, BlueYellow using colloquial "everyday" terms.
const OpponentsN Opponents = 3
OpponentsN is the highest valid value for type Opponents, plus one.
func OpponentsValues ¶
func OpponentsValues() []Opponents
OpponentsValues returns all possible values for the type Opponents.
func (Opponents) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*Opponents) SetString ¶
SetString sets the Opponents value from its string representation, and returns an error if the string is invalid.
func (*Opponents) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
type SRGBToOp ¶
type SRGBToOp struct { // number of levels in the lookup table -- linear interpolation used Levels int // lookup table Table tensor.Float32 }
SRGBToOp implements a lookup-table for the conversion of SRGB components to LMS color opponent values. After all this, it looks like the direct computation is faster than the lookup table! In any case, it is all here and reasonably accurate (mostly under 1.0e-4 according to testing)
var TheSRGBToOp SRGBToOp
TheSRGBToOp is the instance of SRGBToOp to use