Advertisement
Kojima0502

resizecmake

Nov 29th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.05 KB | None | 0 0
  1. #include <opencv2/core/core.hpp>
  2. #include <opencv2/imgproc/imgproc.hpp>
  3. #include <opencv2/highgui/highgui.hpp>
  4. #include <iostream>
  5.  
  6. int
  7. main(int argc, char** argv)
  8. {
  9.     if( argc != 4 ) {
  10.         std::cerr << "Usage: " << argv[0] << " <InputImage>  <OutputImage> up:3.0" << std::endl;
  11.         return EXIT_FAILURE;
  12.     }
  13.     float up;
  14.     cv::Mat src_img = cv::imread(argv[1], 2);
  15.     if(src_img.empty()) return -1;
  16.     up=atof(argv[3]);
  17.     cv::Mat dst_img(src_img.rows*up, src_img.cols*up, src_img.type());
  18.  
  19.  
  20.    
  21.     // INTER_CUBIC(バイキュービック補間)でのサイズ変更
  22.     cv::resize(src_img, dst_img, dst_img.size(), cv::INTER_CUBIC);//画像のサイズを変更
  23.    
  24.     cv::namedWindow("resize image", CV_WINDOW_AUTOSIZE|CV_WINDOW_FREERATIO);
  25.     cv::imshow("resize image", dst_img);//指定したウィンドウ内に画像を表示します.
  26.     cv::imwrite(argv[2],dst_img);       //画像ファイルに保存
  27.    
  28.     cv::waitKey(0);                     //キーが押されるまで待機
  29.    
  30.  
  31.    
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement