Mayke Santos
Mayke Santos

Reputation: 67

Importing pictures from module in Python

Very stupid question, but here it goes.

Scikit-image has a module called 'data'. Such module has plenty of pictures that are used in the examples.

So, for instance:

from skimage import data
image = data.camera() # camera being a camera.png file in data

Now, I want to import my own files into the scripts, but if I add a new file to the data folder, I get back the following error:

module data has no attribute 'whatever' #whatever being the new file I added to data.

Upvotes: 1

Views: 1575

Answers (1)

Tonechas
Tonechas

Reputation: 13743

As an alternative solution with respect to @Peter Wood's comment, skimage.io.imread should do the trick:

In [5]: from skimage import io

In [6]: image = io.imread('whatever.png')

In [7]: io.imshow(image)
Out[7]: <matplotlib.image.AxesImage at 0xf695f98>

whatever

Upvotes: 1

Related Questions