Search in sources :

Example 21 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Util method serializeFeatures.

/**
 * Save a {@link Collection} of {@link Feature Features} to the TrakEM2
 * project folder.  The saved file contains a key {@link Object} which
 * may specify the properties of the {@link Feature} {@link Collection}.
 *
 * @param project
 * @param key
 * @param prefix
 * @param id
 * @param f
 * @return
 */
public static final boolean serializeFeatures(final Project project, final Object key, final String prefix, final long id, final Collection<Feature> f) {
    final ArrayList<Feature> list = new ArrayList<Feature>();
    list.addAll(f);
    final String name = prefix == null ? "features" : prefix + ".features";
    final Loader loader = project.getLoader();
    final Features fe = new Features(key, list);
    return loader.serialize(fe, new StringBuilder(loader.getUNUIdFolder()).append("features.ser/").append(FSLoader.createIdPath(Long.toString(id), name, ".ser")).toString());
}
Also used : ArrayList(java.util.ArrayList) Loader(ini.trakem2.persistence.Loader) FSLoader(ini.trakem2.persistence.FSLoader) Feature(mpicbg.imagefeatures.Feature)

Example 22 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Util method serializePointMatches.

/**
 * Save a {@link Collection} of {@link PointMatch PointMatches} two-sided.
 * Creates two serialization files which is desperately required to clean
 * up properly invalid serializations on change of a {@link Patch}.
 *
 * @param project
 * @param key
 * @param prefix
 * @param id1
 * @param id2
 * @param m
 * @return
 */
public static final boolean serializePointMatches(final Project project, final Object key, final String prefix, final long id1, final long id2, final Collection<PointMatch> m) {
    final ArrayList<PointMatch> list = new ArrayList<PointMatch>();
    list.addAll(m);
    final ArrayList<PointMatch> tsil = new ArrayList<PointMatch>();
    PointMatch.flip(m, tsil);
    final String name = prefix == null ? "pointmatches" : prefix + ".pointmatches";
    final Loader loader = project.getLoader();
    return loader.serialize(new PointMatches(key, list), new StringBuilder(loader.getUNUIdFolder()).append("pointmatches.ser/").append(FSLoader.createIdPath(Long.toString(id1) + "_" + Long.toString(id2), name, ".ser")).toString()) && loader.serialize(new PointMatches(key, tsil), new StringBuilder(loader.getUNUIdFolder()).append("pointmatches.ser/").append(FSLoader.createIdPath(Long.toString(id2) + "_" + Long.toString(id1), name, ".ser")).toString());
}
Also used : PointMatch(mpicbg.models.PointMatch) ArrayList(java.util.ArrayList) Loader(ini.trakem2.persistence.Loader) FSLoader(ini.trakem2.persistence.FSLoader)

Example 23 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class MatchIntensities method main.

public static final void main(final String... args) {
    new ImageJ();
    final Project project = Project.openFSProject("/home/saalfeld/tmp/intensity-corrected/elastic.xml", true);
    final MatchIntensities matcher = new MatchIntensities();
    matcher.invoke(project.getRootLayerSet());
}
Also used : ImageJ(ij.ImageJ) Project(ini.trakem2.Project)

Example 24 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Render method main.

public static final void main(final String... args) {
    new ImageJ();
    final double scale = 0.05;
    // final double scale = 1;
    final int numCoefficients = 4;
    final Project project = Project.openFSProject("/home/saalfeld/tmp/bock-lens-correction/subproject.xml", false);
    final Layer layer = project.getRootLayerSet().getLayer(0);
    final ArrayList<Patch> patches = (ArrayList) layer.getDisplayables(Patch.class);
    final Patch patch1 = patches.get(0);
    final Patch patch2 = patches.get(2);
    final Rectangle box = patch1.getBoundingBox().intersection(patch2.getBoundingBox());
    // final Rectangle box = patch1.getBoundingBox();
    final int w = (int) (box.width * scale + 0.5);
    final int h = (int) (box.height * scale + 0.5);
    final FloatProcessor pixels1 = new FloatProcessor(w, h);
    final FloatProcessor weights1 = new FloatProcessor(w, h);
    final ColorProcessor coefficients1 = new ColorProcessor(w, h);
    final FloatProcessor pixels2 = new FloatProcessor(w, h);
    final FloatProcessor weights2 = new FloatProcessor(w, h);
    final ColorProcessor coefficients2 = new ColorProcessor(w, h);
    render(patch1, numCoefficients, numCoefficients, pixels1, weights1, coefficients1, box.x, box.y, scale);
    render(patch2, numCoefficients, numCoefficients, pixels2, weights2, coefficients2, box.x, box.y, scale);
    final ImageStack stack = new ImageStack(w, h);
    stack.addSlice(pixels1);
    stack.addSlice(pixels2);
    stack.addSlice(weights1);
    stack.addSlice(weights2);
    stack.addSlice(coefficients1.convertToFloatProcessor());
    stack.addSlice(coefficients2.convertToFloatProcessor());
    new ImagePlus("", stack).show();
}
Also used : FloatProcessor(ij.process.FloatProcessor) ImageStack(ij.ImageStack) ArrayList(java.util.ArrayList) Rectangle(java.awt.Rectangle) Layer(ini.trakem2.display.Layer) ImagePlus(ij.ImagePlus) Point(mpicbg.models.Point) ImageJ(ij.ImageJ) Project(ini.trakem2.Project) ColorProcessor(ij.process.ColorProcessor) Patch(ini.trakem2.display.Patch)

Example 25 with Project

use of ini.trakem2.Project in project TrakEM2 by trakem2.

the class Display method findLandmarkNodes.

private static final Hashtable<String, ProjectThing> findLandmarkNodes(final Project p, final String landmarks_type) {
    final Set<ProjectThing> landmark_nodes = p.getRootProjectThing().findChildrenOfTypeR(landmarks_type);
    final Hashtable<String, ProjectThing> map = new Hashtable<String, ProjectThing>();
    for (final ProjectThing pt : landmark_nodes) {
        map.put(pt.toString() + "# " + pt.getId(), pt);
    }
    return map;
}
Also used : Hashtable(java.util.Hashtable) ProjectThing(ini.trakem2.tree.ProjectThing)

Aggregations

ArrayList (java.util.ArrayList)33 Project (ini.trakem2.Project)26 HashMap (java.util.HashMap)25 Layer (ini.trakem2.display.Layer)21 Displayable (ini.trakem2.display.Displayable)19 Patch (ini.trakem2.display.Patch)18 File (java.io.File)18 HashSet (java.util.HashSet)18 ZDisplayable (ini.trakem2.display.ZDisplayable)17 ImagePlus (ij.ImagePlus)16 ProjectThing (ini.trakem2.tree.ProjectThing)16 Worker (ini.trakem2.utils.Worker)16 TemplateThing (ini.trakem2.tree.TemplateThing)15 Map (java.util.Map)15 LayerSet (ini.trakem2.display.LayerSet)14 ResultSet (java.sql.ResultSet)13 DBObject (ini.trakem2.persistence.DBObject)12 AffineTransform (java.awt.geom.AffineTransform)11 TreeMap (java.util.TreeMap)11 FSLoader (ini.trakem2.persistence.FSLoader)10