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

JSci.instruments.PTTemplate Maven / Gradle / Ivy

Go to download

JSci is a set of open source Java packages. The aim is to encapsulate scientific methods/principles in the most natural way possible. As such they should greatly aid the development of scientific based software. It offers: abstract math interfaces, linear algebra (support for various matrix and vector types), statistics (including probability distributions), wavelets, newtonian mechanics, chart/graph components (AWT and Swing), MathML DOM implementation, ... Note: some packages, like javax.comm, for the astro and instruments package aren't listed as dependencies (not available).

The newest version!
package JSci.instruments;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.border.*;
import java.text.*;

/** Find a given template in a two dimensional image. Usage:
 * press Add button; the image stops; select a template with the inner 
 * rectangle; press Done. The tracking starts immediately. If you want to 
 * track another object, simply repeat the procedure. Select an object
 * number before Remove.
 */
public class PTTemplate implements ImageFilter,ParticleTracker {

    private static long startTime = System.currentTimeMillis();;
    private TwoROI theROI = null;
    private Image stillImage=null;
    private boolean catchImage=false;
    private JComboBox crossCombo = new JComboBox();

    /** @param r a TwoROI is needed. The inner rectangle represents the
     * template to be searched for; the outer represents the region in which the template is searched. 
     */
    public PTTemplate(TwoROI r) {
	theROI = r;
    }

    private ImageSink sink;
    public void setSink(ImageSink fs) {
        if (sink!=fs) {
            sink=fs;
            sink.setSource(this);
        }
    }

    private ImageSource source = null;
    public void setSource(ImageSource fs) {
        if (source!=fs) {
            source=fs;
            source.setSink(this);
        }
    }

    public int getWidth() { return source.getWidth(); }
    public int getHeight() { return source.getHeight(); }
    public Dimension getSize() { return source.getSize(); }


    /** defines the name of the filter */
    public String getName() { return "PT Template"; }

    private ParticleTrackerListener ptl = null;
    public void setListener(ParticleTrackerListener ptl) {
	this.ptl=ptl;
    }

    public String toString() {
	return "Particle Tracking - Template; startTime="+startTime;
    }

    /** find the bead */
    public void receive(Image f) {
	ListModel l = crossCombo.getModel();
	if (l.getSize()>=0) {
	    int[] n=new int[l.getSize()];
	    double[] x=new double[l.getSize()];
	    double[] y=new double[l.getSize()];
	    for (int j=0;j




© 2015 - 2024 Weber Informatics LLC | Privacy Policy