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

io.github.mianalysis.mia.process.activecontour.energies.ImageGradientEnergy 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

//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 ImageGradientEnergy extends Energy {
    private double[][] im_x;
    private double[][] im_y;

    public ImageGradientEnergy(double weight, double[][] im_x, double[][] im_y) {
        super(weight);

        this.im_x = im_x;
        this.im_y = im_y;

    }

    public ImageGradientEnergy(double weight, ImagePlus ipl_x, ImagePlus ipl_y) {
        super(weight);

        int w = ipl_x.getWidth();
        int h = ipl_x.getHeight();

        im_x = new double[w][h];
        im_y = new double[w][h];

        ImageProcessor ipr_x = ipl_x.getProcessor();
        ImageProcessor ipr_y = ipl_y.getProcessor();

        for (int r=0;r= 0 & x < w & y >= 0 & y < h) {
            term_x = Math.pow(im_x[x][y],2);
            term_y = Math.pow(im_y[x][y],2);

        }

        double energy = -weight*(term_x+term_y);

        return energy;

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy