get Differential Int Matrix - Java java.lang

Java examples for java.lang:Math Matrix

Description

get Differential Int Matrix

Demo Code


//package com.java2s;

public class Main {
    public static int[][] getDifferentialIntMatrix(int[][] intMatrix,
            int width, int height) {
        int[][] differentialIntMatrix = new int[width - 1][height - 1];

        for (int i = 0; i < width - 1; i++) {
            for (int j = 0; j < height - 1; j++) {
                //two components of the "gradient" vector
                int diffx = intMatrix[i][j + 1] - intMatrix[i][j];
                int diffy = intMatrix[i + 1][j] - intMatrix[i][j];
                //I put the module in the matrix though
                differentialIntMatrix[i][j] = (int) Math.floor(Math
                        .sqrt(diffx * diffx + diffy * diffy));
            }/*w ww .  j a  v  a  2  s.  c  o m*/
        }

        return differentialIntMatrix;
    }
}

Related Tutorials