Show labels in different color

Hi i am new to ImageJ and i am doing a porosity analysis.

In the “Analyze Particle” window you can check “Add to Manager”. And after analysis is done i have labels in all of my detected pores. But since my pores are black and my labels in black too i cannot see the labels anymore. Is there a way to make them visible?
And is there a way to search for a specific label in the image?

Thanks!

@Manuel_Fuelling

If I am understanding your issue correctly… I think all you have to do is go in your ROI Manager window to "More >>" > "Labels" and then there you can adjust the color.

And for searching for a label… you will have to Script something for this. Is that what you were aiming to do? You can check the Built-in Macro Functions list for appropriate function calls…

eta

You can set the color and size of labels in the Image>Overlay>Labels dialog. Here is a macro example:

  run("Blobs (25K)");
  setAutoThreshold("Default");
  run("Analyze Particles...", "size=200 show=Overlay exclude");
  resetThreshold();
  run("Labels...", "color=white font=14 show draw bold");
  run("In [+]");

1 Like

Thanks! that helped a lot.
Somehow the labels are gone, after closing the image and reopening. if i save it as tiff then only the overlay is saved. How can i save the labels?

The labels and overlay are saved with the image when you save in TIFF format and reopen in ImageJ. To export to other programs, flatten the image (Image>Overlay>Flatten) before saving.

1 Like

Hi Wayne,

Sorry to butt in but I’ve come across an issue when I try to export as you suggested here. I’ve added labels onto TIFF files using the Multi-point tool and now want to export the image with the labels on it. I find that the Flatten function only works if the label type is ‘dot’. Using circle or crosshair there’s no visible labels in the saved PNG image when I re-open it later. Am I missing something?

Thanks!

I am unable to reproduce this problem. I created medium sized point selections in each of the four supported types, added them to an overlay, flattened the image and saved it in PNG format, and found the labels were easily readable when the image was reopened (see screenshot).

Screenshot

Hi Wayne,

Thanks so much for looking into this. I have done a few tests again and it seems like the issue is not dependent on the type of point as I initially thought.

What I find is that when, after using the point or multi-point tool, I run Image>Overlay>Flatten and save as PNG the image is saved but doesn’t display the points (see on the left of the screenshot below). The issue appears to be circumvented by running Flatten twice on the image before saving as PNG (see on the right of the screenshot below).

I’d never used the points tool before, so I don’t know if this could be because I’m working with a multichannel TIFF? It’s not a huge issue anyway but I was mostly curious to figure out what the issue might be.

Thanks again,

Carlos

29

I can confirm that the behavior of the Flatten command is inconsistent when using multi-channel composite images and multi-point selections. The following macro illustrates the issue:

newImage("HyperStack", "8-bit composite-mode label", 200, 200, 3, 1, 1);
xPoints = newArray(50,50,50);
yPoints = newArray(35,50,65);
makeSelection("point", xPoints, yPoints)
getDimensions(_, _, channels, _, _);
print("Before: " + channels + " channel(s)");
print("Before: " + Overlay.size + " elements in overlay");
eval("script", "IJ.log(\"Current selection: \" + IJ.getImage().getRoi());");
print("*****");
run("Flatten");
rename("first flattened");
getDimensions(_, _, channels, _, _);
print("After first flatten: " + channels + " channel(s)");
print("After first flatten: " + Overlay.size + " elements in overlay");
eval("script", "IJ.log(\"Current selection: \" + IJ.getImage().getRoi());");
print("*****");
run("Flatten");
rename("second flattened");
getDimensions(_, _, channels, _, _);
print("After second flatten: " + channels + " channel(s)");
print("After second flatten: " + Overlay.size + " elements in overlay");
eval("script", "IJ.log(\"Current selection: \" + IJ.getImage().getRoi());");

which produces the output:

Before: 3 channel(s)
Before: 3 elements in overlay
Current selection: Roi[Points, count=3]
*****
After first flatten: 1 channel(s)
After first flatten: 0 elements in overlay
Current selection: Roi[Points, count=3]
*****
After second flatten: 1 channel(s)
After second flatten: 0 elements in overlay
Current selection: null
2 Likes

How do I add “use names as labels” to macro? I’ve tried use names labels use_names all with no joy.

thanks

Use the macro recorder to get the required command.

When running Image > Overlay > Labels… and checking the Use names as labels checkbox, this is what it records:

run("Labels...", "color=white font=12 show use");

Yes the macro record is a great tool and it was the first thing I tried. Sadly the recorder doesn’t capture any label settings.

What do you mean? Doesn’t it record the line I was posting? If it behaves differently, please post details about your ImageJ/Fiji version, so we can try to reproduce.

The use keyword in the macro command is what dictates the Use names as labels option.

I am using FIJI:

ver 2.0.0-rc-69/1.52i

build: 269a0ad53f

date: 2018-12-04

This is what macro records when I try to get the labels settings:

run(“Record…”);

roiManager(“Show None”);

roiManager(“Show All”);

makeRectangle(489, 229, 80, 42);

roiManager(“Add”);

selectWindow(“Recorder”);