Example usage for org.apache.commons.math3.exception MathIllegalArgumentException printStackTrace

List of usage examples for org.apache.commons.math3.exception MathIllegalArgumentException printStackTrace

Introduction

In this page you can find the example usage for org.apache.commons.math3.exception MathIllegalArgumentException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:edu.stanford.cfuller.imageanalysistools.filter.VariableSizeMeanFilter.java

protected boolean shouldSubDivide(OcttreeNode node, Image im, Image laplacianFiltered) {

    im.setBoxOfInterest(node.getBoxMin(), node.getBoxMax());
    laplacianFiltered.setBoxOfInterest(node.getBoxMin(), node.getBoxMax());

    double l_sum = 0;
    double sum = 0;
    double count = 0;

    for (ImageCoordinate ic : im) {
        l_sum += laplacianFiltered.getValue(ic);
        sum += im.getValue(ic);//from ww  w .  j  a v  a  2s .  com
        count++;

    }

    if (count == 1)
        return false;

    l_sum /= count;
    sum /= count;

    double l_var = 0;
    double var = 0;

    for (ImageCoordinate ic : im) {

        l_var += Math.pow(laplacianFiltered.getValue(ic) - l_sum, 2);
        var += Math.pow(im.getValue(ic) - sum, 2);

    }

    l_var /= (count - 1);
    var /= (count - 1);

    im.clearBoxOfInterest();
    laplacianFiltered.clearBoxOfInterest();

    double cutoff = 0.0001;

    double smallerVar = var < l_var ? var : l_var;
    double largerVar = var > l_var ? var : l_var;
    try {

        FDistribution f = new FDistribution(count - 1, count - 1);
        double valueAtLowerCutoff = f.inverseCumulativeProbability(cutoff);
        double valueAtUpperCutoff = f.inverseCumulativeProbability(1 - cutoff);
        boolean result = (smallerVar / largerVar > valueAtUpperCutoff
                || smallerVar / largerVar < valueAtLowerCutoff);
        return result;

    } catch (MathIllegalArgumentException e) {
        LoggingUtilities.getLogger()
                .severe("Exception while calculating variable size mean QO partition: " + e.getMessage());
        e.printStackTrace();
        return false;
    }
}