Skip to content

Instantly share code, notes, and snippets.

@frauzufall
Last active June 26, 2019 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frauzufall/d053de527d17be78e31dcc1b8fb27c7d to your computer and use it in GitHub Desktop.
Save frauzufall/d053de527d17be78e31dcc1b8fb27c7d to your computer and use it in GitHub Desktop.
Get all open images in ImageJ
// creating images
Object img1 = ij.io().open("https://samples.fiji.sc/blobs.png");
Object img2 = ij.io().open("https://samples.fiji.sc/new-lenna.jpg");
// showing images
ij.ui().show(img1);
ij.ui().show(img2);
// get images
List<Dataset> datasets = ij.dataset().getDatasets();
System.out.println(datasets);
String name1 = datasets.get(0).getName();
String name2 = datasets.get(1).getName();
// rename displays [DOES NOT TRIGGER ACTION IJ UI]
ij.display().getDisplay(name1).setName("X");
ij.display().getDisplay(name2).setName("Y");
// move img1 into focus [DOES NOT TRIGGER ACTION IJ UI]
Display<?> display1 = ij.display().getDisplay(name1);
ij.display().setActiveDisplay(display1);
@NasserDarwish
Copy link

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment