Android Bitmap Color Change getGrayscaleHistogram(Bitmap bm)

Here you can find the source of getGrayscaleHistogram(Bitmap bm)

Description

get Grayscale Histogram

Declaration

public static int[] getGrayscaleHistogram(Bitmap bm) 

Method Source Code

//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;
    }
}

Related

  1. createSaturatedBitmap(final Bitmap bitmap)
  2. dilate(Bitmap bitmap, int[][] se)
  3. dilate(Bitmap source, Bitmap target, int[][] se)
  4. doBrightness(Bitmap src, int value)
  5. erosion(Bitmap bitmap, int[][] se)
  6. increaseGreen(Bitmap src, int value)
  7. initAlphaChannel( BitmapFactory.Options bitmapOptions)
  8. initBitmapFactoryOptions( BitmapFactory.Options bitmapOptions, int maxWidth, int maxHeight)
  9. makeSaturated(Bitmap source, int level)