RGB conversion formula for different color space

xiaoxiao2021-03-06  74

RGB conversion formula for different color space

Mutual conversion RGB <-> Gray: RGB [A] -> Gray: y = 0.212671 * R 0.715160 * G 0.072169 * B

Gray-> RGB [A]: r = y g = y b = y A = 0

Other mutual transformation formulas of all possible image color space are listed below: RGB <=> XYZ: | X | 0.412411 0.357585 0.180454 | R |

| Y | = | 0.212649 0.715169 0.072182 | * | g |

| Z | 0.019332 0.119195 0.950390 | | B |

| R | 3.240479 -1.53715 -0.498535 | | x |

| G | = | -0.969256 1.875991 0.041556 | * | Y |

| B | 0.055648 -0.204043 1.057311 | | z | RGB <=> YCRCB Y = 0.299 * R 0.587 * G 0.114 * B

Cr = (r-y) * 0.713 128

CB = (b-y) * 0.564 128

R = Y 1.403 * (CR - 128)

G = Y - 0.344 * (CR - 128) - 0.714 * (CB - 128)

B = Y 1.773 * (CB - 128)

RGB => HSV V = Max (R, G, B)

S = (V-min (r, g, b)) * 255 / v if v! = 0, 0 Otherwise

(G - b) * 60 / s, if v = r

H = 180 (B - r) * 60 / s, if v = g

240 (r - g) * 60 / s, if v = B

If h <0, H = H 360

The color tone (hue) value is calculated using the formula from 0 ° to 360 °, ensuring that they can be tried to 8 bits after 2. RGB => lab | x | | 0.433910 0.376220 0.189860 | R / 255 |

| Y | = | 0.212649 0.715169 0.072182 | * | g / 255 |

| Z | 0.017756 0.109478 0.872915 | | B / 255 |

L = 116 * Y1 / 3 for y> 0.008856

L = 903.3 * y for y <= 0.008856

A = 500 * (f (x) -f (y))

B = 200 * (f (y) -f (z))

Where f (t) = T1 / 3 for t> 0.008856

f (t) = 7.787 * T 16/116 for t <= 0.008856

(Transfer from a mustum: http://www.assuredigit.com/forum)

转载请注明原文地址:https://www.9cbs.com/read-121165.html

New Post(0)