어떻게이 코드 인쇄 200 세 이상 밝은 픽셀의 총 수를 어떻게해야합니까 : 지금이미지의 밝은 픽셀 수를 계산하는 방법은 무엇입니까?
from PIL import Image
img = input("File name: ")
img = Image.open(img);
for y in range(img.height):
for x in range(img.width):
pixel = img.getpixel((x, y))
if pixel >= 200:
print(pixel,"pixels are bright.")
는 새로운 라인 (200)를 초과 모든 하나의 픽셀을 인쇄하는 것,하지만 난 그냥 한 줄을 원하는 다음과 같이 합계를 인쇄합니다.
File name: slippers.png
121081 pixels are bright.