caffe resize用interpolation

opencv的resize默认的是使用双线性插值INTER_LINEAR,也可以是尝试其他的方式进行插值操作

if (param.random_interpolation_method()) {
    // 0: INTER_NEAREST
    // 1: INTER_LINEAR
    // 2: INTER_CUBIC
    // 3: INTER_AREA
    // 4: INTER_LANCZOS4
    int interpolation = caffe_rng_rand() % 5;
    cv::resize(cv_img_origin, img, cv::Size(new_width, new_height), 0, 0,
        interpolation);
  } else if (param.use_self_resize_fun()) {
    // TODO(kun): resize_model() now is not well verified.
    // When use_self_resize_fun, we consider cv::resize() just in case.
    if (caffe_rng_rand() % 2) {
      cv::resize(cv_img_origin, img, cv::Size(new_width, new_height));
    } else {
      img = cv::Mat(new_height, new_width, cv_img_origin.type());
      int mode = caffe_rng_rand() % 2;
      resize_model(img.data, cv_img_origin.data,
          cv_img_origin.cols, cv_img_origin.rows,
          new_width, new_height, NULL, mode);
    }
  } else {  // Resize using INTER_LINEAR
    cv::resize(cv_img_origin, img, cv::Size(new_width, new_height));
  }

 

posted @ 2018-06-11 16:35  有梦就要去实现他  阅读(641)  评论(0编辑  收藏  举报