Here you can find the source of getGrayscaleHistogram(Bitmap bm)
public static int[] getGrayscaleHistogram(Bitmap bm)
//package com.java2s; import android.graphics.Bitmap; public class Main { public static int[] getGrayscaleHistogram(Bitmap bm) { int[] histogram = new int[256]; int ptr = 0; while (ptr < histogram.length) histogram[ptr++] = 0;//from ww w . jav a 2 s. c o m int hlen = bm.getWidth(), vlen = bm.getHeight(); int pixel; for (int y = 0; y < vlen; y++) { for (int x = 0; x < hlen; x++) { pixel = bm.getPixel(x, y); histogram[pixel & 0xff]++; } } return histogram; } }