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

io.github.mianalysis.mia.process.activecontour.energies.ImageEnergy 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
//TODO: Add math for getEnergy
//TODO: Check if the energy here wants to be the squared pixel value

//Gradient images are converted to generalised 2D double arrays.  This means different constructors could be used down
//the line for other image formats.

package io.github.mianalysis.mia.process.activecontour.energies;

import ij.ImagePlus;
import ij.process.ImageProcessor;
import io.github.mianalysis.mia.process.activecontour.physicalmodel.Vertex;

/**
 * Created by Stephen on 16/09/2016.
 */
public class ImageEnergy extends Energy {
    private double[][] im;

    public ImageEnergy(double weight, double[][] im) {
        super(weight);

        this.im = im;

    }

    public ImageEnergy(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;r= 0 & x < w & y >= 0 & y < h) term = Math.pow(im[x][y],2);
        else term = Double.POSITIVE_INFINITY;

        return weight*term;

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy