Search in sources :

Example 36 with ByteProcessor

use of ij.process.ByteProcessor in project GDSC-SMLM by aherbert.

the class BinaryDisplay method setup.

@Override
public int setup(String arg, ImagePlus imp) {
    SmlmUsageTracker.recordPlugin(this.getClass(), arg);
    if (imp == null) {
        return DONE;
    }
    if ("reset".equals(arg)) {
        final ImageProcessor ip = imp.getProcessor();
        ip.reset();
        if (ip instanceof ByteProcessor) {
            // Reset to the entire range
            ip.resetMinAndMax();
        } else {
            // Short and FloatProcessor store the min and max in the snapshot
            // so restore it from the reset values.
            ip.setMinAndMax(ip.getMin(), ip.getMax());
        }
        imp.updateAndDraw();
        return DONE;
    }
    this.imp = imp;
    return DOES_8G | DOES_16 | DOES_32;
}
Also used : ByteProcessor(ij.process.ByteProcessor) ImageProcessor(ij.process.ImageProcessor)

Example 37 with ByteProcessor

use of ij.process.ByteProcessor in project mcib3d-core by mcib3d.

the class ArrayUtil method drawBar.

/**
 * drawing of the array as an image
 *
 * @param scale scale value
 */
public ImagePlus drawBar(int scale) {
    int haut = 256;
    double val;
    double max = getMaximum();
    ByteProcessor ip = new ByteProcessor(size, haut);
    ip.setColor(255);
    for (int i = 0; i < size; i++) {
        ip.moveTo(i, haut - 1);
        if (scale == -1) {
            val = (haut * values[i] / max);
        } else if (values[i] > scale) {
            val = haut - 1;
        } else {
            val = (haut * values[i] / scale);
        }
        ip.lineTo(i, (int) (haut - val));
    }
    return new ImagePlus("tab", ip);
}
Also used : ByteProcessor(ij.process.ByteProcessor) ImagePlus(ij.ImagePlus)

Example 38 with ByteProcessor

use of ij.process.ByteProcessor in project mcib3d-core by mcib3d.

the class ImageByte method resize.

/*
     * public static ImageByte merge3DBinary(ImageByte[] images, int sizeX, int
     * sizeY, int sizeZ) { ImageByte out = new ImageByte("merge", sizeX, sizeY,
     * sizeZ); if (images==null || images.length==0 || images[0]==null) return
     * out; // si offset negatif, les pixels doivent etre = 0 sinon erreur for
     * (int idx = 0; idx < images.length; idx++) { byte label = (byte)(idx+1);
     * for (int z = 0; z<images[idx].sizeZ; z++) { for (int y = 0;
     * y<images[idx].sizeY; y++) { for (int x = 0; x<images[idx].sizeX; x++) {
     * if (images[idx].pixels[z][x+y*images[idx].sizeX]!=0) {
     * out.pixels[z+images[idx].offsetZ][x+images[idx].offsetX+
     * (y+images[idx].offsetY)*sizeX]=label; } } } } } return out; }
     *
     */
@Override
public ImageHandler resize(int dX, int dY, int dZ) {
    int newX = Math.max(1, sizeX + 2 * dX);
    int newY = Math.max(1, sizeY + 2 * dY);
    boolean bck = Prefs.get("resizer.zero", true);
    Prefs.set("resizer.zero", true);
    ij.plugin.CanvasResizer cr = new ij.plugin.CanvasResizer();
    ImageStack res = cr.expandStack(img.getStack(), newX, newY, dX, dY);
    if (!bck) {
    // Prefs.set("resizer.zero", false);
    }
    if (dZ > 0) {
        for (int i = 0; i < dZ; i++) {
            res.addSlice("", new ByteProcessor(newX, newY), 0);
            res.addSlice("", new ByteProcessor(newX, newY));
        }
    } else {
        for (int i = 0; i < -dZ; i++) {
            if (res.getSize() <= 2) {
                break;
            }
            res.deleteLastSlice();
            res.deleteSlice(1);
        }
    }
    ImageByte r = new ImageByte(new ImagePlus(title + "::resized", res));
    r.offsetX = offsetX - dX;
    r.offsetY = offsetY - dY;
    r.offsetZ = offsetZ - dZ;
    return r;
}
Also used : ByteProcessor(ij.process.ByteProcessor) ImageStack(ij.ImageStack) ImagePlus(ij.ImagePlus)

