Skip to content

Commit

Permalink
make InteractiveMorphologicalReconstruction3D.java works for RGB stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
dlegland committed Jul 25, 2017
1 parent 280ce68 commit 6223189
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import ij.plugin.PlugIn;
import ij.plugin.frame.RoiManager;
import ij.process.ByteProcessor;
import ij.process.ColorProcessor;
import ij.process.FloatProcessor;
import ij.process.ImageProcessor;
import ij.process.ShortProcessor;
Expand Down Expand Up @@ -219,11 +220,14 @@ public void run( String arg )
if( null == result )
return;

Images3D.optimizeDisplayRange( result );

if (result.getBitDepth() != 24)
{
Images3D.optimizeDisplayRange( result );
}

// Display the result image
result.show();
result.setSlice( image.getSlice() );
result.show();

long t1 = System.currentTimeMillis();
IJUtils.showElapsedTime( operation.toString(), t1 - t0, image );
Expand Down Expand Up @@ -262,6 +266,8 @@ ImagePlus process( ImagePlus mask, Roi roi )
maxValue = 255;
else if ( bitDepth == 16 )
maxValue = 65535;
else if ( bitDepth == 24 )
maxValue = 0xFFFFFF;
else
maxValue = Float.MAX_VALUE;

Expand All @@ -271,9 +277,11 @@ else if ( bitDepth == 16 )
for( int n=0; n<mask.getImageStackSize(); n++ )
{
if( bitDepth == 8 )
markerSlice[ n ] = new ByteProcessor( mask.getWidth(), mask.getHeight() );
markerSlice[ n ] = new ByteProcessor( mask.getWidth(), mask.getHeight() );
else if( bitDepth == 16 )
markerSlice[ n ] = new ShortProcessor( mask.getWidth(), mask.getHeight() );
else if( bitDepth == 24 )
markerSlice[ n ] = new ColorProcessor( mask.getWidth(), mask.getHeight() );
else
markerSlice[ n ] = new FloatProcessor( mask.getWidth(), mask.getHeight() );

Expand Down Expand Up @@ -339,20 +347,22 @@ else if ( null != RoiManager.getInstance() )
if( operation == Operation.BY_EROSION )
Images3D.invert(markerStack);

// Compute geodesic reconstruction
// Compute morphological reconstruction
ImageStack result =
operation.applyTo( markerStack, mask.getImageStack(),
connectivity.getValue() );

// Keep same color model
result.setColorModel( mask.getImageStack().getColorModel() );

// create resulting image
String newName = mask.getShortTitle() + "-geodRec";
String newName = mask.getShortTitle() + "-rec";
ImagePlus resultPlus = new ImagePlus( newName, result );
resultPlus.copyScale( mask );
resultPlus.show();

resultPlus.setSlice( mask.getSlice() );
resultPlus.show();

return resultPlus;
}
}

0 comments on commit 6223189

Please sign in to comment.