@@ -9,8 +9,8 @@ Mat NearestNeighborInterpolation(Mat src, float sx, float sy) {
9
9
Mat dst (dst_row, dst_col, CV_8UC1);
10
10
for (int i = 0 ; i < dst_row; i++) {
11
11
for (int j = 0 ; j < dst_col; j++) {
12
- int pre_i = round (i / sy);
13
- int pre_j = round (j / sx);
12
+ int pre_i = floor (i / sy);
13
+ int pre_j = floor (j / sx);
14
14
if (pre_i > row - 1 ) pre_i = row - 1 ;
15
15
if (pre_j > col - 1 ) pre_j = col - 1 ;
16
16
dst.at <uchar>(i, j) = src.at <uchar>(pre_i, pre_j);
@@ -22,8 +22,8 @@ Mat NearestNeighborInterpolation(Mat src, float sx, float sy) {
22
22
Mat dst (dst_row, dst_col, CV_8UC3);
23
23
for (int i = 0 ; i < dst_row; i++) {
24
24
for (int j = 0 ; j < dst_col; j++) {
25
- int pre_i = round (i / sy);
26
- int pre_j = round (j / sx);
25
+ int pre_i = floor (i / sy);
26
+ int pre_j = floor (j / sx);
27
27
if (pre_i > row - 1 ) pre_i = row - 1 ;
28
28
if (pre_j > col - 1 ) pre_j = col - 1 ;
29
29
dst.at <Vec3b>(i, j)[0 ] = src.at <Vec3b>(pre_i, pre_j)[0 ];
@@ -33,4 +33,4 @@ Mat NearestNeighborInterpolation(Mat src, float sx, float sy) {
33
33
}
34
34
return dst;
35
35
}
36
- }
36
+ }
0 commit comments