Load and view an image with imageio and visvis (Python)

vegaseat 4 Tallied Votes 7K Views Share

Two third party Python modules imageio and visvis make it easy to load and view images. The modules come with the pyzo scientific package or can be downloaded separately. Module imageio can read many image file formats as shown in
http://imageio.readthedocs.org/en/latest/formats.html

You could also replace your image file name directly with a URL containing an image, for example
image_file = "Lake2.jpg"
could be changed to
image_file = "http://i.imgur.com/3MnBqHh.jpg"
and your picture would simply come from the internet.

Gribouillis commented: interesting +14
''' imageio_vv_imageview101.py
imageio can read many image file formats
(also reads file objects, http, zipfiles and bytes)
visvis can display these images

get 
imageio-0.5.1.tar.gz
from
https://pypi.python.org/pypi/imageio

get
visvis-1.8.win-amd64.exe
from
https://pypi.python.org/pypi/visvis/1.8

imageio and visvis come with 
pyzo_distro-2014a.win64.exe
from
http://www.pyzo.org/downloads.html
(includes numpy, pyOpenGl and PySide)

imageio, visvis and pyzo_distro come in Linux and OSX flavors too

see:
http://imageio.readthedocs.org/en/latest/formats.html
https://code.google.com/p/visvis/

tested with Python34-64bit  by vegaseat  09nov2014
'''

import imageio
import visvis as vv

# use an image file you have in the working directory
# or give the full path
image_file = "Lake2.jpg"
img = imageio.imread(image_file)

# optional info
#print(img.shape)  # (300, 400, 3)

vv.title(image_file)

# use visvis to display image
vv.imshow(img)
Slavi 94 Master Poster Featured Poster

Thank you @vegaseat

Ene Uran 638 Posting Virtuoso

Very good third party modules to add to Python.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.