20 from distutils.version
import StrictVersion
as VS
23 print(
"ITK 5.0.0 or newer is required.")
26 parser = argparse.ArgumentParser(
27 description=
"Segment blood vessels with multi-scale Hessian-based measure."
29 parser.add_argument(
"input_image")
30 parser.add_argument(
"output_image")
31 parser.add_argument(
"--sigma_minimum", type=float, default=1.0)
32 parser.add_argument(
"--sigma_maximum", type=float, default=10.0)
33 parser.add_argument(
"--number_of_sigma_steps", type=int, default=10)
34 args = parser.parse_args()
36 input_image = itk.imread(args.input_image, itk.F)
38 ImageType = type(input_image)
39 Dimension = input_image.GetImageDimension()
41 HessianImageType =
itk.Image[HessianPixelType, Dimension]
44 HessianImageType, ImageType
46 objectness_filter.SetBrightObject(
False)
47 objectness_filter.SetScaleObjectnessMeasure(
False)
48 objectness_filter.SetAlpha(0.5)
49 objectness_filter.SetBeta(1.0)
50 objectness_filter.SetGamma(5.0)
53 ImageType, HessianImageType, ImageType
55 multi_scale_filter.SetInput(input_image)
56 multi_scale_filter.SetHessianToMeasureFilter(objectness_filter)
57 multi_scale_filter.SetSigmaStepMethodToLogarithmic()
58 multi_scale_filter.SetSigmaMinimum(args.sigma_minimum)
59 multi_scale_filter.SetSigmaMaximum(args.sigma_maximum)
60 multi_scale_filter.SetNumberOfSigmaSteps(args.number_of_sigma_steps)
62 OutputPixelType = itk.UC
63 OutputImageType =
itk.Image[OutputPixelType, Dimension]
66 rescale_filter.SetInput(multi_scale_filter)
68 itk.imwrite(rescale_filter.GetOutput(), args.output_image)