opencv的resize默認的是使用雙線性插值INTER_LINEAR,也能夠是嘗試其餘的方式進行插值操做dom
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)); }