У меня есть список (Cyst_intensity) длины l
, содержащий значения области контура изображений в измерении (n x 3)
.то есть список списков.
Где 3
представляет три канала, а n
представляет строки, имеющие значения изображения.

Я хочу сохранить канал Красный, Синий, Зеленый отдельно в списке.
# Cyst pixel generator
cyst_intensity= []
# For each list of contour points...
for i in range(len(cystcontours)):
# Create a mask image that contains the contour filled in
cimg = np.zeros_like(image)
cv.drawContours(cimg, cystcontours, i, color=255, thickness=-1)
# Access the image pixels and create a 1D numpy array then add to list
pts = np.where(cimg == 255)
#Cyst_intensity will contain the original image contour pixel value
cyst_intensity.append(image[pts[0], pts[1]])
#separating into channels and averaging out
B=[]
G=[]
R=[]
cystcolours=[]
i=0
for m in iter(cyst_intensity):
for j in m[i][0]:
B.append(j)
i+=1
i=0
for k in m[i][1]:
G.append(k)
i+=1
i=0
for q in m[i][2]:
R.append(q)
i+=1
cystcolours.append([avg(B),avg(G),avg(R)])
При выполнении приведенного выше кода я получаю следующую ошибку.
Traceback (most recent call last):
File "<input>", line 7, in <module>
TypeError: 'numpy.uint8' object is not iterable
Как решить эту проблему?