Search in sources :

Example 1 with EDM

use of ij.plugin.filter.EDM in project imagej1 by imagej.

the class RoiEnlarger method shrink.

private static Roi shrink(Roi roi, int n) {
    Rectangle bounds = roi.getBounds();
    int width = bounds.width + 2;
    int height = bounds.height + 2;
    ImageProcessor ip = new ByteProcessor(width, height);
    roi.setLocation(1, 1);
    ip.setColor(255);
    ip.fill(roi);
    roi.setLocation(bounds.x, bounds.y);
    boolean bb = Prefs.blackBackground;
    Prefs.blackBackground = true;
    new EDM().toEDM(ip);
    Prefs.blackBackground = bb;
    ip.setThreshold(n + 1, 255, ImageProcessor.NO_LUT_UPDATE);
    Roi roi2 = (new ThresholdToSelection()).convert(ip);
    if (roi2 == null)
        return roi;
    Rectangle bounds2 = roi2.getBounds();
    if (bounds2.width <= 0 && bounds2.height <= 0)
        return roi;
    roi2.setLocation(bounds.x + bounds2.x - 1, bounds.y + bounds2.y - 1);
    return roi2;
}
Also used : ThresholdToSelection(ij.plugin.filter.ThresholdToSelection) EDM(ij.plugin.filter.EDM)

Example 2 with EDM

use of ij.plugin.filter.EDM in project imagej1 by imagej.

the class RoiEnlarger method enlarge.

public static Roi enlarge(Roi roi, double pixels) {
    if (pixels == 0)
        return roi;
    int type = roi.getType();
    int n = (int) Math.round(pixels);
    if (type == Roi.RECTANGLE || type == Roi.OVAL)
        return enlargeRectOrOval(roi, n);
    if (n > 255)
        n = 255;
    if (n < 0)
        return shrink(roi, -n);
    Rectangle bounds = roi.getBounds();
    int width = bounds.width;
    int height = bounds.height;
    width += 2 * n + 2;
    height += 2 * n + 2;
    ImageProcessor ip = new ByteProcessor(width, height);
    ip.invert();
    roi.setLocation(n + 1, n + 1);
    ip.setColor(0);
    ip.fill(roi);
    roi.setLocation(bounds.x, bounds.y);
    boolean bb = Prefs.blackBackground;
    Prefs.blackBackground = true;
    new EDM().toEDM(ip);
    // new ImagePlus("ip", ip).show();
    Prefs.blackBackground = bb;
    ip.setThreshold(0, n, ImageProcessor.NO_LUT_UPDATE);
    Roi roi2 = (new ThresholdToSelection()).convert(ip);
    if (roi2 == null)
        return roi;
    roi2.setLocation(bounds.x - n, bounds.y - n);
    roi2.setStrokeColor(roi.getStrokeColor());
    if (roi.getStroke() != null)
        roi2.setStroke(roi.getStroke());
    return roi2;
}
Also used : ThresholdToSelection(ij.plugin.filter.ThresholdToSelection) EDM(ij.plugin.filter.EDM)

Example 3 with EDM

use of ij.plugin.filter.EDM in project GDSC-SMLM by aherbert.

the class JTransformsTest method createProcessor.

private static FloatProcessor createProcessor(int size, int x, int y, int width, int height, UniformRandomProvider rng) {
    final ByteProcessor bp = new ByteProcessor(size, size);
    bp.setColor(255);
    bp.fillOval(x, y, width, height);
    final EDM e = new EDM();
    final FloatProcessor fp = e.makeFloatEDM(bp, 0, true);
    if (rng != null) {
        final float[] d = (float[]) fp.getPixels();
        for (int i = 0; i < d.length; i++) {
            d[i] += rng.nextFloat() * 0.01;
        }
    }
    return fp;
}
Also used : ByteProcessor(ij.process.ByteProcessor) FloatProcessor(ij.process.FloatProcessor) EDM(ij.plugin.filter.EDM)

Example 4 with EDM

use of ij.plugin.filter.EDM in project GDSC-SMLM by aherbert.

the class FhtFilterTest method createProcessor.

private static FloatProcessor createProcessor(int size, int x, int y, int width, int height, UniformRandomProvider rng) {
    final ByteProcessor bp = new ByteProcessor(size, size);
    bp.setColor(255);
    bp.fillOval(x, y, width, height);
    final EDM e = new EDM();
    final FloatProcessor fp = e.makeFloatEDM(bp, 0, true);
    if (rng != null) {
        final float[] d = (float[]) fp.getPixels();
        for (int i = 0; i < d.length; i++) {
            d[i] += rng.nextFloat() * 0.01;
        }
    }
    return fp;
}
Also used : ByteProcessor(ij.process.ByteProcessor) FloatProcessor(ij.process.FloatProcessor) EDM(ij.plugin.filter.EDM)

Aggregations

EDM (ij.plugin.filter.EDM)4 ThresholdToSelection (ij.plugin.filter.ThresholdToSelection)2 ByteProcessor (ij.process.ByteProcessor)2 FloatProcessor (ij.process.FloatProcessor)2