lets say i wanted to counte the black pixels in the bottom right 200x200 pixels of every image.
i have:
i have:
my_list = [] for root, dirs, files in os.walk("E:/1/1/"): for filename in files: my_list.append(filename) cpt1 = sum([len(files) for r, d, files in os.walk('E:/1/1')]) i = 0 increment1 = ('E:/1/1/' + my_list[i]) black = 0 red = 0 while (i) < cpt1-2: i += 1 increment1 = ('E:/1/1/' + my_list[i]) black1 = 0 im1 = Image.open(str(increment1)) rgb_im1 = im1.convert('RGB') width1, height1 = imagesize.get(str(increment1)) totalpixels1 = width1*height1 for pixel in rgb_im1.getdata(): if pixel == (0, 0, 0): black1 += 1 else: red += 1