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 thezoom
function from thescipy.ndimage
module.from scipy import misc
: This imports themisc
module fromscipy
.img = misc.face()
: This stores the sample image in theimg
variable.zoomed_img = zoom(img, 2)
: This calls thezoom
function with theimg
array and a zoom factor of two as parameters and stores the resulting array in thezoomed_img
variable.
Helpful links
More of Python Scipy
- How do I use Python XlsxWriter to write a NumPy array to an Excel file?
- How do I use the trapz function in Python SciPy?
- How do I create a 2D array of zeros using Python and NumPy?
- How to use Python, XML-RPC, and NumPy together?
- How do I calculate variance using Python and SciPy?
- How can I use Python and Numpy to parse XML data?
- How do I use Python Numpy to read and write Excel (.xlsx) files?
- How can I use Python Numpy to select elements from an array based on multiple conditions?
- How do I download a Python Scipy .whl file?
- How do I use the numpy vstack function in Python?
See more codes...