Example 39 with ByteProcessor

use of ij.process.ByteProcessor in project mcib3d-core by mcib3d.

the class Object3DLabel method createRoi.

/**
 * Constructor for the createRoi object
 *
 * @param z Description of the Parameter
 * @return Description of the Return Value
 */
@Deprecated
public Roi createRoi(int z) {
    // IJ.write("create roi " + z);
    int sx = labelImage.sizeX;
    int sy = labelImage.sizeY;
    ByteProcessor mask = new ByteProcessor(sx, sy);
    // object black on white
    // mask.invert();
    draw(mask, z, 255);
    ImagePlus maskPlus = new ImagePlus("mask " + z, mask);
    // maskPlus.show();
    // IJ.run("Create Selection");
    ThresholdToSelection tts = new ThresholdToSelection();
    tts.setup("", maskPlus);
    tts.run(mask);
    maskPlus.updateAndDraw();
    return maskPlus.getRoi();
}
Also used : ByteProcessor(ij.process.ByteProcessor) ThresholdToSelection(ij.plugin.filter.ThresholdToSelection) ImagePlus(ij.ImagePlus)

Example 40 with ByteProcessor

use of ij.process.ByteProcessor in project mcib3d-core by mcib3d.

the class Object3DFuzzy method createRoi.

@Override
public Roi createRoi(int z) {
    // IJ.write("create roi " + z);
    int sx = this.getXmax() - this.getXmin() + 1;
    int sy = this.getYmax() - this.getYmin() + 1;
    ByteProcessor mask = new ByteProcessor(sx, sy);
    // object black on white
    // mask.invert();
    draw(mask, z, 255);
    ImagePlus maskPlus = new ImagePlus("mask " + z, mask);
    // maskPlus.show();
    // IJ.run("Create Selection");
    ThresholdToSelection tts = new ThresholdToSelection();
    tts.setup("", maskPlus);
    tts.run(mask);
    maskPlus.updateAndDraw();
    // IJ.write("sel=" + maskPlus.getRoi());
    // maskPlus.hide();
    Roi roi = maskPlus.getRoi();
    Rectangle rect = roi.getBounds();
    rect.x += this.getXmin();
    rect.y += this.getYmin();
    return roi;
}
Also used : ByteProcessor(ij.process.ByteProcessor) Rectangle(java.awt.Rectangle) ThresholdToSelection(ij.plugin.filter.ThresholdToSelection) ImagePlus(ij.ImagePlus) Roi(ij.gui.Roi)

Aggregations

ByteProcessor (ij.process.ByteProcessor)86 ImagePlus (ij.ImagePlus)30 ImageProcessor (ij.process.ImageProcessor)23 FloatProcessor (ij.process.FloatProcessor)21 ShortProcessor (ij.process.ShortProcessor)19 ColorProcessor (ij.process.ColorProcessor)14 ArrayList (java.util.ArrayList)13 Point (java.awt.Point)12 Rectangle (java.awt.Rectangle)11 Roi (ij.gui.Roi)10 AffineTransform (java.awt.geom.AffineTransform)10 ImageStack (ij.ImageStack)9 Patch (ini.trakem2.display.Patch)9 Calibration (ij.measure.Calibration)8 Pair (mpicbg.trakem2.util.Pair)7 Color (java.awt.Color)6 LUT (ij.process.LUT)5 BufferedImage (java.awt.image.BufferedImage)5 IOException (java.io.IOException)5 CoordinateTransformMesh (mpicbg.models.CoordinateTransformMesh)5