Skip to content

Commit

Permalink
Give error message in -d bilinear when formula does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
tnipen committed Sep 17, 2018
1 parent f98750e commit bb13bb8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/Downscaler/Bilinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,19 @@ float DownscalerBilinear::bilinear(float x, float y, float x0, float x1, float x
else
calcGeneral(x, y, x0, x1, x2, x3, y0, y1, y2, y3, t, s);

if(t >= 1 && t <= 1.05)
if(t >= 1 && t <= 1.15)
t = 1;
if(t <= 0 && t >= -0.05)
if(t <= 0 && t >= -0.15)
t = 0;
if(s >= 1 && s <= 1.05)
if(s >= 1 && s <= 1.15)
s = 1;
if(s <= 0 && s >= -0.05)
if(s <= 0 && s >= -0.15)
s = 0;
if(!(s >= 0 && s <= 1 && t >= 0 && t <= 1))
std::cout << "s = " << s << " t = " << t << std::endl;
if(!(s >= 0 && s <= 1 && t >= 0 && t <= 1)) {
std::stringstream ss;
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].";
Util::error(ss.str());
}
assert(s >= 0 && s <= 1 && t >= 0 && t <= 1);
float value = P1 * (1 - s) * ( 1 - t) + P2 * s * (1 - t) + P3 * (1 - s) * t + P4 * s * t;

Expand Down

0 comments on commit bb13bb8

Please sign in to comment.