// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java
// public class CV4JException extends RuntimeException {
// 
//     private static final long serialVersionUID = -2565764903880816387L;
// 
//     public CV4JException(String message) {
//         super(message);
//     }
// 
//     public CV4JException(Throwable throwable) {
//         super(throwable);
//     }
// 
//     public CV4JException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


import com.cv4j.exception.CV4JException;
        // start to normalize the histogram data
        double[] hist1 = new double[len];
        double[] hist2 = new double[len];
        double sum1=0, sum2=0;
        for (int i = 0; i < len; i++)
        {
            sum1 += source[i];
            sum2 += target[i];
        }
        for (int i = 0; i < len; i++)
        {
            hist1[i] = source[i] / sum1;
            hist2[i] = target[i] / sum2;
        }

        for(int i=0; i<len; i++ ) {
            mixedData[i] = Math.sqrt(hist1[i] * hist2[i]);
        }

        // The values of Bhattacharyya Coefficient ranges from 0 to 1,
        double similarity = 0;
        for(int i=0; i<mixedData.length; i++ ) {
            similarity += mixedData[i];
        }

        // The degree of similarity
        return similarity;
    }

    public double covariance(int[] source, int[] target) {
// Path: desktop/src/main/java/com/cv4j/exception/CV4JException.java
// public class CV4JException extends RuntimeException {
// 
//     private static final long serialVersionUID = -2565764903880816387L;
// 
//     public CV4JException(String message) {
//         super(message);
//     }
// 
//     public CV4JException(Throwable throwable) {
//         super(throwable);
//     }
// 
//     public CV4JException(String message, Throwable throwable) {
//         super(message, throwable);
//     }
// }


// Path: desktop/src/main/java/com/cv4j/core/hist/CompareHist.java
import com.cv4j.exception.CV4JException;

        // start to normalize the histogram data
        double[] hist1 = new double[len];
        double[] hist2 = new double[len];
        double sum1=0, sum2=0;
        for (int i = 0; i < len; i++)
        {
            sum1 += source[i];
            sum2 += target[i];
        }
        for (int i = 0; i < len; i++)
        {
            hist1[i] = source[i] / sum1;
            hist2[i] = target[i] / sum2;
        }

        for(int i=0; i<len; i++ ) {
            mixedData[i] = Math.sqrt(hist1[i] * hist2[i]);
        }

        // The values of Bhattacharyya Coefficient ranges from 0 to 1,
        double similarity = 0;
        for(int i=0; i<mixedData.length; i++ ) {
            similarity += mixedData[i];
        }

        // The degree of similarity
        return similarity;
    }

    public double covariance(int[] source, int[] target) {
        if(source.length != target.length) {