I'm trying to calculate the sum of white pixels in multiple images.
I am able to count the number of white pixels in one image (2.png )with this code below:
import cv2
import numpy as np
image = cv2.imread('2.png')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
pixels = cv2.countNonZero(gray)
print('pixel count', pixels)
, but I don't know how to do it with multiple images. I would like to input multiple images and get the sum of all the white pixels. I'm fairly new to python and need some help with this. Thank you!