public static double dist(Mat src1, Mat src2, NormType normType) {
        assert(src1.cols == src2.cols && src1.rows == src2.rows);
        if (src1.isEmpty()) {            // is this proper way?
            return norm(src2, normType); // if src1 is empty , return norm of src2
        }
        if (src2.isEmpty()) {			 // is this proper way?
            return norm(src1, normType); // if src1 is empty , return norm of src2
        }
        double sum = 0.0;
        double diff;
        switch (normType) {
            // L1 norm,  get absolute value of all elements, return the squared
            // root of sum
            case NORM_L1: {
                for (int i = 0; i < src1.data.length; i++) {
                    diff = src1.data[i] - src2.data[i];
                    sum += diff > 0 ? diff : -diff;
                }
                break;
            }

            // L2 norm, get sum of squared of all elements, return the squared
            // root of sum
            case NORM_L2: {
                for (int i = 0; i < src1.data.length; i++) {
                    diff = src1.data[i] - src2.data[i];
                    sum += diff * diff;
                }
                sum = Math.sqrt(sum);
                break;
            }

            default:
                break;
        }
        return sum;
    }