-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrgbtogray.cpp
More file actions
36 lines (27 loc) · 919 Bytes
/
rgbtogray.cpp
File metadata and controls
36 lines (27 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"
using namespace cv;
using namespace std;
int main( )
{
Mat image;
image = imread("Lenna.bmp", CV_LOAD_IMAGE_COLOR);
if(! image.data )
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
// Create a new matrix to hold the gray image
Mat gray;
// convert RGB image to gray
cvtColor(image, gray, CV_BGR2GRAY);
namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
imshow( "Display window", image );
waitKey(200);
namedWindow( "Result window", CV_WINDOW_AUTOSIZE );
imshow( "Result window", gray );
waitKey(0);
return 0;
}