All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.mianalysis.mia.process.activecontour.energies.PathEnergy Maven / Gradle / Ivy

Go to download

ModularImageAnalysis (MIA) is an ImageJ plugin which provides a modular framework for assembling image and object analysis workflows. Detected objects can be transformed, filtered, measured and related. Analysis workflows are batch-enabled by default, allowing easy processing of high-content datasets.

There is a newer version: 1.6.12
Show newest version
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();

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy