Python Forum
how to analayze only a part of an image?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to analayze only a part of an image?
#1
lets say i wanted to counte the black pixels in the bottom right 200x200 pixels of every image.
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
Reply


Messages In This Thread
how to analayze only a part of an image? - by nadavrock - May-28-2019, 12:06 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  error "cannot identify image file" part way through running hatflyer 0 737 Nov-02-2023, 11:45 PM
Last Post: hatflyer
  Replacing part of a source image with the matching template image Glasgow1988 2 2,022 Jul-17-2020, 03:02 PM
Last Post: Glasgow1988

Forum Jump:

User Panel Messages

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