|
CvtColor中RGB=>Lab (CV_BGR2Lab, CV_RGB2Lab) 变换矩阵元素值有些疑惑,与indiana 大学(http://cgi.cs.indiana.edu/~oleykin/website/OpenCVHelp/ref/OpenCVRef_Cv.htm#cv_imgproc_filters) 提供的变换矩阵元素值不同,该以哪个作为标准,为什么?还有indiana 大学代码中的Xn, Yn 和 Zn是参考白的三刺激值,代表什么含义。- 文档中内容:
- |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
- 上面的公式可以参考 http://www.cica.indiana.edu/cica/faq/color_spaces/color.spaces.html
复制代码- 网页http://cgi.cs.indiana.edu/~oleykin/website/OpenCVHelp/ref/OpenCVRef_Cv.htm#cv_imgproc_filters 中内容:
- RGB<=>CIE L*a*b* (CV_BGR2Lab, CV_RGB2Lab, CV_Lab2BGR, CV_Lab2RGB)
- // In case of 8-bit and 16-bit images
- // R, G and B are converted to floating-point format and scaled to fit 0..1 range
- // convert R,G,B to CIE XYZ
- |X| |0.412453 0.357580 0.180423| |R|
- |Y| <- |0.212671 0.715160 0.072169|*|G|
- |Z| |0.019334 0.119193 0.950227| |B|
- X <- X/Xn, where Xn = 0.950456
- Z <- Z/Zn, where Zn = 1.088754
- L <- 116*Y1/3 for Y>0.008856
- L <- 903.3*Y for Y<=0.008856
- a <- 500*(f(X)-f(Y)) + delta
- b <- 200*(f(Y)-f(Z)) + delta
- where f(t)=t1/3 for t>0.008856
- f(t)=7.787*t+16/116 for t<=0.008856
- where delta = 128 for 8-bit images,
- 0 for floating-point images
- On output 0≤L≤100, -127≤a≤127, -127≤b≤127
- The values are then converted to the destination data type:
- 8-bit images:
- L <- L*255/100, a <- a + 128, b <- b + 128
- 16-bit images are currently not supported
- 32-bit images:
- L, a, b are left as is
复制代码 |
|