python-scipyHow can I use Python Scipy to zoom in on an image?
Python Scipy can be used to zoom in on an image by using the zoom() function. This function takes an array and a zoom factor as parameters and returns a zoomed array. The following example code zooms in on a sample image by a factor of two:
from scipy.ndimage import zoom
from scipy import misc
img = misc.face()
zoomed_img = zoom(img, 2)
The output of the above code is an array which contains the zoomed image.
Code explanation
from scipy.ndimage import zoom: This imports thezoomfunction from thescipy.ndimagemodule.from scipy import misc: This imports themiscmodule fromscipy.img = misc.face(): This stores the sample image in theimgvariable.zoomed_img = zoom(img, 2): This calls thezoomfunction with theimgarray and a zoom factor of two as parameters and stores the resulting array in thezoomed_imgvariable.
Helpful links
More of Python Scipy
- How can I check if a certain version of Python is compatible with SciPy?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How do I uninstall Python Scipy?
- How do I use Scipy zeros in Python?
- How do I create a 2D array of zeros using Python and NumPy?
- How do I download a Python Scipy .whl file?
- How can I install and use SciPy on Ubuntu?
- How do I convert a Python Numpy array to a Pandas Dataframe?
- How do I use the NumPy transpose function in Python?
- How can I use Python and SciPy to solve an ordinary differential equation?
See more codes...