Minor Bug Fix: trilinear interpolation may crash when querying with coordinates between -1 and 0. Add a test on real coordinates to exit interpolation if it is < 0.

This commit is contained in:
Stéphane Tayeb 2009-07-08 11:22:48 +00:00
parent 37fdaefe04
commit 86527359ed
1 changed files with 6 additions and 0 deletions

View File

@ -221,6 +221,9 @@ Image_3::trilinear_interpolation(const Coord_type& x,
const Image_word_type& value_outside,
Image_transform transform) const
{
// Check on double/float coordinates, because (int)-0.1 gives 0
if ( x < 0 || y < 0 || z < 0 ) return value_outside;
const Coord_type lx = x / image()->vx;
const Coord_type ly = y / image()->vy;
const Coord_type lz = z / image()->vz;
@ -406,6 +409,9 @@ Image_3::labellized_trilinear_interpolation(const Coord_type& x,
const Coord_type& z,
const Image_word_type& value_outside) const
{
// Check on double/float coordinates, because (int)-0.1 gives 0
if ( x < 0 || y < 0 || z < 0 ) return value_outside;
const int dimx = xdim();
const int dimy = ydim();
const int dimz = zdim();