use of ini.trakem2.imaging.PatchStack in project TrakEM2 by trakem2.
the class PatchStack method resetNonActive.
/**
* Reset temporary changes such as from dragging B&C sliders and so on, in the current slice (the current Patch).
*/
public void resetNonActive() {
Utils.log2("PatchStack: calling reset");
// remake the awt for the patch, flush the previous awt
Loader loader = patch[currentSlice - 1].getProject().getLoader();
for (int i = 0; i < patch.length; i++) {
if (currentSlice - 1 == i || !called[i])
continue;
called[i] = false;
ImagePlus imp = loader.fetchImagePlus(patch[i]);
ImageProcessor ip = imp.getProcessor();
switch(// as in ij.plugin.frame.ContrastAdjuster.reset(ImagePlus, ImageProcessor)
imp.getType()) {
case ImagePlus.COLOR_RGB:
ip.reset();
break;
case ImagePlus.GRAY16:
case ImagePlus.GRAY32:
ip.resetMinAndMax();
break;
}
patch[i].setMinAndMax(ip.getMin(), ip.getMax());
patch[i].getProject().getLoader().decacheAWT(patch[i].getId());
Display.repaint(patch[i].getLayer(), patch[i], null, 0, true);
}
}
use of ini.trakem2.imaging.PatchStack in project TrakEM2 by trakem2.
the class PatchStack method setProcessor.
public void setProcessor(String title, ImageProcessor ip) {
// so not applied to stacks
if (1 != patch.length)
return;
Loader loader = patch[currentSlice - 1].getProject().getLoader();
ImagePlus imp = loader.fetchImagePlus(patch[currentSlice - 1]);
if (ip.getWidth() != imp.getWidth() || ip.getHeight() != imp.getHeight())
throw new IllegalArgumentException("PatchStack: ip wrong size");
// null means don't touch title
imp.setProcessor(null, ip);
patch[currentSlice - 1].updateInDatabase("tiff_working");
// loader.vacuum();
// repainting elsewhere
}
use of ini.trakem2.imaging.PatchStack in project TrakEM2 by trakem2.
the class PatchStack method saveImages.
/**
* Store working copies and remake the awts and repaint.
*/
public void saveImages() {
Utils.log2("PatchStack: calling saveImages");
if (!this.changes) {
Utils.log2("PatchStack.saveImages: nothing changed.");
return;
}
Loader loader = patch[currentSlice - 1].getProject().getLoader();
Utils.showProgress(0);
for (int i = 0; i < patch.length; i++) {
ImagePlus imp = loader.fetchImagePlus(patch[i]);
Utils.log2("PatchStack.saveImages: patch imp " + i + " has the imp.changes=" + imp.changes + " and the called[i]=" + called[i]);
if (imp.changes || called[i]) {
// may be doing it twice, check TODO
patch[i].updateInDatabase("tiff_working");
/*
patch[i].createImage(); //flushes the old awt, and creates the new one, and stores it in the cache.
*/
// just flush away all dependent images, will be recreated when needed on repaint
patch[i].getProject().getLoader().decache(imp);
Display.repaint(patch[i].getLayer(), patch[i], 0);
// reset
imp.changes = false;
called[i] = false;
}
Utils.showProgress((i + 1.0) / patch.length);
}
this.changes = false;
// patch[0].getProject().getLoader().vacuum();
Utils.showProgress(1);
}
Aggregations