Android Bitmap Color Change dilate(Bitmap bitmap, int[][] se)

Here you can find the source of dilate(Bitmap bitmap, int[][] se)

Description

dilate

Declaration

public static void dilate(Bitmap bitmap, int[][] se) 

Method Source Code

//package com.java2s;

import android.graphics.Bitmap;

public class Main {
    public static void dilate(Bitmap bitmap, int[][] se) {
        dilate(bitmap.copy(bitmap.getConfig(), false), bitmap, se);
    }//from w w w.  j  av  a  2 s . c  o m

    public static int dilate(Bitmap source, Bitmap target, int[][] se) {
        int hlen = source.getWidth(), vlen = source.getHeight(), offsetX = (int) -Math
                .floor(se[0].length / 2), offsetY = (int) -Math
                .floor(se.length / 2);
        int toReturn = 0;
        for (int i = 0; i < vlen; i++) {
            for (int j = 0; j < hlen; j++) {
                if ((source.getPixel(j, i) & 0xff) > 0) {
                    kernelDilate(j, i, hlen, vlen, target, se, offsetX,
                            offsetY);
                    toReturn++;
                }
            }
        }

        return toReturn;
    }

    private static void kernelDilate(int x, int y, int w, int h,
            Bitmap target, int[][] se, int offsetX, int offsetY) {
        int lenh = se[0].length, lenv = se.length, xPos, yPos;
        for (int i = 0; i < lenv; i++) {
            for (int j = 0; j < lenh; j++) {
                if ((yPos = i + y + offsetY) > 0
                        && (xPos = x + j + offsetX) > 0 && yPos < h
                        && xPos < w && se[i][j] == 1) {
                    target.setPixel(xPos, yPos, 0xffffffff);
                }
            }
        }
    }
}

Related

  1. boost(Bitmap src)
  2. brightness(Bitmap src, int value)
  3. changeHue(Bitmap bmp, int hue, int width, int height)
  4. createAnaglyphBitmap(Bitmap bitmap)
  5. createSaturatedBitmap(final Bitmap bitmap)
  6. dilate(Bitmap source, Bitmap target, int[][] se)
  7. doBrightness(Bitmap src, int value)
  8. erosion(Bitmap bitmap, int[][] se)
  9. getGrayscaleHistogram(Bitmap bm)