[ASIFT 1] Load images

int main(int argc, char**argv[]){
 if ((argc != 8) && (argc != 9)) {
          std::cerr << " ******************************************************************************* " << std::endl
                    << " ***************************  ASIFT image matching  **************************** " << std::endl
                    << " ******************************************************************************* " << std::endl
                    << "Usage: " << argv[0] << " imgIn1.png imgIn2.png imgOutVert.png imgOutHori.png " << std::endl
                                            << "           matchings.txt keys1.txt keys2.txt [Resize option: 0/1] " << std::endl
                                            << "- imgIn1.png, imgIn2.png: input images (in PNG format). " << std::endl
                                            << "- imgOutVert.png, imgOutHori.png: output images (vertical/horizontal concatenated, " << std::endl
                                            << "  in PNG format.) The detected matchings are connected by write lines." << std::endl
                                            << "- matchings.txt: coordinates of matched points (col1, row1, col2, row2). " << std::endl
                                            << "- keys1.txt keys2.txt: ASIFT keypoints of the two images." << std::endl                                                                                   
                                            << "- [optional 0/1]. 1: input images resize to 800x600 (default). 0: no resize. " << std::endl 
                    << " ******************************************************************************* " << std::endl
                    << " *********************  Jean-Michel Morel, Guoshen Yu, 2010 ******************** " << std::endl
                    << " ******************************************************************************* " << std::endl;
          return 1;
      }
      

}
argc: number of the parameters from the command line

         this project needs 8 or 9 parameters when you want to run it;

argv[]: argv[0] shows the name of the project

           use argv[1] to get the first string parameter, argv[2].......

           as you know, you can use char* to store a string, such as ' hello_world'. So, char **argv[] can store a set of       char*. But when your parameters are numbers, you can use char* argv[] to store them.


/**************************input images******************************/

      // Read image1
      float * iarr1;
      size_t w1, h1;
      if (NULL == (iarr1 = read_png_f32_gray(argv[1], &w1, &h1))) {
          std::cerr << "Unable to load image file " << argv[1] << std::endl;
          return 1;
      }
      std::vector<float> ipixels1(iarr1, iarr1 + w1 * h1);
      free(iarr1); /*memcheck*/
      
      // Read image2
      float * iarr2;
      size_t w2, h2;
     if (NULL == (iarr2 = read_png_f32_gray(argv[2], &w2, &h2))) {
         std::cerr << "Unable to load image file " << argv[2] << std::endl;
         return 1;
     }
     std::vector<float> ipixels2(iarr2, iarr2 + w2 * h2);
     free(iarr2); /*memcheck*/   

argv[1] and argv[2] are the names of the images, then the width and height of the images are stored in w1,h1 and w2,h2 respectively.

read_png_f32_gray :  read .png image. you can learn it in theipol.




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值