Skip to content

Commit

Permalink
The label image exporter sets a Glasbey LUT to its output.
Browse files Browse the repository at this point in the history
  • Loading branch information
tinevez committed May 7, 2024
1 parent 625a54a commit 0f63ef6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import fiji.plugin.trackmate.gui.displaysettings.DisplaySettings;
import fiji.plugin.trackmate.util.SpotUtil;
import fiji.plugin.trackmate.util.TMUtils;
import fiji.plugin.trackmate.visualization.GlasbeyLut;
import ij.ImagePlus;
import net.imagej.ImgPlus;
import net.imagej.axis.Axes;
Expand Down Expand Up @@ -354,8 +355,9 @@ public static final ImagePlus createLabelImagePlus(

final ImagePlus lblImp = ImageJFunctions.wrap( createLabelImg( model, dims, calibration, exportSpotsAsDots, exportTracksOnly, labelIdPainting, logger ), "LblImage" );
lblImp.setDimensions( 1, dimensions[ 2 ], dimensions[ 3 ] );
lblImp.setLut( GlasbeyLut.toLUT() );
lblImp.setDisplayRange( 0, 255 );
lblImp.setOpenAsHyperStack( true );
lblImp.resetDisplayRange();
return lblImp;
}

Expand Down
16 changes: 16 additions & 0 deletions src/main/java/fiji/plugin/trackmate/visualization/GlasbeyLut.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import java.awt.Color;

import ij.process.LUT;

public class GlasbeyLut
{

Expand Down Expand Up @@ -301,4 +303,18 @@ public static final Color next()
return colors[ index ];
}

public static LUT toLUT()
{
final byte[] r = new byte[ 256 ];
final byte[] g = new byte[ 256 ];
final byte[] b = new byte[ 256 ];
for ( int i = 1; i < 256; i++ )
{
final Color c = colors[ ( i - 1 + colors.length / 2 ) % colors.length ];
r[ i ] = ( byte ) ( ( 0xFF ) & c.getRed() );
g[ i ] = ( byte ) ( ( 0xFF ) & c.getGreen() );
b[ i ] = ( byte ) ( ( 0xFF ) & c.getBlue() );
}
return new LUT( r, g, b );
}
}

0 comments on commit 0f63ef6

Please sign in to comment.