Skip to content

Commit bb13bb8

Browse files
committed
Give error message in -d bilinear when formula does not work
1 parent f98750e commit bb13bb8

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/Downscaler/Bilinear.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,19 @@ float DownscalerBilinear::bilinear(float x, float y, float x0, float x1, float x
5454
else
5555
calcGeneral(x, y, x0, x1, x2, x3, y0, y1, y2, y3, t, s);
5656

57-
if(t >= 1 && t <= 1.05)
57+
if(t >= 1 && t <= 1.15)
5858
t = 1;
59-
if(t <= 0 && t >= -0.05)
59+
if(t <= 0 && t >= -0.15)
6060
t = 0;
61-
if(s >= 1 && s <= 1.05)
61+
if(s >= 1 && s <= 1.15)
6262
s = 1;
63-
if(s <= 0 && s >= -0.05)
63+
if(s <= 0 && s >= -0.15)
6464
s = 0;
65-
if(!(s >= 0 && s <= 1 && t >= 0 && t <= 1))
66-
std::cout << "s = " << s << " t = " << t << std::endl;
65+
if(!(s >= 0 && s <= 1 && t >= 0 && t <= 1)) {
66+
std::stringstream ss;
67+
ss << "Problem with bilinear interpolation. Grid is rotated/distorted in a way that is not supported. s=" << s << " and t=" << t << " are outside [-0.05,1.05].";
68+
Util::error(ss.str());
69+
}
6770
assert(s >= 0 && s <= 1 && t >= 0 && t <= 1);
6871
float value = P1 * (1 - s) * ( 1 - t) + P2 * s * (1 - t) + P3 * (1 - s) * t + P4 * s * t;
6972

0 commit comments

Comments
 (0)