我正在尝试使用文档中提供的功能将Mat表示具有8位深度的RGB图像的给定转换为Lab:
cvtColor(source, destination, <conversion code>);
Run Code Online (Sandbox Code Playgroud)
我尝试了以下转换代码:
CV_RGB2Lab
CV_BGR2Lab
CV_LBGR2Lab
Run Code Online (Sandbox Code Playgroud)
我每次都收到奇怪的结果,某些样本的"L"值大于100,字面上<107,125,130>.
我也使用Photoshop检查结果 - 但鉴于107超出0≤L≤100的可接受范围,我无法理解我的错误是什么.
更新: 我将在此处发布我的整体结果:给定由8位BGR表示的图像(Mat),可以通过以下方式转换图像:
cvtColor(source, destination, CV_BGR2Lab);
Run Code Online (Sandbox Code Playgroud)
然后可以通过以下方式访问像素值:
int step = destination.step;
int channels = destination.channels();
for (int i = 0; i < destination.rows(); i++) {
for (int j = 0; j < destination.cols(); j++) {
Point3_<uchar> pixelData;
//L*: 0-255 (elsewhere is represented by 0 to 100)
pixelData.x = destination.data[step*i + channels*j + 0];
//a*: 0-255 (elsewhere is represented by -127 to 127) …Run Code Online (Sandbox Code Playgroud)