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

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

Description

dilate

Declaration

public static int dilate(Bitmap source, Bitmap target, 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  ww.  j a  v  a2  s.co  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. brightness(Bitmap src, int value)
  2. changeHue(Bitmap bmp, int hue, int width, int height)
  3. createAnaglyphBitmap(Bitmap bitmap)
  4. createSaturatedBitmap(final Bitmap bitmap)
  5. dilate(Bitmap bitmap, int[][] se)
  6. doBrightness(Bitmap src, int value)
  7. erosion(Bitmap bitmap, int[][] se)
  8. getGrayscaleHistogram(Bitmap bm)
  9. increaseGreen(Bitmap src, int value)