ドキュメントで提供されている関数を使用して、8 ビット深度のRGBMat
画像を表す特定のものをLabに変換しようとしています。
cvtColor(source, destination, <conversion code>);
次の変換コードを試しました。
CV_RGB2Lab
CV_BGR2Lab
CV_LBGR2Lab
私は毎回奇妙な結果を受け取りました。いくつかのサンプルでは、「L」値が 100 を超えており、文字通り <107, 125, 130> です。
Photoshop も使用して結果を確認していますが、107 が 0 ≤ L ≤ 100 の許容範囲を超えているため、エラーが何であるかを理解できません。
更新: 全体的な結果をここに投稿します: 8 ビット BGR で表される画像 (Mat) が与えられた場合、画像は次のように変換できます。
cvtColor(source, destination, CV_BGR2Lab);
ピクセル値は、次の方法でアクセスできます。
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)
pixelData.y = destination.data[step*i + channels*j + 1];
//b*: 0-255 (elsewhere is represented by -127 to 127)
pixelData.z = destination.data[step*i + channels*j + 2];
}
}