hi there, i have written a function to calculate entropy of an MBFImage, how can i make sure that its correct???
i have tried to convert this code https://rosettacode.org/wiki/Entropy#Java to work for image...

thanks for your precious time, in advance...

public class Entropy {

    public static void main(String[] args) throws IOException {
        MBFImage image_color = ImageUtilities.readMBF(new File("lena_color.gif"));
        System.out.println("color entropy" + getShannonEntropy(image_color));
    }

    public static float getShannonEntropy(MBFImage image) {

        int bins = 256;
        HistogramModel model = new HistogramModel(bins);
        model.estimateModel(image);
        MultidimensionalHistogram hist = model.histogram;

        int n = image.getWidth() * image.getHeight();

        double[] list = hist.values;
        float e = 0.0f;

        for (double d : list) {

            if (d != 0.0) {
                double p = d / n;

                e += p * log2(p);

            }
        }

        return -e;
    }

    private static double log2(double a) {
        return Math.log(a) / Math.log(2);
    }
}