Overlay numbers on image

@haesleinhuepf @imagejan @aklemm,
Do you know an easy way to overlay the numbers in a results table onto the objects in a label mask image? I know how to do it with an ImageJ Macro but I was wondering about something built in?

1 Like

Hi Tischi,

CLIJ2 has the pullLabelsToROIManager method built-in which allows to to visualize labels using the ROIManager:

// Clean up first
run("Close All");

// make a label image
run("Blobs (25K)");
setAutoThreshold("Default");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Analyze Particles...", "  show=[Count Masks]");
run("glasbey", "display=[Count Masks of blobs.gif] view=net.imagej.display.DefaultDatasetView@2402d878");

// show Labels on the label map using the ROIManager
run("CLIJ Macro Extensions", "cl_device=[GeForce RTX 2060 SUPER]");
Ext.CLIJ2_push("Count Masks of blobs.gif");
Ext.CLIJ2_pullLabelsToROIManager("Count Masks of blobs.gif");
roiManager("show all with labels");

image

Let me know if that helps :wink:

Cheers,
Robert

…not sure, I meant to overlay measurement results, like Area or Perimeter.

1 Like

Hi,

I had the same wish few years ago, and made a (quick and dirty) plugin for doing this… The plugins combines three columns in a table (two for the position, the last one for the value), and creates an overlay over an image.


Honestly, I do not like the rendering (especially the positionning), but sometimes it can help… I have resuscitated the code source, now available here:

If it can help…

3 Likes

I do not know of a built in way label overlay ROIs with Results table values but here is a relatively simple macro that labels an overlay with “Area” values. It requires the latest ImageJ daily build (1.52v9), which adds the Overlay.useNamesAsLabels() macro function.

  parameter = "Area";
  lut = "Cyan";
  setBatchMode(true);
  run("Blobs (25K)");
  setAutoThreshold("Default");
  run("Analyze Particles...", "clear include show=Overlay");
  resetThreshold;
  newImage("lut","8-bit",1,1,1);
  run(lut);
  getLut(reds, greens, blues);
  close;
  n = Overlay.size;
  values = Table.getColumn(parameter);
  Array.getStatistics(values, min, max, mean, stdDev);
  for (i=0; i<n; i++) {
      Overlay.activateSelection(i);
      value = getValue(parameter);
      Roi.setName(value);
      index = 255*(value-min)/(max-min);
      Roi.setFillColor(reds[index], greens[index], blues[index]);
  }
  Overlay.setLabelFontSize(9, "bold background")
  Overlay.useNamesAsLabels(true);
  setBatchMode(false);

blobs

4 Likes

Thanks @Wayne and @dlegland!

I am posting here an example macro for MorphoLibJ and a 3D image:

// 0. Have MorpholibJ installed
// 1. Have a 3D label mask image open!

// glasbey lut
run("glasbey_on_dark");

// perform measurements
run("Analyze Regions 3D", "volume surface_area mean_breadth sphericity euler_number centroid inertia_ellipsoid ellipsoid_elongations max._inscribed surface_area_method=[Crofton (13 dirs.)] euler_connectivity=C26");

// set font size
setFont("SansSerif", 4);

// paint text into table
for ( i = 0; i < Table.size; ++i )
{
	volume = Table.get( "Volume", i );
	x = Table.get( "Centroid.X", i );
	y = Table.get( "Centroid.Y", i );
	z = Table.get( "Centroid.Z", i );

	toUnscaled(x, y, z);

	Overlay.drawString( volume, x, y );
	Overlay.setPosition( z );	
}

Overlay.show();
2 Likes

Hem…

I just realized that the plugin I mentioned above was already included into MorphoLibJ (by me! seems Alzheimer already started for me…). It an be found under the name “Draw Table Values” (in the main menu of MorphoLibJ).
There are also additional options to adjust the position, as well as the formatting pattern. Font size can be adjusted by ImageJ options.

1 Like

Maybe you did not release it yet?

Just checked, it was released with version 1.4.1.
is this your version?

I have 1.4.0; maybe that’s the current one in Fiji?!

Hi,
I have just released a new version of MorphoLibJ (1.4.2).
It is also updated on the update server. Therefore updating Fiji should bring to you the new version, with the “Draw Table Values” plugin.
May thanks to @iarganda for the support!

2 Likes