Search in sources :

Example 16 with DatasetView

use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.

the class ShowLUT method run.

// -- public interface --
@Override
public void run() {
    DatasetView view = imgDispService.getActiveDatasetView(display);
    List<ColorTable> colorTables = view.getColorTables();
    int currChannel = display.getIntPosition(Axes.CHANNEL);
    ColorTable colorTable = colorTables.get(currChannel);
    Dataset ds = createDataset(colorTable);
    output = displayService.createDisplay(ds);
// TODO
// output.addButton("List", ShowLUTAsTable.class);
}
Also used : DatasetView(net.imagej.display.DatasetView) ColorTable(net.imglib2.display.ColorTable) Dataset(net.imagej.Dataset)

Example 17 with DatasetView

use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.

the class CopyToSystem method getARGBPixels.

private ARGBPlane getARGBPixels() {
    final DatasetView view = imageDisplayService.getActiveDatasetView(display);
    if (view == null)
        return null;
    final Overlay overlay = overlayService.getActiveOverlay(display);
    final int imageWidth = (int) display.dimension(0);
    final int imageHeight = (int) display.dimension(1);
    final int[] argbPixels = view.getScreenImage().getData();
    final int x, y, w, h;
    if (overlay == null) {
        // no active overlay
        x = 0;
        y = 0;
        w = imageWidth;
        h = imageHeight;
    } else {
        // an active overlay exists
        int ovrMinX = (int) overlay.realMin(0);
        int ovrMinY = (int) overlay.realMin(1);
        int ovrMaxX = (int) (overlay.realMax(0));
        int ovrMaxY = (int) (overlay.realMax(1));
        // overlay bounds can be outside image bounds
        x = Math.max(0, ovrMinX);
        y = Math.max(0, ovrMinY);
        w = Math.min(imageWidth, ovrMaxX) - x + 1;
        h = Math.min(imageHeight, ovrMaxY) - y + 1;
    }
    final ARGBPlane plane = new ARGBPlane(w, h);
    for (int u = 0; u < w; u++) {
        for (int v = 0; v < h; v++) {
            final int argbLoc = (y + v) * imageWidth + (x + u);
            final int argb = argbPixels[argbLoc];
            plane.setARGB(u, v, argb);
        }
    }
    return plane;
}
Also used : DatasetView(net.imagej.display.DatasetView) ARGBPlane(org.scijava.ui.ARGBPlane) Overlay(net.imagej.overlay.Overlay)

Example 18 with DatasetView

use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.

the class AddSpecifiedNoiseToDataValues method run.

// -- public interface --
@Override
public void run() {
    Dataset dataset = displayService.getActiveDataset(display);
    Overlay overlay = overlayService.getActiveOverlay(display);
    DatasetView view = displayService.getActiveDatasetView(display);
    Position planePos = (allPlanes) ? null : view.getPlanePosition();
    NoiseAdder<T> noiseAdder = new NoiseAdder<T>(dataset, overlay, planePos);
    noiseAdder.setStdDev(stdDev);
    noiseAdder.run();
}
Also used : DatasetView(net.imagej.display.DatasetView) Position(net.imagej.Position) Dataset(net.imagej.Dataset) Overlay(net.imagej.overlay.Overlay)

Example 19 with DatasetView

use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.

the class EquationDataValues method setRegion.

// -- private helpers --
private String setRegion(final ImageDisplay disp, boolean allPlanes) {
    dataset = imgDispService.getActiveDataset(disp);
    final Overlay overlay = overlayService.getActiveOverlay(disp);
    final DatasetView view = imgDispService.getActiveDatasetView(disp);
    // check dimensions of Dataset
    final int xIndex = dataset.dimensionIndex(Axes.X);
    final int yIndex = dataset.dimensionIndex(Axes.Y);
    if ((xIndex < 0) || (yIndex < 0))
        return "display does not have XY planes";
    // calc XY outline boundary
    final long x, y, w, h;
    if (overlay == null) {
        x = 0;
        y = 0;
        w = dataset.dimension(xIndex);
        h = dataset.dimension(yIndex);
    } else {
        x = (long) overlay.realMin(0);
        y = (long) overlay.realMin(1);
        w = Math.round(overlay.realMax(0) - x);
        h = Math.round(overlay.realMax(1) - y);
    }
    // calc origin and span values
    origin = new long[dataset.numDimensions()];
    span = new long[dataset.numDimensions()];
    Position pos = view.getPlanePosition();
    int p = 0;
    for (int i = 0; i < dataset.numDimensions(); i++) {
        if (i == xIndex) {
            origin[xIndex] = x;
            span[xIndex] = w;
        } else if (i == yIndex) {
            origin[yIndex] = y;
            span[yIndex] = h;
        } else if (allPlanes) {
            origin[i] = 0;
            span[i] = dataset.dimension(i);
        } else {
            origin[i] = pos.getLongPosition(p++);
            span[i] = 1;
        }
    }
    condition = null;
    if (overlay != null)
        condition = new UVInsideRoiCondition(overlay.getRegionOfInterest());
    return null;
}
Also used : DatasetView(net.imagej.display.DatasetView) Position(net.imagej.Position) UVInsideRoiCondition(net.imglib2.ops.condition.UVInsideRoiCondition) Overlay(net.imagej.overlay.Overlay)

Example 20 with DatasetView

use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.

the class MathCommand method initialize.

// -- private helpers --
private void initialize() {
    dataset = displayService.getActiveDataset(display);
    overlay = overlayService.getActiveOverlay(display);
    DatasetView view = displayService.getActiveDatasetView(display);
    planePos = view.getPlanePosition();
    InplaceUnaryTransform<?, ?> xform = getPreviewTransform(dataset, overlay);
    PointSet region = determineRegion(dataset, xform.getRegionOrigin(), xform.getRegionSpan());
    iter = region.iterator();
    ArrayImgFactory<DoubleType> factory = new ArrayImgFactory<DoubleType>();
    dataBackup = factory.create(new long[] { region.size() }, new DoubleType());
    backupAccess = dataBackup.randomAccess();
    dataAccess = dataset.getImgPlus().randomAccess();
    // check dimensions of Dataset
    final long w = xform.getRegionSpan()[0];
    final long h = xform.getRegionSpan()[1];
    if (w * h > Integer.MAX_VALUE)
        throw new IllegalArgumentException("preview region too large to copy into memory");
}
Also used : PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) DatasetView(net.imagej.display.DatasetView) DoubleType(net.imglib2.type.numeric.real.DoubleType) ArrayImgFactory(net.imglib2.img.array.ArrayImgFactory)

Aggregations

DatasetView (net.imagej.display.DatasetView)21 Dataset (net.imagej.Dataset)13 Overlay (net.imagej.overlay.Overlay)11 DoubleType (net.imglib2.type.numeric.real.DoubleType)8 Position (net.imagej.Position)4 ColorTable (net.imglib2.display.ColorTable)4 Point (java.awt.Point)2 ImageDisplay (net.imagej.display.ImageDisplay)2 Graphics2D (java.awt.Graphics2D)1 Image (java.awt.Image)1 BufferedImage (java.awt.image.BufferedImage)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DataView (net.imagej.display.DataView)1 OverlayView (net.imagej.display.OverlayView)1 OptionsCompatibility (net.imagej.options.OptionsCompatibility)1 OptionsMisc (net.imagej.options.OptionsMisc)1 DefaultResultsTable (net.imagej.table.DefaultResultsTable)1 ARGBScreenImage (net.imglib2.display.screenimage.awt.ARGBScreenImage)1 ArrayImgFactory (net.imglib2.img.array.ArrayImgFactory)1