Here you can find the source of average(int[] pixels)
public static int average(int[] pixels)
//package com.java2s; //License from project: Apache License public class Main { public static int average(int[] pixels) { float m = 0; for (int i = 0; i < pixels.length; ++i) { m += pixels[i];/*from www . j a v a 2 s. c o m*/ } m = m / pixels.length; return (int) m; } }