本文整理汇总了Java中net.imagej.ImageJ类的典型用法代码示例。如果您正苦于以下问题:Java ImageJ类的具体用法?Java ImageJ怎么用?Java ImageJ使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ImageJ类属于net.imagej包,在下文中一共展示了ImageJ类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testNullImageCancelsPlugin
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void testNullImageCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", null).get();
// VERIFY
assertTrue("Null image should have canceled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NO_IMAGE_OPEN,
module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例2: test2DImageCancelsPlugin
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void test2DImageCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
// Create an image with only two spatial dimensions
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL);
final Img<DoubleType> img = ArrayImgs.doubles(10, 10, 3);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, cAxis);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", imgPlus).get();
// VERIFY
assertTrue("2D image should have cancelled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NOT_3D_IMAGE,
module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例3: test2DImagePlusCancelsPlugin
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void test2DImagePlusCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
final ImagePlus image = mock(ImagePlus.class);
when(image.getNSlices()).thenReturn(1);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", image).get();
// VERIFY
assertTrue("2D image should have cancelled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NOT_3D_IMAGE,
module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例4: RoiEditor
import net.imagej.ImageJ; //导入依赖的package包/类
public RoiEditor(SlideSet slideSet, DataTypeIDService dtid,
ImageJ ij, SlideSetLog log) {
if(slideSet == null || dtid == null || ij == null || log == null)
throw new IllegalArgumentException("Can't initiate with null elements");
this.slideSet = slideSet;
this.dtid = dtid;
this.ij = ij;
this.log = log;
os = ij.get(OverlayService.class);
ui = ij.ui().getUI(SwingUI.NAME);
roiSetNames = new ArrayList<String>();
roiSets = new ArrayList<AbstractOverlay[][]>();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
buildLayout();
setActionListeners();
}
示例5: SlideSetLauncher
import net.imagej.ImageJ; //导入依赖的package包/类
@SuppressWarnings(value="LeakingThisInConstructor")
public SlideSetLauncher(ImageJ context, DataTypeIDService dtid,
XMLService xmls, CSVService csvs, SlideSetLog log) {
if(context == null || dtid == null || xmls == null || csvs == null)
throw new IllegalArgumentException("Can't initialize with null elements");
helpLoader = new HttpHelpLoader(context);
try {
ver = (
new BufferedReader(new InputStreamReader(
getClass().getClassLoader().getResourceAsStream("edu/emory/cellbio/ijbat/version.info")))
).readLine();
} catch(Exception e) { e.printStackTrace(System.err); ver = "ERR"; }
context.log().setLevel(org.scijava.log.LogService.ERROR); // Prevents Fiji log window from poping up all the time. Not a durable fix!
this.ij = context;
this.dtid = dtid;
this.xmls = xmls;
this.csvs = csvs;
this.sspl = new SlideSetPluginLoader(context, dtid, log, helpLoader);
this.log = log;
this.log.registerListener(this);
buildLayout();
}
示例6: PluginInputMatcherFrame
import net.imagej.ImageJ; //导入依赖的package包/类
public PluginInputMatcherFrame(SlideSet data, ImageJ context, DataTypeIDService dtid) {
this.data = data;
ij = context;
this.dtid = dtid;
setTitle("Select values for input fields");
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
lman = new BoxLayout(getContentPane(), BoxLayout.Y_AXIS);
getContentPane().setLayout(lman);
// Set window listener
addWindowListener( new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
kill();
}
});
}
示例7: main
import net.imagej.ImageJ; //导入依赖的package包/类
public static <T extends RealType<T>> void main(final String... args) throws Exception {
// Launch ImageJ as usual.
final ImageJ ij = new ImageJ();
ij.ui().showUI();//launch(args);
// Launch the command .
IJ.openImage("F:\\projects\\2DEmbryoSection_Mette.tif").show();
//Dataset dataset = (Dataset) ij.io().open("F:\\projects\\2DEmbryoSection_Mette.tif");
//Dataset dataset2 = (Dataset) ij.io().open("F:\\projects\\2D_8peaks.tif");
//ij.ui().show(dataset);
ij.command().run(HWatershed_Plugin.class, true);
}
示例8: main
import net.imagej.ImageJ; //导入依赖的package包/类
public static void main(final String[] args) throws IOException {
// Launch ImageJ.
final ImageJ ij = new ImageJ();
ij.launch(args);
// Load an image.
final File file = ij.ui().chooseFile(null, FileWidget.OPEN_STYLE);
if (file == null) return;
final Object data = ij.io().open(file.getAbsolutePath());
ij.ui().show(data);
// Run the command.
ij.command().run(MicroscopeImageFocusQualityClassifier.class, true);
}
示例9: main
import net.imagej.ImageJ; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
final ImageJ ij = new ImageJ();
ij.launch(args);
// Open an image and display it.
final String imagePath = "http://samples.fiji.sc/new-lenna.jpg";
final Object dataset = ij.io().open(imagePath);
ij.ui().show(dataset);
// Launch the "Label Images" command with some sensible defaults.
ij.command().run(LabelImage.class, true, //
"inputImage", dataset);
}
示例10: testNonBinaryImageCancelsPlugin
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void testNonBinaryImageCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
// Create a test image with more than two colors
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis zAxis = new DefaultLinearAxis(Axes.Z);
final Img<DoubleType> img = ArrayImgs.doubles(5, 5, 5);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, zAxis);
final Iterator<Integer> intIterator = IntStream.iterate(0, i -> i + 1)
.iterator();
imgPlus.cursor().forEachRemaining(e -> e.setReal(intIterator.next()));
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", imgPlus).get();
// VERIFY
assertTrue(
"An image with more than two colours should have cancelled the plugin",
module.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NOT_BINARY, module
.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例11: testNoCalibrationShowsWarning
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void testNoCalibrationShowsWarning(
final ImageJ imageJ, final Class<C> commandClass,
Object... additionalInputs) throws Exception
{
// SETUP
// Mock UI
final UserInterface mockUI = mock(UserInterface.class);
final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
when(mockUI.dialogPrompt(eq(BAD_CALIBRATION), anyString(), eq(
WARNING_MESSAGE), any())).thenReturn(mockPrompt);
imageJ.ui().setDefaultUI(mockUI);
// Create an hyperstack with no calibration
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis zAxis = new DefaultLinearAxis(Axes.Z);
final DefaultLinearAxis tAxis = new DefaultLinearAxis(Axes.TIME);
final Img<DoubleType> img = ArrayImgs.doubles(5, 5, 5, 2);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, zAxis, tAxis);
final List<Object> inputs = new ArrayList<>();
inputs.add("inputImage");
inputs.add(imgPlus);
Collections.addAll(inputs, additionalInputs);
// EXECUTE
imageJ.command().run(commandClass, true, inputs.toArray()).get();
// VERIFY
verify(mockUI, timeout(1000).times(1)).dialogPrompt(eq(BAD_CALIBRATION),
anyString(), eq(WARNING_MESSAGE), any());
}
示例12: testNonBinaryImagePlusCancelsPlugin
import net.imagej.ImageJ; //导入依赖的package包/类
public static <C extends Command> void testNonBinaryImagePlusCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
final ImagePlus nonBinaryImage = mock(ImagePlus.class);
final ImageStatistics stats = new ImageStatistics();
stats.pixelCount = 3;
stats.histogram = new int[256];
stats.histogram[0x00] = 1;
stats.histogram[0x01] = 1;
stats.histogram[0xFF] = 1;
when(nonBinaryImage.getStatistics()).thenReturn(stats);
when(nonBinaryImage.getNSlices()).thenReturn(2);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", nonBinaryImage).get();
// VERIFY
assertTrue(
"An image with more than two colours should have cancelled the plugin",
module.isCanceled());
assertEquals("Cancel reason is incorrect",
CommonMessages.NOT_8_BIT_BINARY_IMAGE, module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例13: mockUIService
import net.imagej.ImageJ; //导入依赖的package包/类
public static UserInterface mockUIService(final ImageJ imageJ) {
final UserInterface mockUI = mock(UserInterface.class);
final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
when(mockUI.dialogPrompt(any(), anyString(), any(), any())).thenReturn(
mockPrompt);
imageJ.ui().setDefaultUI(mockUI);
return mockUI;
}
示例14: testAnisotropyWarning
import net.imagej.ImageJ; //导入依赖的package包/类
/**
* Tests that running the given command with an anisotropic {@link ImagePlus}
* shows a warning dialog that can be used to cancel the plugin
*/
public static <C extends Command> void testAnisotropyWarning(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mock(UserInterface.class);
final SwingDialogPrompt mockPrompt = mock(SwingDialogPrompt.class);
when(mockPrompt.prompt()).thenReturn(DialogPrompt.Result.CANCEL_OPTION);
when(mockUI.dialogPrompt(startsWith("The image is anisotropic"),
anyString(), eq(WARNING_MESSAGE), any())).thenReturn(mockPrompt);
imageJ.ui().setDefaultUI(mockUI);
final Calibration calibration = new Calibration();
calibration.pixelWidth = 300;
calibration.pixelHeight = 1;
calibration.pixelDepth = 1;
final ImagePlus imagePlus = NewImage.createByteImage("", 5, 5, 5, 1);
imagePlus.setCalibration(calibration);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", imagePlus).get();
// VERIFY
verify(mockUI, timeout(1000).times(1)).dialogPrompt(startsWith(
"The image is anisotropic"), anyString(), eq(WARNING_MESSAGE), any());
assertTrue("Pressing cancel on warning dialog should have cancelled plugin",
module.isCanceled());
}
示例15: main
import net.imagej.ImageJ; //导入依赖的package包/类
public static void main(String... args) {
// SETUP
final ImageJ imageJ = new ImageJ();
final Random random = new Random();
final int width = 100;
final int height = 100;
final int depth = 100;
final int rotations = 100;
final int bins = 100;
final Img<FloatType> img = ArrayImgs.floats(width, height, depth);
@SuppressWarnings("unchecked")
final BinaryFunctionOp<ValuePair<Point3d, Vector3d>, Interval, Optional<ValuePair<DoubleType, DoubleType>>> intersectOp =
(BinaryFunctionOp) Functions.binary(imageJ.op(), BoxIntersect.class,
Optional.class, ValuePair.class, img);
final BinaryHybridCFI1<Tuple3d, AxisAngle4d, Tuple3d> rotateOp = Hybrids
.binaryCFI1(imageJ.op(), RotateAboutAxis.class, Tuple3d.class,
new Vector3d(), new AxisAngle4d());
// EXECUTE
for (int i = 0; i < rotations; i++) {
final AxisAngle4d rotation = RotateAboutAxis.randomAxisAngle();
final LineGrid grid = createGrid(img, rotateOp, rotation, random);
final Stream<Section> sections = createSections(img, grid, bins,
intersectOp);
sections.forEach(s -> sample(img, s, 1.0, random));
}
// DISPLAY RESULT
final ImgPlus<FloatType> image = new ImgPlus<>(img, "Sampling count",
new DefaultLinearAxis(Axes.X), new DefaultLinearAxis(Axes.Y),
new DefaultLinearAxis(Axes.Z));
imageJ.launch(args);
imageJ.ui().show(image);
}