Android based project coding<font color=#AA0080></font>
package com.AndroidImageProcessing;
Â
import android.app.Activity;
import android.os.Bundle<font size=5>;
</font>import android.widget.TextView;
Â
public class AndroidImageProcessingActivity extends Activity {
 Â
 final static int KERNAL_WIDTH = 3;
 final static int KERNAL_HEIGHT = 3;
 final static int MATRIX_WIDTH = 5;
 final static int MATRIX_HEIGHT = 5;
 Â
 int[][] kernal ={
   {0, 1, 0},
   {0, 0, 0},
   {0, 0, 0}
 };
 Â
 int[][] dataOriginal = {
   {35, 40, 41, 45, 50},
   {40, 40, 42, 46, 52},
   {42, 46, 50, 55, 55},
   {48, 52, 56, 58, 60},
   {56, 60, 65, 70, 75}
 };
 Â
 int[][] dataResult = new int[MATRIX_WIDTH][MATRIX_HEIGHT];
 Â
 TextView textOriginal, textResult;
 Â
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        textOriginal = (TextView)findViewById(R.id.original);
        textResult = (TextView)findViewById(R.id.result);
        Â
        dataResult = convolution(dataOriginal, kernal);
        Â
        textOriginal.setText("dataOriginal:\n" + getDataString(dataOriginal) + "\n");
        textResult.setText("dataResult:\n" + getDataString(dataResult) + "\n");
    }
    Â
    private String getDataString(int[][] d){
     String s = "";
     Â
     for(int i = 0; i < d.length; i++){
      for(int j = 0; j < d[i].length; j++){
       s += " " + String.format("%02d", d[i][j]);
      }
      s += "\n";
     }
     Â
     return s;
    }
    Â
    private int[][] convolution(int[][] src, int[][] knl){
     int[][] convolutionResult = new int[MATRIX_WIDTH][MATRIX_HEIGHT];
     Â
     for(int i = 1; i <= src.length-2; i++){
      for(int j = 1; j <= src[i].length-2; j++){
       Â
       //get the surround 3*3 pixel of current src[i][j] into a matrix subSrc[][]
       int[][] subSrc = new int[KERNAL_WIDTH][KERNAL_HEIGHT];
       for(int k = 0; k < subSrc.length; k++){
        for(int l = 0; l < subSrc[k].length; l++){
         subSrc[k][l] = src[i-1+k][j-1+l];
        }
       }
       Â
       //subSum = subSrc[][] * knl[][]
       int subSum = 0;
       for(int k = 0; k < knl.length; k++){
        for(int l = 0; l < knl[k].length; l++){
         subSum += subSrc[k][l] * knl[k][l];
        }
       }
Â
       convolutionResult[i][j] = subSum;
      }
     }
     Â
     return convolutionResult;
    }
}