title: Polarizing an image--how to find the average of each RGB value
body: <p>For an exercise in image processing, I have to write a program that applies various effects to images. One of the effects was grayscale, which was done find the average of RGB values ((red+green+blue)/3). To polarize an image, however, I need to first find the averages of each individual component (i.e. all red values/number of red pixels). Would it be appropriate to then loop through the rows and columns (with a counter for pixels, red values, green values, and blue values) as a way to find the average? Is there a more efficient way?</p>
  
  <p>Also, pixels are polarized based on the average pixel value. "If average R is 100, average G is 200, and average B is 300 and a pixel has R 150, G 150, and B, 100, the polarized pixel would be 255, 0, and 0." I don't understand the relationship? Is it if the current value is less than the average, then it would be polarized to 0/more than the average, polarized to 255?</p>