Studiando un pochino la libreria png.py ho letto questo:
''The array is expected to be a ``numpy`` array, but it can be any
suitable Python sequence. For example, a list of lists can be used:
``png.from_array([[0, 255, 0], [255, 0, 255]], 'L')``. The exact
rules are: ``len(a)`` gives the first dimension, height;
``len(a[0])`` gives the second dimension; ``len(a[0][0])`` gives the
third dimension, unless an exception is raised in which case a
2-dimensional array is assumed. It's slightly more complicated than
that because an iterator of rows can be used, and it all still
works. Using an iterator allows data to be streamed efficiently."
Facendo una piccola ricerca su internet ho letto che un Numpy Array facilita operazioni matematiche avanzate e che in genere tali operazioni vengono eseguite in modo più efficiente e con meno codice di quanto sia possibile utilizzando le sequenze integrate di Python.
Essendo scontato il fatto che non possiamo importare librerie al di fuori di images(e quindi anche png), immagino che importare numpy non sia possibile, è possibile ricavarsi una numpy array fai da te da inserire nel save?
Per quanto riguarda questo: "Using an iterator allows data to be streamed efficiently."
Ho già provato a trasformare la lista in iteratore ma mi riporta l'errore Error("len(a) does not work, supply info['height'] instead."). Idee per trasformare in iteratore la lista che facciamo ?
''The array is expected to be a ``numpy`` array, but it can be any
suitable Python sequence. For example, a list of lists can be used:
``png.from_array([[0, 255, 0], [255, 0, 255]], 'L')``. The exact
rules are: ``len(a)`` gives the first dimension, height;
``len(a[0])`` gives the second dimension; ``len(a[0][0])`` gives the
third dimension, unless an exception is raised in which case a
2-dimensional array is assumed. It's slightly more complicated than
that because an iterator of rows can be used, and it all still
works. Using an iterator allows data to be streamed efficiently."
Facendo una piccola ricerca su internet ho letto che un Numpy Array facilita operazioni matematiche avanzate e che in genere tali operazioni vengono eseguite in modo più efficiente e con meno codice di quanto sia possibile utilizzando le sequenze integrate di Python.
Essendo scontato il fatto che non possiamo importare librerie al di fuori di images(e quindi anche png), immagino che importare numpy non sia possibile, è possibile ricavarsi una numpy array fai da te da inserire nel save?
Per quanto riguarda questo: "Using an iterator allows data to be streamed efficiently."
Ho già provato a trasformare la lista in iteratore ma mi riporta l'errore Error("len(a) does not work, supply info['height'] instead."). Idee per trasformare in iteratore la lista che facciamo ?