06-12-2020, 03:47 PM
(06-12-2020, 03:40 PM)Ofnuts Wrote: Yes, likely a bug, nice finding.
Didn't see you code, but if you access each pixel in turn using get_pixel(), you code will not scale to real-life images. In Python your can use "pixel regions", which is a nbig array-like structure that you can access in Python (it even supports slices).
from PIL import Image
import numpy as np
img = Image.open('start.bmp')
arr=np.array(img)
print (arr)
#im still learning arrays so i changed it to list that im more familiar with
b=arr.tolist()
print ()
flat_list=[]
for sublist in b:
for item in sublist:
flat_list.append(item)
white_dots=0
black_dots=0
for i in flat_list:
if i == 255:
white_dots+=1
if i == 0:
black_dots+=1
print ('number 255: ', white_dots)
print ('number 0: ', black_dots)
thats my code
thank you very much