Here you can find the source of erosion(Bitmap bitmap, int[][] se)
public static void erosion(Bitmap bitmap, int[][] se)
//package com.java2s; import android.graphics.Bitmap; public class Main { public static void erosion(Bitmap bitmap, int[][] se) { int hlen = bitmap.getWidth(), vlen = bitmap.getHeight(); for (int i = 0; i < vlen; i++) { for (int j = 0; j < hlen; j++) { bitmap.setPixel(/*from w w w. j a va 2 s .c om*/ j, i, kernelMatch(j, i, hlen, vlen, bitmap, se) ? 0xffffffff : 0xff000000); } } } private static boolean kernelMatch(int x, int y, int w, int h, Bitmap bitmap, int[][] se) { int lenh = se[0].length, lenv = se.length; for (int i = 0; i < lenv; i++) { for (int j = 0; j < lenh; j++) { int pVal = ((bitmap.getPixel((x + j) % w, (y + i) % h) & 0xff) > 0 ? 1 : 0); if (se[i][j] != pVal) { return false; } } } return true; } }