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