jay
jay

Reputation: 31

ImageJ- how to get the slicename from the actually processed image in an imagestack

i have a problem getting the filename from an image stack in ImageJ. I wrote a plugin that can be used on image stacks and gives an output result for every image in the stack with:

if (mfpc == true) {
            IJ.log(fileName+": Good");
        } else {
            IJ.log(fileName+": Bad");
        }

getTitle() works for single images, but only shows the Stack-Name for stacks, not the name of the actual slice.

i also tried to get the slice name with the following code

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

but it only shows the currently chosen picture, not the picture which is handled by the plugin. My wishful thinking is the following output (while the filename is Imagex.png):

Is that possible and if so, how? :)

Upvotes: 0

Views: 2032

Answers (2)

HYS
HYS

Reputation: 771

You can get the slice name by using the command getInfo("slice.label");

Upvotes: 0

Soltius
Soltius

Reputation: 2263

A dirty way to tackle the problem : run Stack to Images, stock all names in an array, close all images, open your stack again.

Here is a code snippet in the ImageJ macro language :

setBatchMode(true);

open("your_stack.tif")

n=nSlices;
titles=newArray(n);

run("Stack to Images");

// for every image (slice of the stack)
for(cpt=0;cpt<n;cpt++){
    titles[cpt]=getTitle(); //get its title
    close(); //then close it so focus goes to the next image
}

Array.print(titles);

Upvotes: 0

Related Questions