-
Notifications
You must be signed in to change notification settings - Fork 113
/
LoadAndDisplayDataset.java
36 lines (27 loc) · 1.01 KB
/
LoadAndDisplayDataset.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* To the extent possible under law, the ImageJ developers have waived
* all copyright and related or neighboring rights to this tutorial code.
*
* See the CC0 1.0 Universal license for details:
* http://creativecommons.org/publicdomain/zero/1.0/
*/
import imagej.ImageJ;
import imagej.data.Dataset;
import java.io.File;
import javax.swing.JFileChooser;
/** Loads and displays a dataset using the ImageJ API. */
public class LoadAndDisplayDataset {
public static void main(final String... args) throws Exception {
// create the ImageJ application context with all available services
final ImageJ ij = new ImageJ();
// ask the user for a file to open
final JFileChooser chooser = new JFileChooser();
final int returnVal = chooser.showOpenDialog(null);
if (returnVal != JFileChooser.APPROVE_OPTION) return;
final File file = chooser.getSelectedFile();
// load the dataset
final Dataset dataset = ij.io().loadDataset(file.getAbsolutePath());
// display the dataset
ij.ui().show(dataset);
}
}