Search code examples
imagej

imagej get current image from imagestack


i need to get the current image opened after importing an image sequence to ImageJ. As i need to save the overlay information to a text file bearing the name of the image

int number = imp.getImageStackSize();
if(number > 1)
{
  ImagePlus check = imp.duplicate();
  gd.removeAll();
  gd.addMessage(check.getTitle());
  gd.showDialog();          
}

imp.gettitle returns the folder name the images were loaded from.

couldn't find any solution so far :(

Any way to find the text in the status bar would be appreciated..


Solution

  • it was a simple issue.. the name of the current image can be retrieved by the following piece of code..

    fileName = imp.getImageStack().getShortSliceLabel(imp.getCurrentSlice());
    

    Thanks everyone..