How to find the average pixel value for a rectangular region
I have a rectangular region in an image and have to calculate the average value.
One way I can do is parsing through each pixel value to calculate the average, but that is not an efficient way. Is there any better approach to do in openCV, preferably JAVA.