answered Dec 20 '12
You can use mean function in C++ and Core.mean() from Java. It is native OpenCV function and it is rather faster then individual pixel access from Java code.