/usr/src/WrapITK/Python/Tests/WatershedSegmentation1.py is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | import itk
import sys
itk.auto_progress(2)
reader = itk.ImageFileReader.IF2.New()
reader.SetFileName( sys.argv[1] )
diffusion = itk.GradientAnisotropicDiffusionImageFilter.IF2IF2.New()
diffusion.SetInput(reader.GetOutput())
diffusion.SetTimeStep(0.0625)
diffusion.SetConductanceParameter(9.0)
diffusion.SetNumberOfIterations( 5 );
gradient = itk.GradientMagnitudeImageFilter.IF2IF2.New()
gradient.SetInput(diffusion.GetOutput())
watershed = itk.WatershedImageFilter.IF2.New()
watershed.SetInput(gradient.GetOutput())
watershed.SetThreshold(0.01)
watershed.SetLevel(0.2)
relabel = itk.RelabelComponentImageFilter.IUL2IUS2.New()
relabel.SetInput( watershed.GetOutput() )
cast = itk.CastImageFilter.IUS2IUC2.New()
cast.SetInput( relabel.GetOutput() )
writer = itk.ImageFileWriter.IUC2.New()
writer.SetFileName( sys.argv[2] )
writer.SetInput( cast.GetOutput() )
writer.Update()
|