use of net.imagej.display.DatasetView in project imagej-omero by imagej.
the class DefaultOMEROService method toOMERO.
@Override
public Object toOMERO(final omero.client client, final Object value) throws omero.ServerError, IOException, ExecutionException, DSOutOfServiceException, DSAccessException, NumberFormatException, URISyntaxException {
if (value == null)
return null;
if (value instanceof Dataset) {
// upload image to OMERO, returning the resultant image ID
final Dataset d = (Dataset) value;
final long imageID = uploadImage(client, d);
// TODO: upload or update?
if (d.getProperties().get("rois") != null)
uploadROIs(createCredentials(client), (TreeNode<?>) d.getProperties().get("rois"), imageID);
// TODO: Modify tables to implement Named??
if (d.getProperties().get("tables") != null) {
@SuppressWarnings("unchecked") final List<Table<?, ?>> tables = (List<Table<?, ?>>) d.getProperties().get("tables");
final OMEROLocation cred = createCredentials(client);
for (final Table<?, ?> table : tables) uploadTable(cred, d.getName() + "-table", table, imageID);
}
return toOMERO(client, imageID);
}
if (convertService.supports(value, Dataset.class))
return toOMERO(client, convertService.convert(value, Dataset.class));
if (value instanceof DatasetView) {
final DatasetView datasetView = (DatasetView) value;
// TODO: Verify whether any view-specific metadata can be preserved.
return toOMERO(client, datasetView.getData());
}
if (value instanceof ImageDisplay) {
final ImageDisplay imageDisplay = (ImageDisplay) value;
// TODO: Support more aspects of image displays; e.g., multiple datasets.
return toOMERO(client, imageDisplayService.getActiveDataset(imageDisplay));
}
if (value instanceof Table)
return convertOMEROTable((Table<?, ?>) value);
if (value instanceof TableDisplay)
return toOMERO(client, ((TableDisplay) value).get(0));
if (convertService.supports(value, Table.class))
return toOMERO(client, convertService.convert(value, Table.class));
if (value instanceof TreeNode) {
return convertOMEROROI((TreeNode<?>) value, null);
}
if (value instanceof MaskPredicate) {
final Object o = toOMERO(client, new DefaultTreeNode<>(value, null));
return ((List<?>) o).get(0);
}
if (convertService.supports(value, TreeNode.class))
return toOMERO(client, convertService.convert(value, TreeNode.class));
if (convertService.supports(value, MaskPredicate.class))
return toOMERO(client, convertService.convert(value, MaskPredicate.class));
return toOMERO(value);
}
use of net.imagej.display.DatasetView in project imagej-ui-swing by imagej.
the class SwingImageDisplayPanel method redraw.
@Override
public void redraw() {
final DatasetView view = imageDisplayService.getActiveDatasetView(display);
// no active dataset
if (view == null || view.getProjector() == null)
return;
view.getProjector().map();
displayViewer.getCanvas().update();
}
use of net.imagej.display.DatasetView in project imagej-ui-swing by imagej.
the class SwingImageDisplayPanel method updateColorBar.
private void updateColorBar(final int c) {
final DatasetView view = imageDisplayService.getActiveDatasetView(display);
// no active dataset
if (view == null)
return;
List<ColorTable> colorTables = view.getColorTables();
if (c >= colorTables.size())
return;
final ColorTable lut = colorTables.get(c);
colorBar.setColorTable(lut);
colorBar.repaint();
}
use of net.imagej.display.DatasetView in project imagej-ui-swing by imagej.
the class JHotDrawImageCanvas method capture.
/**
* Captures the current view of data displayed in the canvas, including all
* JHotDraw embellishments.
*/
public Dataset capture() {
final ImageDisplay display = getDisplay();
if (display == null)
return null;
final DatasetView datasetView = imageDisplayService.getActiveDatasetView(display);
if (datasetView == null)
return null;
final ARGBScreenImage screenImage = datasetView.getScreenImage();
final Image pixels = screenImage.image();
final int w = pixels.getWidth(null);
final int h = pixels.getHeight(null);
// draw the backdrop image info
final BufferedImage outputImage = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
final Graphics2D outputGraphics = outputImage.createGraphics();
outputGraphics.drawImage(pixels, 0, 0, null);
// draw the overlay info
for (final FigureView view : figureViews) {
view.getFigure().draw(outputGraphics);
}
// create a dataset that has view data with overlay info on top
final Dataset dataset = datasetService.create(new long[] { w, h, 3 }, "Captured view", new AxisType[] { Axes.X, Axes.Y, Axes.CHANNEL }, 8, false, false);
dataset.setRGBMerged(true);
final RandomAccess<? extends RealType<?>> accessor = dataset.randomAccess();
for (int x = 0; x < w; x++) {
accessor.setPosition(x, 0);
for (int y = 0; y < h; y++) {
accessor.setPosition(y, 1);
final int rgb = outputImage.getRGB(x, y);
final int r = (rgb >> 16) & 0xff;
final int g = (rgb >> 8) & 0xff;
final int b = (rgb >> 0) & 0xff;
accessor.setPosition(0, 2);
accessor.get().setReal(r);
accessor.setPosition(1, 2);
accessor.get().setReal(g);
accessor.setPosition(2, 2);
accessor.get().setReal(b);
}
}
return dataset;
}
use of net.imagej.display.DatasetView in project imagej-plugins-commands by imagej.
the class ShowInfo method displayRangesString.
private String displayRangesString() {
int chAxis = disp.dimensionIndex(Axes.CHANNEL);
if (chAxis < 0)
return null;
long numChan = disp.dimension(chAxis);
final StringBuilder builder = new StringBuilder();
for (int c = 0; c < numChan; c++) {
final DatasetView datasetView = imageDisplayService.getActiveDatasetView(disp);
final double min = datasetView.getChannelMin(c);
final double max = datasetView.getChannelMax(c);
builder.append("Display range channel " + c + ": " + min + "-" + max + "\n");
}
return builder.toString();
}
Aggregations