You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ConvertService can be used to convert a Dataset to an ImagePlus, which is handy for use with IJ1. However, the internal linkage between these types is actually between ImageDisplay and ImagePlus; when the dataset is registered, an ImageDisplay is implicitly created using DisplayService.createDisplay, which publishes DisplayCreatedEvent, adding the ImageDisplay to the object index, which causes it to be later shown when UIService.showUI() is called.
The proper fix is unclear without further investigation. Perhaps the LegacyImageMap could call createDisplayQuietly instead of createDisplay, although that might cause other problems. When the ImageJ2 data model is reworked, this issue might become moot.
Here is an example (from @rimadoma) reproducing the issue:
packageprotoOps.datasetExample;
importij.ImagePlus;
importnet.imagej.Dataset;
importnet.imagej.ImageJ;
importnet.imagej.axis.Axes;
importnet.imagej.axis.AxisType;
importnet.imagej.ops.Op;
importnet.imagej.ops.OpEnvironment;
importnet.imglib2.type.numeric.integer.UnsignedByteType;
importorg.scijava.convert.ConvertService;
importorg.scijava.plugin.Parameter;
importorg.scijava.plugin.Plugin;
importjava.util.stream.IntStream;
/** * A (M)inimal, (C)omplete, and (V)erifiable (E)xample of an issue I've encountered with ConvertService. * * A call to ConvertService.convert(dataset, ImagePlus.class) causes an image window to pop up, * when the ImageJ UI is opened (line 77). * * The image turns red if you move the slider from slide 1. */@Plugin(type = Op.class, name = "datasetWrapping")
publicclassMVCEDatasetWrappingextendsAbstractOp {
privateImagePlusimagePlus;
@ParameterprivateConvertServiceconvertService;
@ParameterprivateDatasetdataset;
@Overridepublicvoidrun() {
convertDataset();
}
publicstaticvoidmain(finalString... args) throwsException {
intwidth = 320, height = 200, depth = 10;
finalImageJij = newImageJ();
finalDatasetinputDataset = createMonochromeDataset(ij ,width, height, depth, 0xFF);
ij.op().run("datasetWrapping", inputDataset);
ij.ui().showUI();
}
privatestaticDatasetcreateMonochromeDataset(finalImageJijInstance, finalintwidth, finalintheight,
finalintdepth, finalintcolor) {
finallong[] dims = {width, height, depth};
finalAxisType[] axisTypes = {Axes.X, Axes.Y, Axes.Z};
Datasetdataset = ijInstance.dataset().create(newUnsignedByteType(), dims, "Test image", axisTypes);
IntStream.range(0, depth).forEach(i -> {
finalbyte[] data = newbyte[width * height];
IntStream.range(0, data.length).forEach(j -> data[j] = (byte)color);
dataset.setPlane(i, data);
});
returndataset;
}
privatevoidconvertDataset() {
imagePlus = convertService.convert(dataset, ImagePlus.class);
}
}
The text was updated successfully, but these errors were encountered:
ctrueden
changed the title
Converting a Dataset to ImagePlus implicitly creates an ImageDisplay
Converting a Dataset to ImagePlus implicitly creates an ImageDisplay, then shows it
Feb 26, 2016
ctrueden
changed the title
Converting a Dataset to ImagePlus implicitly creates an ImageDisplay, then shows it
Converting a Dataset to ImagePlus implicitly shows it
Feb 26, 2016
ctrueden
added a commit
to ctrueden/sandbox
that referenced
this issue
Aug 23, 2016
The
ConvertService
can be used to convert aDataset
to anImagePlus
, which is handy for use with IJ1. However, the internal linkage between these types is actually betweenImageDisplay
andImagePlus
; when the dataset is registered, anImageDisplay
is implicitly created usingDisplayService.createDisplay
, which publishesDisplayCreatedEvent
, adding theImageDisplay
to the object index, which causes it to be later shown whenUIService.showUI()
is called.The proper fix is unclear without further investigation. Perhaps the
LegacyImageMap
could callcreateDisplayQuietly
instead ofcreateDisplay
, although that might cause other problems. When the ImageJ2 data model is reworked, this issue might become moot.Here is an example (from @rimadoma) reproducing the issue:
The text was updated successfully, but these errors were encountered: