2019-10-10 图像降采样

1、得到一个尺寸是原图1/2的图像

2、代码

#include

void help(char** argv ) {

std::cout << "\n"

<< "2-06: AUsing cv::pyrDown() to create a new image that is half the width and"

    << "      height of the input image\n"

<< argv[0] <<" \n"

<< "For example:\n"

<< argv[0] << " ../faces.png\n"

<< std::endl;

}

int main( int argc, char** argv ) {

if (argc != 2) {

help(argv);

return 0;

}

  cv::Mat img1,img2;

  cv::namedWindow( "Example 2-6-in", cv::WINDOW_AUTOSIZE );

  cv::namedWindow( "Example 2-6-out", cv::WINDOW_AUTOSIZE );

  img1 = cv::imread( argv[1] );

  cv::imshow( "Example 2-6-in", img1 );

  cv::pyrDown( img1, img2);  //降采样

  cv::imshow( "Example 2-6-out", img2 );

  cv::waitKey(0);

  return 0;

};

你可能感兴趣的:(2019-10-10 图像降采样)