Please ignore secret bonuses. Secret tests do NOT award bonus. Max hw grade is 30+2 bonus efficiency

Do you need help?

Notice Board

Per partecipare al corso di Fondamenti di programmazione 2023-24 loggatevi e attivatelo nella vostra pagina dei corsi preferiti. A quel punto il corso appare nel menù personale cliccando sul proprio avatar. Per i materiali degli anni precedenti seguite lo stesso metodo.

To join the Programming/Lab 2023-24 course, log-on and select it on the my courses page. It will appear on the personal menu of your avatar. For earlier years use the same method.

How to fix images.visd() : [ ValueError: invalid literal for int() with base 10: 'a' ]

L
Lexyo (800 points)
1 2 5
in News by (800 points)
closed by

I downloaded the library from the teaching materials, when trying to use the function into the spyder console it shows this error:

images.visd('cane.png')
Traceback (most recent call last):

  File "C:\Users\User\anaconda3\lib\site-packages\IPython\core\formatters.py", line 345, in __call__
    return method()

  File "C:\Users\User\OneDrive\Python\HW5opt\images.py", line 42, in _repr_png_
    img.save(b)

  File "C:\Users\User\OneDrive\Python\HW5opt\png.py", line 1280, in save
    w.write(file, self.rows)

  File "C:\Users\User\OneDrive\Python\HW5opt\png.py", line 621, in write
    nrows = self.write_passes(outfile, rows)

  File "C:\Users\User\OneDrive\Python\HW5opt\png.py", line 779, in write_passes
    extend(row)

  File "C:\Users\User\OneDrive\Python\HW5opt\png.py", line 767, in <lambda>
    return lambda sl: f([int(x) for x in sl])

  File "C:\Users\User\OneDrive\Python\HW5opt\png.py", line 767, in <listcomp>
    return lambda sl: f([int(x) for x in sl])

ValueError: invalid literal for int() with base 10: 'a'

<images.Image at 0x190cfb87af0>




370 views
closed with the note: Solved

1 Answer

andrea.sterbini (207920 points)
750 1267 2373
by (208k points)
This method displays a matrix of triples.

First load the image

Then use visd
L
Lexyo (800 points)
1 2 5
by (800 points)
Okay so I should put as argument the actual image matrix, thanks, now it's working