Note for later : Test a variety of lossless colorspace conversions and see which performs best :-)
- G, R-G, B-G
This one is the simplest !
; encoding
Y = G
Cb = B - G
Cr = R-G
; decoding
G = Y
B = Cb - Y
R = Cr - Y
Latency is 1 addition (1 cycle). 8-bits components wrap around on overflow.- Reversible Color Transform (RCT)
https://en.wikipedia.org/wiki/JPEG_2000#Color_components_transformation
; encoding
Y = ( R + 2G + B) >> 2
Cb = B - G
Cr = R - G
; decoding
G = Y - ((Cb + Cr)>>4)
R = Cr + G
B = Cb + G
That one is very nice, encoding takes 1 cycle and decoding 2 cycles. Is it more efficient than the previous one ?- YCoCg
It's a bit different https://software.intel.com/en-us/node/503873
; coding
Y = R/4 + G/2 + B/4
Co = R/2 - B/2
Cg = -R/4 + G/2 - B/4
; or better :
t = (R + B) >> 1
Co = (R - B) >> 1 ; I have to find an "add-sub" circuit, but A+B and A-B have the same LSB
Y = (G + t ) >> 1
Cg = (G - t) >> 1
; decoding
R = Y + Co - Cg
G = Y + Cg
B = Y - Co - Cg
Coding and decoding use 4 add or sub each but more bits are needed to preserve perfect reversibility.
- YCoCG24
I love this one. I'm not sure who designed it first, it uses a different lifting scheme that preserves reversibility
; encoding
Co = B - R
R = R + Co>>1
Cg = R - G
Y = G + Cg>>1
; decoding
G = Y - Cg>>1
Cg = Cg + Y
R = Cg - Co>>1
Cg = Co + R
It is perfectly reversible at the price of a longer critical datapath.
Which of those transforms is the best in practice ?
20170529:
See the solution at colorspace decomposition
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.