reading/manipulation of python images

Asked

Viewed 278 times

0

  • I use Windows 8.1 ( 64 bits );
  • Python 3.7, Spyder 3 and Scikit-Image Library, all included in the Anaconda package.

Here’s the super simple code:

from skimage import io
img = io.imread("C:\Users\Vitor Monteiro\Pictures\Nova pasta\bull.jpg")
io.imshow(img)
io.show()

Here are the mistakes:

runfile('C:/Users/Vitor Monteiro/.spyder-py3/temp.py', wdir='C:/Users/Vitor Monteiro/.spyder-py3')
Traceback (most recent call last):

File "C:\Users\Vitor Monteiro\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "<ipython-input-8-9f9680e460c7>", line 1, in <module>

runfile('C:/Users/Vitor Monteiro/.spyder-py3/temp.py', wdir='C:/Users/Vitor Monteiro/.spyder-py3')

File "C:\Users\Vitor Monteiro\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile
execfile(filename, namespace)

File "C:\Users\Vitor Monteiro\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Vitor Monteiro/.spyder-py3/temp.py", line 6
img = io.imread("C:\Users\Vitor Monteiro\Pictures\Nova pasta\bull.jpg")
^
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape

How are so many errors possible in only 4 lines of code?

  • Are you sure that’s all your code is? For the error message, the code img = io.imread(...) is on line 6, but what you presented to us would be on line 2.

  • Yes, the code is just that.

  • I like to leave empty lines at the beginning, and the code starts so on line 4.

  • 2

    I went through a similar problem, img = io.imread(r"C:\Users\Vitor Monteiro\Pictures\Nova pasta\bull.jpg") to convert to a raw string ;)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.