1
votes

I needed to transform my image (RGB stored in .jpg) to highlight the specific area of it. Using ImageJ I found out that extraction of the L-channel of image in LAB color space is exactly what I need for further inspection. When implemented in C++ / OpenCV, the result is totally different from the ImageJ one (see pics ImageJ L-channel and OpenCV L-channel):

#include "opencv2/opencv.hpp"
#include "opencv2/core/core.hpp"        
#include "opencv2/highgui/highgui.hpp"  
#include "opencv2/imgproc/imgproc.hpp"

using namespace cv;
using namespace std;

int main(){

     vector <Mat> lab_planes;
     Mat src, lab;

     src = imread("Pic.jpg", CV_LOAD_IMAGE_COLOR);
     cvtColot(src, lab, CV_BGR2Lab);
     split(lab, lab_planes);

     imshow("L", lab_planes[0]);
     imshow("a", lab_planes[1]);
     imshow("b", lab_planes[2]);

     waitKey(0);
     return 0;
 }

I tried to google that and found out that there may be a problem in difference of storing ranges of channels (0 - 255 instead of 'correct' 0 - 100) or RGB-presentation, but I don't figure out how to receive same result as with ImageJ.

Thanks!

1

1 Answers

1
votes

May be:

cv::normalize(L,L,0,255,cv::NORM_MINMAX); 

Or (may be more correct) just multiply by 2.55 (first convert to CV_32F then multiply, and convert back).