Skip to content

Instantly share code, notes, and snippets.

@damvantai
Last active August 29, 2015 14:19
Show Gist options
  • Save damvantai/aaa14e7378a20ea44cba to your computer and use it in GitHub Desktop.
Save damvantai/aaa14e7378a20ea44cba to your computer and use it in GitHub Desktop.
/********************************
* MYcvtColor.cpp
* S. F. Hasan
* *****************************/
#include <opencv2/opencv.hpp>
#include <iostream>
#include <fstream>
using namespace cv;
using namespace std;
double alpha; /**< Simple contrast control */
int beta; /**< Simple brightness control */
int main( int argc, char** argv )
{
IplImage* imgA = cvLoadImage("C:/view0.png");
CvSize img_sz = cvGetSize( imgA );
if (!imgA) {
return 0;
}
IplImage* lab_image = cvCreateImage( img_sz, imgA->depth, 3 );
cvCvtColor(imgA, lab_image, CV_BGR2Lab);
for (int row=0;row<lab_image->height;row++)
{
const uchar* ptr= (uchar*)(lab_image->imageData + row*lab_image->widthStep );
for(int col=0;col<lab_image->width;col++)
{
//cout << "uchar = "<< endl << " " << (uchar)*ptr << endl << endl;
cout << "int = "<< endl << " " << (int)*ptr << endl << endl;
*ptr++;
}
}
cvNamedWindow("rgb",1);
cvNamedWindow("lab",1);
cvShowImage("rgb",imgA);
cvShowImage("lab",lab_image);
cvReleaseImage(&imgA);
cvReleaseImage(&lab_image);
cvWaitKey();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment