Skip to content

Commit

Permalink
Use bicubic interp in DetectNetTransform layer
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeyeager committed Aug 23, 2016
1 parent 1497995 commit 0a1c9f5
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/caffe/layers/detectnet_transform_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,14 @@ void DetectNetTransformationLayer<Dtype>::retrieveMeanImage(Size dimensions) {

// resize, if dimensions were defined:
if (dimensions.area() > 0) {
resize(data_mean_, data_mean_, dimensions, cv::INTER_CUBIC);
// Resize using bicubic interpolation and then clamp to [min, max]
double minval, maxval;
cv::minMaxLoc(data_mean_, &minval, &maxval);
cv::resize(data_mean_, data_mean_, dimensions, 0, 0, cv::INTER_CUBIC);
cv::threshold(data_mean_, data_mean_, maxval, 0, cv::THRESH_TRUNC);
data_mean_ *= -1;
cv::threshold(data_mean_, data_mean_, -minval, 0, cv::THRESH_TRUNC);
data_mean_ *= -1;
}
// scale from 0..255 to 0..1:
data_mean_ /= Dtype(UINT8_MAX);
Expand Down Expand Up @@ -439,7 +446,14 @@ void DetectNetTransformationLayer<Dtype>::transform_scale(
Dtype scale_x = (Dtype)size.width / img.cols;
Dtype scale_y = (Dtype)size.height / img.rows;

resize(img, *img_temp, size, cv::INTER_CUBIC);
// Resize using bicubic interpolation and then clamp to [min, max]
double minval, maxval;
cv::minMaxLoc(img, &minval, &maxval);
cv::resize(img, *img_temp, size, 0, 0, cv::INTER_CUBIC);
cv::threshold(*img_temp, *img_temp, maxval, 0, cv::THRESH_TRUNC);
*img_temp *= -1;
cv::threshold(*img_temp, *img_temp, -minval, 0, cv::THRESH_TRUNC);
*img_temp *= -1;

vector<BboxLabel > bboxList_aug;
foreach_(BboxLabel label, bboxList) { // for every bbox:
Expand Down

0 comments on commit 0a1c9f5

Please # to comment.