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);
}
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;
}
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();
}
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;
}
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");
}
Aggregations