Hi, can anyone tell me how to convert RGB image into Gray Scale Image using C++? Thanks...
Last edited on
Get pixels value for R, G and B. Greyscale value of same pixel = (0.3 R) + (0.59 G) + (0.11 B)
Thanks...I've tried it using C++ in OpenCv but don't know how to show it instead of save the gray image? TQ...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
#include <opencv/highgui.h>
#include <opencv/cv.h>
int main( int argc, char** argv ) {
IplImage* img = cvLoadImage("C:/Users/123/Desktop/PROJECT/1.jpg");
IplImage *destination = cvCreateImage(
cvSize( img->width, img->height ), IPL_DEPTH_8U, 1 );
cvCvtColor( img, destination, CV_RGB2GRAY );
cvSaveImage( "C:/Users/123/Desktop/1ed.jpg", destination );
cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
cvShowImage( "Example1", img );
cvWaitKey(0);
cvReleaseImage( &img );
cvDestroyWindow( "Example1" );
}
|
Last edited on