title: Is it possible to find average color of an image from its histogram?
body: <p>I took the average of each color by <a href="https://stackoverflow.com/questions/7563315/how-to-loop-over-histogram-to-get-the-color-of-the-picture">this method</a> and wrote the average of red, green and blue to database. </p>
  
  <p><a href="http://ting-1.appspot.com/displayimage" rel="nofollow noreferrer">Here are the images</a> sorted by "-blue". As you can see the 5th image has the most blue. Am I doing something wrong, or is it not possible to get average color from the histogram?</p>
  
  <p>This is the handler where I create the histogram:</p>
  
  <pre><code>class ImageSave(webapp.RequestHandler):
      def post(self):
          homepage = HomePage()
          original_image = self.request.get("img")
          url = self.request.get("url")
          firm_name = self.request.get("firm_name")
  
          original_image = db.Blob(original_image)
          thumbnail = images.resize(original_image, 250, 250)
          img = images.Image(thumbnail)
          hist = img.histogram()
          rgb_weighed_average = hist_weighed_average(hist)
  
          #update database
          homepage.original_image = original_image            
          homepage.thumbnail = thumbnail
          homepage.firm_name = firm_name
          homepage.url = url
  
          homepage.red = rgb_weighed_average[0]
          homepage.green = rgb_weighed_average[1]
          homepage.blue = rgb_weighed_average[2]
  
          homepage.put()
  
          self.redirect("/imageupload")
  </code></pre>
  
  <p>Thanks!</p>