io.github.mianalysis.mia.process.activecontour.energies.PathEnergy Maven / Gradle / Ivy
package io.github.mianalysis.mia.process.activecontour.energies;
import ij.ImagePlus;
import ij.process.ImageProcessor;
import io.github.mianalysis.mia.process.activecontour.physicalmodel.Vertex;
import io.github.mianalysis.mia.process.math.CumStat;
import io.github.mianalysis.mia.process.voxel.BresenhamLine;
/**
* Created by sc13967 on 23/09/2016.
*/
public class PathEnergy extends Energy{
private double[][] im;
public PathEnergy(double weight, double[][] im) {
super(weight);
this.im = im;
}
public PathEnergy(double weight, ImagePlus ipl) {
super(weight);
int w = ipl.getWidth();
int h = ipl.getHeight();
im = new double[w][h];
ImageProcessor ipr = ipl.getProcessor();
for (int r=0;rim.length || y1>im[0].length) return Double.MAX_VALUE;
int[][] line = BresenhamLine.getLine(x1,x2,y1,y2);
CumStat cs = new CumStat();
for (int i=0;i= im.length || y < 0 || y >= im[0].length) cs.addMeasure(Double.POSITIVE_INFINITY);
else cs.addMeasure(Math.pow(im[x][y],2));
}
return cs.getMean();
}
}