Skip to content, Skip to search



794 bytes added, 1 February
Segmentation pipeline prototype: update script
<source lang="java">
// @ImagePlus (label="Input image",description="Image to segment") imp// @Integer(label="Gradient radius",description="Radius of the morphological gradient",value=2) radius// @Integer(label="Tolerance",description="Local extrema dynamic",value=3) tolerance// @String(label="Connectivity",description="Local connectivity", choices={"6","26"}) strConn// @Boolean(label="Calculate dams",description="Flag to use dams in watershed",value=true) dams
// @OUTPUT ImagePlus resultImage
// ImageJ imports
import ij.IJ;
import inra.ijpb.morphology.Strel3D;
import inra.ijpb.watershed.Watershed;
import; // convert connectivity string to intconn = Integer.parseInt( strConn ); if( radius != 0 ){ // create structuring element (cube of radius 1'radius') strel = Strel3D.Shape.CUBE.fromRadius( 1 radius ); // apply morphological gradient to input image image = Morphology.gradient( imp.getImageStack(), strel ); }else image = imp.getImageStack();// find regional minima on gradient image with dynamic value of 30 'tolerance' and 6'conn'-connectivityregionalMinima = MinimaAndMaxima3D.extendedMinima( image, 30tolerance, 6 conn );
// impose minima on gradient image
imposedMinima = MinimaAndMaxima3D.imposeMinima( image, regionalMinima, 6 conn );
// label minima using connected components (32-bit output)
labeledMinima = BinaryImages.componentsLabeling( regionalMinima, 6conn, 32 );
// apply marker-based watershed using the labeled minima on the minima-imposed
// gradient image (the "true" last value indicates the use of dams in the output)resultStack = Watershed.computeWatershed( imposedMinima, labeledMinima, 6conn, true dams );
// create image with watershed result
resultImage = new ImagePlus( "watershed", resultStack );
// assign right calibration
resultImage.setCalibration( imp.getCalibration() );
// optimize display range
Images3D.optimizeDisplayRange( resultImage );
// set same slice as input
resultImage.setSlice( imp.getCurrentSlice() );
Emailconfirmed, incoming, administrator, uploaders