-
Notifications
You must be signed in to change notification settings - Fork 4
/
wrapper.go
43 lines (35 loc) · 1.19 KB
/
wrapper.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package hdr
import "github.com/mdouchement/hdr/hdrcolor"
//===============//
// LMS //
//===============//
// A LMSCAT02w wrapper hollows to get pixels in LMS-space using CIE CAT02 matrix.
// https://en.wikipedia.org/wiki/CIECAM02#Chromatic_adaptation
type LMSCAT02w struct {
Image
}
// NewLMSCAT02w instanciates a new LMSCAT02w wrapper.
func NewLMSCAT02w(m Image) *LMSCAT02w {
return &LMSCAT02w{Image: m}
}
// HDRAt returns the pixel in LMS-space using CIE CAT02 matrix.
func (p *LMSCAT02w) HDRAt(x, y int) hdrcolor.Color {
X, Y, Z, _ := p.Image.HDRAt(x, y).HDRXYZA()
L, M, S := hdrcolor.XyzToLmsMcat02(X, Y, Z)
return hdrcolor.RAW{P1: L, P2: M, P3: S}
}
// A LMSHPEw wrapper hollows to get pixels in LMS-space using Hunt-Pointer-Estevez matrix.
// https://en.wikipedia.org/wiki/LMS_color_space
type LMSHPEw struct {
Image
}
// NewLMSHPEw instanciates a new LMSHPE wrapper.
func NewLMSHPEw(m Image) *LMSHPEw {
return &LMSHPEw{Image: m}
}
// HDRAt returns the pixel in LMS-space using Hunt-Pointer-Estevez matrix.
func (p *LMSHPEw) HDRAt(x, y int) hdrcolor.Color {
X, Y, Z, _ := p.Image.HDRAt(x, y).HDRXYZA()
L, M, S := hdrcolor.XyzToLmsMhpe(X, Y, Z)
return hdrcolor.RAW{P1: L, P2: M, P3: S}
}