How can I efficiently calculate average RGB values from a jpeg image in java? I need not get super accurate result, but i need a faster algorithm with good accuracy.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This sort of thing is what sampling is perfect for. If you choose the pixels you sample at random, your answer will converge on the correct answer fairly quickly. Methods like this are called Monte Carlo methods.
To illustrate this to yourself, I suggest using a sample image, and write a program to find out the true average. Now write a program to take N pixels at random uniformly over the entire image and run it for N=10, 100, 1000, 10000 and see for yourself how many you need to be accurate enough.