Android Bitmap Color Get getContactCount(Bitmap bitmap)

Here you can find the source of getContactCount(Bitmap bitmap)

Description

get Contact Count

Declaration

public static int getContactCount(Bitmap bitmap) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static int getContactCount(Bitmap bitmap) {
        int toReturn = 0;
        int hlen = bitmap.getWidth(), vlen = bitmap.getHeight();
        for (int i = 0; i < vlen; i++) {
            for (int j = 0; j < hlen; j++) {
                if ((bitmap.getPixel(j, i) & 0xff) > 0) {
                    // check right border
                    if (j + 1 < hlen
                            && (bitmap.getPixel(j + 1, i) & 0xff) > 0) {
                        toReturn++;/*from  w  w  w  .  j a v  a  2s .c o m*/
                    }
                    // check bottom border
                    if (i + 1 < vlen
                            && (bitmap.getPixel(j, i + 1) & 0xff) > 0) {
                        toReturn++;
                    }
                }
            }
        }

        return toReturn;
    }
}

Related

  1. countSE(Bitmap bitmap, int[][] se)
  2. getPixelsCount(Bitmap bitmap)
  3. kernelMatch(int x, int y, int w, int h, Bitmap bitmap, int[][] se)
  4. getColorHistogram(Bitmap bitmap)
  5. isBitmapWhiteAtTopOrBottom(Bitmap largeBitmap)