-2

I'm trying to run this code:

http://forumbilder.se/H8CIL/skarmavbild-2018-10-08-kl-21-22-19

so I change it to this one:

and then I got this:

http://forumbilder.se/H8CIL/skarmavbild-2018-10-08-kl-21-22-47

What's wrong? I'm a newbie, and fyi, I'm only have anaconda installed to my Python 3.6.6 .

Regards,

--

and in code:

     from skimage import data

     photo_data = misc.imageio('./wifire/sd-3layers.jpg')

     type(photo_data)

and i get this error:

    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-9-c8186ae7b8e9> in <module>()
          1 from skimage import data   
         2 
    ----> 3 photo_data = misc.imageio('./wifire/sd-3layers.jpg')
          4 
          5 type(photo_data)

     AttributeError: module 'scipy.misc' has no attribute 'imageio'

So I change it to:

soetirl13
  • 41
  • 1
  • 6

1 Answers1

0

You have to import imageio. You might have to install the library if you don't have it yet (on your terminal):

 pip install imageio

(If you don't have pip install yet, you can do on your terminal sudo easy_install pip, see here: How do I install pip on macOS or OS X?)

And then your code to use read the image with imageio:

 import imageio

 im = imageio.imread('./wifire/sd-3layers.jpg')
 type(im)

To display your image, you can use visvis library (https://imageio.readthedocs.io/en/stable/examples.html). Then you total code would be:

import imageio
import visvis as vv


im = imageio.imread('./wifire/sd-3layers.jpg')
vv.imshow(im)
ZiGaelle
  • 744
  • 1
  • 9
  • 21
  • okej, then i'll do that. But how? I'm no reading this https://imageio.readthedocs.io/en/latest/installation.html .... And where shall I use that code? In the notebook? In the ternimal (Im on a mac) ? – soetirl13 Oct 08 '18 at 19:51
  • You can do the installation of imageio from a Terminal. If you have `pip` it will install it. The import of imageio, you will have to do it in your code (in your notebook) – ZiGaelle Oct 08 '18 at 19:53
  • @ ZiGaelle Okej, I see. I'm going to the terminal and do: 1) open terminal, 2) type in curl https://bootstrap.pypa.io/get-pip.py 3) And then type sudo python get pip 4) the computer ask for my pw. But when i'm trying to type anything, it just don't work!? i can't type :/ – soetirl13 Oct 09 '18 at 07:56
  • Are you sure it doesn't work ? when you have to enter your pw after `sudo`, it is normal that nothing print on the screen, it stays blank. But if you enter your pw correctly and type the `Enter` key, it should work. You can try just directly typing `Enter`, then it will ask you to try again if it is working normally. – ZiGaelle Oct 09 '18 at 08:38
  • Ahhhhh now I know. You just enter it anyway, because it's on a mac. But hey, now I get this error: `python: can't open file 'get': [Errno 2] No such file or directory` – soetirl13 Oct 09 '18 at 09:36
  • The simpler would be to do : `sudo easy_install pip` I think (see here: https://stackoverflow.com/questions/17271319/how-do-i-install-pip-on-macos-or-os-x) to install `pip` (From your terminal) – ZiGaelle Oct 09 '18 at 09:48
  • does this output means that it is installed now? ` Searching for pip Best match: pip 10.0.1 Adding pip 10.0.1 to easy-install.pth file Installing pip script to /anaconda3/bin Installing pip3 script to /anaconda3/bin Installing pip3.6 script to /anaconda3/bin Using /anaconda3/lib/python3.6/site-packages Processing dependencies for pip Finished processing dependencies for pip ` – soetirl13 Oct 09 '18 at 13:32
  • You can just type `pip install imageio` in your Terminal, you will get an error message that pip is not install if it didn't work. – ZiGaelle Oct 09 '18 at 13:47
  • i got this output `Requirement already satisfied: imageio in /anaconda3/lib/python3.6/site-packages (2.3.0)` is that mean yes? – soetirl13 Oct 09 '18 at 13:54
  • Then it should be installed. I edited my answer with the code you should put in your notebook to read the image with imageio – ZiGaelle Oct 09 '18 at 14:56
  • @soetirl13 when you type the password after a `sudo` line, it is normal that nothing is shown. It's for security reason. Just type the password and hit enter! – alec_djinn Oct 09 '18 at 14:58
  • @ZiGaelle http://forumbilder.se/H8CLK/skarmavbild-2018-10-09-kl-16-59-19 is it now.. But why can't I see the image? – soetirl13 Oct 09 '18 at 15:00
  • Good, so it's reading the image ! The code allowed you to read the image, and it is now contained in the variable `im`. Next, you have to display it if you want to see it – ZiGaelle Oct 09 '18 at 15:14
  • You can try as in here: https://imageio.readthedocs.io/en/stable/examples.html, using visvis to display it – ZiGaelle Oct 09 '18 at 15:15
  • @ZiGaelle , aah cool :D do you know if there is a code that allows us to - let's say that i named it `"photo"` and now i want all the code to be named `im` instead? – soetirl13 Oct 09 '18 at 15:31