Skip to content

Commit

Permalink
avoid np.round
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed Apr 20, 2019
1 parent 7ab7b60 commit 69d6d7a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions util/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def resample_with_wcs(targetwcs, wcs, Limages=[], L=3, spline=True,
table: use Lanczos3 look-up table?
intType: type to return for integer pixel coordinates.
(however, Yi,Xi may still be returned as int32)
'''
### DEBUG
#ps = PlotSequence('resample')
Expand Down Expand Up @@ -220,8 +221,9 @@ def expand_axes():
# the lanczos3_interpolate function below requires int32!
itype = np.int32

ixi = np.round(fxi).astype(itype)
iyi = np.round(fyi).astype(itype)
# (f + 0.5).astype(int) is often faster than round().astype(int) or rint!
ixi = (fxi + 0.5).astype(itype)
iyi = (fyi + 0.5).astype(itype)

# Cut to in-bounds pixels.
I,J = np.nonzero((ixi >= 0) * (ixi < w) * (iyi >= 0) * (iyi < h))
Expand Down

0 comments on commit 69d6d7a

Please sign in to comment.