Here you can find the source of dilate(Bitmap bitmap, int[][] se)
public static void dilate(Bitmap bitmap, int[][] se)
//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); } } } } }