Python Forum
grayscale image processing
Thread Rating:
  • 3 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
grayscale image processing
#11
You still have to find the maximum yourself.
As Mekire already said: This solution is slow.

from PIL import Image
img  = Image.open('grey.jpg')

for row in range(img.height):
    counter = 0
    for col in range(img.width):
        pixel = img.getpixel((col,row))
        red   = pixel[0]; green = pixel[1]; blue  = pixel[2]
        grey  = (red + green + blue) // 3
        if grey > 200:
            counter += 1
    if counter != 0:
        print("row %d: %d" % (row, counter))
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pillow Image Processing matteusbeus 2 2,956 Nov-02-2017, 03:07 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020