0
Given that array:
array([[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
...,
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0],
[0, 0, 0, ..., 0, 0, 0]], dtype=uint8)
I’m willing to stick it to count values on each line and then save them by line. The code below is doing the general sum. I would like to have the count per line.
def count(image):
array = np.array(image)
array[[ array == 0 ]] = 1
array[[ array == 255 ]] = 0
for row in array:
unique, counts = np.unique(array[row,] , return_counts=True)
d = dict(zip(unique, counts))
return new
The result:
{0: 234710, 1: 515}
I completed the first alternative with collection = [] at the beginning and Return(collection) at the end and it worked.
– Gabriel Serrão
good that it worked out friend, if the answer helped her short and mark as answer, so help others answer their questions. Friend hugs.
– Killdary Aguiar de Santana