def zoom(self, newsize, order=1):
"""
Zoom the image to the specified ``newsize``, meanwhile the header
information will be updated accordingly to preserve the FoV coverage.
NOTE
----
The image aspect ratio cannot be changed.
Parameters
----------
newsize : (Nx, Ny) or N
The size of the zoomed image.
order : int, optional
The interpolation order, default: 1
"""
try:
Nx2, Ny2 = newsize
except TypeError:
Nx2 = Ny2 = newsize
zoom = ((Ny2+0.1)/self.Ny, (Nx2+0.1)/self.Nx)
if abs(zoom[0] - zoom[1]) > 1e-3:
raise RuntimeError("image aspect ratio cannot be changed")
pixelsize_old = self.pixelsize
self.image = ndimage.zoom(self.image, zoom=zoom, order=order)
self.pixelsize = pixelsize_old * (self.Nx / Nx2)
return self.image
评论列表
文章目录