16bit LUT for label masks

imagej

#21

Christian,

I think the approach of Pete is along the lines that I’ve proposed and he has delivered the relevant plugin code, so everything should be settled.

You can always show the label numbers but not by hovering, although this could be coded.

Regards

Herbie


#22

Hmmm… that would be nice. Is there a suitable method to get the label values while achieving a similar display for an 8-bit image? Do you mind losing the ‘original’ values when hovering the mouse?

The information is all still there, without any RGB conversion required. So I guess there should be a way that involves listening for mouse events and then querying the overlay… but I don’t know if that’s the best way to go.

I’m not sure what happens if you try using the label stack as the ‘main’ image, and adding two overlapping ROI overlays: one of the original image, and then another (translucent) ROI containing the BufferedImage with the 16-bit color model…


#23

…or actually just create an RGB BufferedImage for the overlay, which is the merge of the two. Something like this (untested!) code:

for (int s = 1; s < imp.getStack().getSize(); s++) {
  // Some things
  def img = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB)
  def g2d = img.createGraphics()
  g2d.drawImage(imp.getStack().getProcessor(s).getBufferedImage(), 0, 0, null)
  g2d.drawImage(imgLabels16, 0, 0, null)
  g2d.dispose()
  def roi = new ImageRoi(0, 0, img)
  roi.setPosition(s)
  // Other things
}

If the labelled stack is the ‘main’ image, then I guess that’s the pixel values that will be shown…


#24

…I have to digest you code a bit because I never used the java awt image model directly :slightly_smiling_face:

But in general, I think I just thought along the same lines as you, but in IJ terms:
Have the raw data and the label image as a composite image, with the colored label mask as an overlay on top.

I just tested it and that actually works. And with the Channels tool in ImageJ one can very conveniently toggle off the label image, while still seeing the values when hovering.


#25

Ah yes, that’s a nice way to do it, at least for 8-bit. And the AWT stuff remains something of a last resort for me…

My workaround is to create a macro Toggle_overlay.ijm

if (Overlay.hidden) {
	Overlay.show;
} else {
	Overlay.hide;
}

and assign it to the shortcut key 0 (almost an o…). Since doing that, I like overlays a lot better…