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());
}
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());
}
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());
}
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();
}
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;
}
Aggregations