Jimmey
November 20th, 2010, 09:10 PM
I am currently writing a program in python to handle large numbers of image files (for my purposes, 2,000+).
I really need to get the "average image colour", with the same result as has been achieved using this code (http://pythonicprose.blogspot.com/2009/09/python-find-average-rgb-color-for-image.html).
[The code retrieves and totals the R, G, B values for each pixel in the image, and divides the total for each by the number of pixels, resulting in an average.]
The problem is, previously, the program would run for between 10-20 seconds through the images I have. Just by adding the code to open each of these images using the PIL alone, I over double that time. And when I use the above algorithm, the time multiplies even higher.
Is there any quicker way to get the average image colour that anybody is aware of?
Would it be much quicker to re-write a similar algorithm in a language like C++?
Any help is appreciated.
Jimmey
I really need to get the "average image colour", with the same result as has been achieved using this code (http://pythonicprose.blogspot.com/2009/09/python-find-average-rgb-color-for-image.html).
[The code retrieves and totals the R, G, B values for each pixel in the image, and divides the total for each by the number of pixels, resulting in an average.]
The problem is, previously, the program would run for between 10-20 seconds through the images I have. Just by adding the code to open each of these images using the PIL alone, I over double that time. And when I use the above algorithm, the time multiplies even higher.
Is there any quicker way to get the average image colour that anybody is aware of?
Would it be much quicker to re-write a similar algorithm in a language like C++?
Any help is appreciated.
Jimmey