简体   繁体   English

java如何从大小约为800x600的图像中获取平均RGB值

[英]java how can I get average RGB values from a image sizing about 800x600

How can I efficiently calculate average RGB values from a jpeg image in java? 如何在Java中从jpeg图像有效地计算平均RGB值? I need not get super accurate result, but i need a faster algorithm with good accuracy. 我不需要获得超级准确的结果,但是我需要一个速度更快且算法准确的算法。

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. 现在编写一个程序,以在整个图像上均匀地随机获取N个像素,并在N = 10、100、1000、10000的情况下运行它,然后亲自查看需要多少像素才能足够准确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM