Search in sources :

Example 1 with Duplicator

use of ij.plugin.Duplicator in project mcib3d-core by mcib3d.

the class ImagePlus_Utils method extractCurrentStack.

public static ImagePlus extractCurrentStack(ImagePlus plus) {
    // check dimensions
    // XYCZT
    int[] dims = plus.getDimensions();
    int channel = plus.getChannel();
    int frame = plus.getFrame();
    ImagePlus stack;
    // crop actual frame
    if ((dims[2] > 1) || (dims[4] > 1)) {
        IJ.log("Hyperstack found, extracting current channel " + channel + " and frame " + frame);
        Duplicator duplicator = new Duplicator();
        stack = duplicator.run(plus, channel, channel, 1, dims[3], frame, frame);
    } else
        stack = plus.duplicate();
    return stack;
}
Also used : Duplicator(ij.plugin.Duplicator) ImagePlus(ij.ImagePlus)

Example 2 with Duplicator

use of ij.plugin.Duplicator in project volumetric-tissue-exploration-analysis by icbm-iupui.

the class JTextAreaFile method getMaskStack.

private ImagePlus getMaskStack(MicroObject vol, int[] starts) {
    int xStart = starts[0];
    int yStart = starts[1];
    int zStart = starts[2];
    // ImageStack cropMe = image.getImageStack();
    ChannelSplitter cs = new ChannelSplitter();
    // Roi r = new Roi(xStart, yStart, size, size);
    image.setRoi(new Rectangle(xStart, yStart, size, size));
    Duplicator dup = new Duplicator();
    ImagePlus objImp = dup.run(image);
    // 32x32x19
    ImageStack stNu = cs.getChannel(objImp, channelOfInterest);
    int[] xPixels = vol.getPixelsX();
    int[] yPixels = vol.getPixelsY();
    int[] zPixels = vol.getPixelsZ();
    ImagePlus temp = IJ.createImage("nuclei", size, size, depth, objImp.getBitDepth());
    // temp.show();
    ImageStack tempStack = temp.getImageStack();
    try {
        for (int i = 0; i < xPixels.length; i++) {
            tempStack.setVoxel(xPixels[i] - xStart, yPixels[i] - yStart, zPixels[i] - zStart, stNu.getVoxel(xPixels[i] - xStart, yPixels[i] - yStart, zPixels[i]));
        }
    } catch (Exception ex) {
        System.out.println("PROFILING: mask stack, object, " + vol.getSerialID() + " dumped with start at: " + zStart);
        return null;
    }
    // }
    return temp;
}
Also used : ImageStack(ij.ImageStack) Duplicator(ij.plugin.Duplicator) Rectangle(java.awt.Rectangle) ChannelSplitter(ij.plugin.ChannelSplitter) ImagePlus(ij.ImagePlus) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Example 3 with Duplicator

use of ij.plugin.Duplicator in project volumetric-tissue-exploration-analysis by icbm-iupui.

the class JTextAreaFile method getBoxStack_old.

private ImagePlus getBoxStack_old(MicroObject vol, int[] starts) {
    int xStart = starts[0];
    int yStart = starts[1];
    int zStart = starts[2];
    int finish = depth + zStart;
    // System.out.println("zstart " + zStart);
    // System.out.println("finish " + finish);
    Duplicator dup = new Duplicator();
    image.setRoi(new Rectangle(xStart, yStart, size, size));
    ImagePlus objImp = dup.run(image);
    ChannelSplitter cs = new ChannelSplitter();
    ImageStack stNu = cs.getChannel(objImp, channelOfInterest);
    ImagePlus objImpNu = new ImagePlus("nuclei", stNu);
    try {
        objImpNu = dup.run(objImpNu, zStart + 1, finish);
    } catch (IllegalArgumentException ex) {
        System.out.println("PROFILING: box stack, object, " + vol.getSerialID() + " dumped with start at: " + zStart);
        return null;
    }
    return objImpNu;
}
Also used : ImageStack(ij.ImageStack) Duplicator(ij.plugin.Duplicator) Rectangle(java.awt.Rectangle) ChannelSplitter(ij.plugin.ChannelSplitter) ImagePlus(ij.ImagePlus)

Example 4 with Duplicator

use of ij.plugin.Duplicator in project volumetric-tissue-exploration-analysis by icbm-iupui.

the class JTextAreaFile method get2ChannelStack.

private ImagePlus get2ChannelStack(MicroObject vol, int[] starts) {
    int xStart = starts[0];
    int yStart = starts[1];
    int zStart = starts[2];
    int finish = depth + zStart;
    // System.out.println("zstart " + zStart);
    // System.out.println("finish " + finish);
    ImageStack cropMe = image.getImageStack();
    ChannelSplitter cs = new ChannelSplitter();
    RGBStackMerge sm = new RGBStackMerge();
    // Roi r = new Roi(xStart, yStart, size, size);
    image.setRoi(new Rectangle(xStart, yStart, size, size));
    Duplicator dup = new Duplicator();
    ImagePlus objImp = dup.run(image);
    // ImageStack stNu = cs.getChannel(objImp, 8); //TODO: nuclei channel is hardcoded
    // ImageStack stActin = cs.getChannel(objImp, 1);
    // ImageStack stapq1 = cs.getChannel(objImp, 3);
    ImagePlus[] sts = cs.split(objImp);
    ImagePlus[] sts_select = new ImagePlus[3];
    sts_select[0] = sts[0];
    sts_select[1] = sts[2];
    sts_select[2] = sts[7];
    // ImageStack multichannel = sm.mergeStacks(size, size, objImp.getNSlices(), stNu, stActin, stapq1, false);
    ImagePlus objImpNu = new ImagePlus();
    HyperStackConverter hsc = new HyperStackConverter();
    // objImpNu = objImpNu.createHyperStack("multi", sts_select.length, objImp.getNSlices(), objImp.getNFrames(), objImp.getBitDepth());
    objImpNu = IJ.createHyperStack("multi", size, size, sts_select.length, objImp.getNSlices(), objImp.getNFrames(), objImp.getBitDepth());
    // for (int c = 1; c <= sts_select.length; c++){
    // objImpNu.setC(c);
    // objImpNu.setStack(sts_select[c-1].getStack());
    // }
    // ImagePlus objImpNu = new ImagePlus("nuclei", multichannel);
    // TODO validate this is correct
    ImagePlus objImpNu_crop = dup.run(objImpNu, zStart, zStart + depth - 1);
    return objImpNu_crop;
}
Also used : HyperStackConverter(ij.plugin.HyperStackConverter) ImageStack(ij.ImageStack) Duplicator(ij.plugin.Duplicator) Rectangle(java.awt.Rectangle) ChannelSplitter(ij.plugin.ChannelSplitter) ImagePlus(ij.ImagePlus) RGBStackMerge(ij.plugin.RGBStackMerge)

Example 5 with Duplicator

use of ij.plugin.Duplicator in project volumetric-tissue-exploration-analysis by icbm-iupui.

the class JTextAreaFile method getBoxStack.

private ImagePlus getBoxStack(MicroObject vol, int[] starts) {
    int xStart = starts[0];
    int yStart = starts[1];
    int zStart = starts[2];
    // ImageStack cropMe = image.getImageStack();
    ChannelSplitter cs = new ChannelSplitter();
    // Roi r = new Roi(xStart, yStart, size, size);
    image.setRoi(new Rectangle(xStart, yStart, size, size));
    Duplicator dup = new Duplicator();
    ImagePlus objImp = dup.run(image);
    ImageStack stNu = cs.getChannel(objImp, channelOfInterest);
    ImagePlus temp = IJ.createImage("nuclei", size, size, depth, objImp.getBitDepth());
    ImageStack tempStack = temp.getImageStack();
    try {
        for (int i = 0; i < size; i++) {
            for (int j = 0; j < size; j++) {
                for (int k = 0; k < depth; k++) {
                    tempStack.setVoxel(i, j, k, stNu.getVoxel(i, j, k + zStart));
                }
            }
        }
    } catch (Exception ex) {
        System.out.println("PROFILING: box2 stack, object, " + vol.getSerialID() + " dumped with start at: " + zStart);
        return null;
    }
    return temp;
}
Also used : ImageStack(ij.ImageStack) Duplicator(ij.plugin.Duplicator) Rectangle(java.awt.Rectangle) ChannelSplitter(ij.plugin.ChannelSplitter) ImagePlus(ij.ImagePlus) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException)

Aggregations

Duplicator (ij.plugin.Duplicator)83 ImagePlus (ij.ImagePlus)74 Image (io.github.mianalysis.mia.object.Image)44 Objs (io.github.mianalysis.mia.object.Objs)22 Color (java.awt.Color)14 Obj (io.github.mianalysis.mia.object.Obj)13 ImageStack (ij.ImageStack)8 Roi (ij.gui.Roi)7 ImageProcessor (ij.process.ImageProcessor)7 Rectangle (java.awt.Rectangle)7 ArrayList (java.util.ArrayList)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Calibration (ij.measure.Calibration)5 IntegerOverflowException (io.github.sjcross.common.exceptions.IntegerOverflowException)5 ChannelSplitter (ij.plugin.ChannelSplitter)4 SpatCal (io.github.sjcross.common.object.volume.SpatCal)4 File (java.io.File)4 CompositeImage (ij.CompositeImage)3 Overlay (ij.gui.Overlay)3 LUT (ij.process.LUT)3