Home > Net >  ValueError: could not broadcast input array from shape (200,200,3) into shape (200,200)
ValueError: could not broadcast input array from shape (200,200,3) into shape (200,200)

Time:12-04

ValueError: could not broadcast input array from shape (200,200,3) into shape (200,200)

img_000= np.array(img_00)

CodePudding user response:

use

np.asarray(img_00)

your image needs 3 channels: (width, height,colorchannels)

CodePudding user response:

A small example that displays a similar error

In [72]: alist = [np.ones((3,3,3)), np.zeros((3,3))]

In [73]: np.array(alist)
C:\Users\paul\AppData\Local\Temp\ipykernel_7196\2629805649.py:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  np.array(alist)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [73], in <cell line: 1>()
----> 1 np.array(alist)

ValueError: could not broadcast input array from shape (3,3,3) into shape (3,3)
  • Related