Here you can find the source of normalizeHistogram(int[] h)
public static double[] normalizeHistogram(int[] h)
//package com.java2s; //License from project: GNU General Public License public class Main { public static double[] normalizeHistogram(double[] h) { // find max histogram entry double max = h[0]; for (int i = 0; i < h.length; i++) { if (h[i] > max) max = h[i];// w w w . j a v a 2 s. c o m } if (max == 0) return null; // normalize double[] hn = new double[h.length]; double s = 1.0 / max; for (int i = 0; i < h.length; i++) { hn[i] = s * h[i]; } return hn; } public static double[] normalizeHistogram(int[] h) { // find the max histogram entry int max = h[0]; for (int i = 0; i < h.length; i++) { if (h[i] > max) max = h[i]; } if (max == 0) return null; // normalize double[] hn = new double[h.length]; double s = 1.0 / max; for (int i = 0; i < h.length; i++) { hn[i] = s * h[i]; } return hn; } }