Search in sources :

Example 6 with PatchStack

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);
    }
}
Also used : ImageProcessor(ij.process.ImageProcessor) Loader(ini.trakem2.persistence.Loader) ImagePlus(ij.ImagePlus)

Example 7 with PatchStack

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
}
Also used : Loader(ini.trakem2.persistence.Loader) ImagePlus(ij.ImagePlus)

Example 8 with PatchStack

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);
}
Also used : Loader(ini.trakem2.persistence.Loader) ImagePlus(ij.ImagePlus)

Aggregations

ImagePlus (ij.ImagePlus)7 PatchStack (ini.trakem2.imaging.PatchStack)4 Loader (ini.trakem2.persistence.Loader)3 ArrayList (java.util.ArrayList)3 ImageProcessor (ij.process.ImageProcessor)2 ImageStatistics (ij.process.ImageStatistics)2 StackStatistics (ij.process.StackStatistics)2 Content (ij3d.Content)2 Displayable (ini.trakem2.display.Displayable)2 Patch (ini.trakem2.display.Patch)2 GenericDialog (ij.gui.GenericDialog)1 Calibration (ij.measure.Calibration)1 ZDisplayable (ini.trakem2.display.ZDisplayable)1 EqualizeHistogram (ini.trakem2.imaging.filters.EqualizeHistogram)1 TaskFactory (ini.trakem2.parallel.TaskFactory)1 Rectangle (java.awt.Rectangle)1 File (java.io.File)1 HashSet (java.util.HashSet)1 SortedMap (java.util.SortedMap)1 TreeMap (java.util.TreeMap)1