title: Detection of Transition Frames from Video
body: <p>I would like to add a set of pictures on my computer to a list. If the <code>r</code>, <code>g</code> and <code>b</code> values of a pixel constituting the image are greater than 20, then I want to count the pixel. If the number of counted pixels is greater than 20000 for a particular image, I want add the location of that image to a list (<code>trans_frames</code>). I think I am having issues with the <code>if trans_check &gt; 20000</code> statement. I am also interested in how to save that list to a file. Any suggestions?</p>
  <pre><code>from PIL import Image
  import glob
  
  all_frames = glob.glob('/Users/isaiahnields/Documents/Code/#g_isaiah/Python/Code/Isaiah/Subtractions/'+'/*.png') #add location of pictures to list
  all_frames.sort() #sort pictures in numberical order
  trans_frames = [] #transition frames list
  for index in range(0, len(all_frames)): #for loop for each picture
      image1_nominal = all_frames[index]
      image1 = Image.open(image1_nominal)
      width, height = image1.size
      trans_check = 0
      for x in range(0 , width):
          for y in range(0 , height):
              r, g, b = image1.getpixel( (x,y))
              if r &gt; 20 and g &gt; 20 and b &gt; 20:
                  trans_check = trans_check + 1
                  if trans_check &gt; 20000: #I am having issues here
                      trans_check = 0
                      trans_frames.append(image1_nominal)
                      print trans_frames
  </code></pre>