Documentation ¶
Index ¶
- Variables
- func LMSToComps(l, m, s float32) (lc, mc, sc, lmc, lvm, svlm, grey float32)
- func LuminanceAdaptation(bgLum float32) float32
- func MacbethImage(img *etensor.Float32, width, height, bord int)
- func RGBImgToLMSComps(img image.Image, tsr *etensor.Float32, padWidth int, topZero bool)
- func RGBTensorToLMSComps(tsr *etensor.Float32, rgb *etensor.Float32)
- func ResponseCompression(val float32) float32
- func SRGBFmLinear(rl, gl, bl float32) (r, g, b float32)
- func SRGBFmLinearComp(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
- type Opponents
- type SRGBToOp
Constants ¶
This section is empty.
Variables ¶
var KiT_LMSComponents = kit.Enums.AddEnum(LMSComponentsN, kit.NotBitFlag, nil)
var KiT_Opponents = kit.Enums.AddEnum(OpponentsN, kit.NotBitFlag, nil)
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 SRGBFmLinear ¶
SRGBFmLinear converts set of sRGB components from linear values, adding gamma correction.
func SRGBFmLinearComp ¶
SRGBFmLinearComp 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 int
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 // number of components LMSComponentsN )
func (*LMSComponents) FromString ¶
func (i *LMSComponents) FromString(s string) error
func (LMSComponents) MarshalJSON ¶
func (ev LMSComponents) MarshalJSON() ([]byte, error)
func (LMSComponents) String ¶
func (i LMSComponents) String() string
func (*LMSComponents) UnmarshalJSON ¶
func (ev *LMSComponents) UnmarshalJSON(b []byte) error
type Opponents ¶ added in v1.1.11
type Opponents int
Opponents enumerates the three primary opponency channels: WhiteBlack, RedGreen, BlueYellow using colloquial "everyday" terms.
func (*Opponents) FromString ¶ added in v1.1.11
func (Opponents) MarshalJSON ¶ added in v1.1.11
func (*Opponents) UnmarshalJSON ¶ added in v1.1.11
type SRGBToOp ¶
type SRGBToOp struct { // number of levels in the lookup table -- linear interpolation used Levels int `desc:"number of levels in the lookup table -- linear interpolation used"` // lookup table Table etensor.Float32 `desc:"lookup table"` }
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