ait-survey

OpenCV-write

Nov 25th, 2013
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <cv.h>
  2. #include <highgui.h>
  3.  
  4. using namespace cv;
  5.  
  6. int
  7. main( int argc, char** argv )
  8. {
  9.  
  10.     char* imageName = argv[1];
  11.     Mat image;
  12.  
  13.     image = imread( imageName, 1 );
  14.  
  15.     if( argc != 3 || !image.data )
  16.     {
  17.         printf( " No image data \n " );
  18.         return -1;
  19.     }
  20.  
  21.     Mat gray_image;
  22.     cvtColor( image, gray_image, CV_RGB2GRAY );
  23.     imwrite( argv[2], gray_image );
  24.     namedWindow( imageName, CV_WINDOW_AUTOSIZE );
  25.     namedWindow( "Gray image", CV_WINDOW_AUTOSIZE );
  26.  
  27.     imshow( imageName, image );
  28.     imshow( "Gray image", gray_image );
  29.  
  30.     waitKey(0);
  31.     return 0;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment