aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/utils
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-08-14 09:40:12 +0800
committerAaron LI <aly@aaronly.me>2017-08-14 09:40:12 +0800
commitb9697f8e8c10ab80f4c24652833f33ab1a8b620b (patch)
tree47124b48db4962d91ab25c4e09117e425804e5bc /fg21sim/utils
parent9bde3eea7ba531c7d1f96a7430f7d8ef0d9acbc0 (diff)
downloadfg21sim-b9697f8e8c10ab80f4c24652833f33ab1a8b620b.tar.bz2
Fix the warning on scipy.ndimage.zoom output shape calculation
scipy.ndimage.zoom calculate the output/zoomed image shape with round(), while the old versions use int() instead. When the two calculations are different, a warning is raised. This commit fixes the calculation mismatch. Signed-off-by: Aaron LI <aly@aaronly.me>
Diffstat (limited to 'fg21sim/utils')
-rw-r--r--fg21sim/utils/transform.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/fg21sim/utils/transform.py b/fg21sim/utils/transform.py
index 3fc64ca..c897f70 100644
--- a/fg21sim/utils/transform.py
+++ b/fg21sim/utils/transform.py
@@ -171,7 +171,10 @@ def circle2ellipse(imgcirc, bfraction, rotation=0.0):
# Shrink the circle to be elliptical
nrow2 = nrow * bfraction
nrow2 = int(nrow2 / 2) * 2 + 1 # be odd
- img2 = ndimage.zoom(imgcirc, zoom=(nrow2/nrow, 1.0), order=1)
+ # NOTE: zoom() calculate the output shape with round() instead of int();
+ # fix the warning about they may be different.
+ zoom = ((nrow2+0.1)/nrow, 1)
+ img2 = ndimage.zoom(imgcirc, zoom=zoom, order=1)
# Pad the shrunk image to have the same size as input
imgout = np.zeros(shape=(nrow, ncol))
r1 = int((nrow - nrow2) / 2)