/usr/src/WrapITK/Python/Tests/module2module.py is in libinsighttoolkit3-dev 3.20.1-1.
This file is owned by root:root, with mode 0o755.
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | #!/usr/bin/env python
# def custom_callback(name):
# print "loading %s submodule..." % name
# import itkConfig
# itkConfig.ImportCallback = custom_callback
import itk, sys
import Base
import BaseNumerics
import BaseSpatialObject
import BaseTransforms
import BinaryMorphology
import Calculators
import Compose
import DeformableTransforms
import Denoising
import DistanceMap
import EdgesAndContours
import FFT
import Filtering
import IntensityFilters
import Interpolators
import IO
# import Iterators
import LevelSet
import Morphology
# import Patented
import PixelMath
import Registration
import Resize
import SegmentationAndThreshold
import SegmentationValidation
import SimpleFilters
import UnaryPixelMath
import VXLNumerics
PType = itk.US
dim = 2
IType = itk.Image[PType, dim]
kernel = itk.strel(2, 1)
# create the reader
reader = itk.ImageFileReader[IType].New(FileName=sys.argv[1])
sources = []
image = Base.Image[PType, dim].New()
r = itk.ImageRegion._2()
r.SetSize((10, 10))
image.SetRegions(r)
image.Allocate()
# BaseNumerics
# BaseSpatialObject
# BaseTransforms
# Compose
# DeformableTransforms
# FFT
# Interpolators
# Iterators
# LevelSet
# Patented
# PixelMath
# Registration
# SegmentationValidation
# VXLNumerics
# EdgesAndContours
# Filtering
sources.append(("Base", image))
sources.append(("IO", reader.GetOutput()))
otsu = SegmentationAndThreshold.OtsuThresholdImageFilter[IType, IType].New(reader)
sources.append(("SegmentationAndThreshold", otsu.GetOutput()))
flip = SimpleFilters.FlipImageFilter[IType].New(reader)
sources.append(("SimpleFilters", flip.GetOutput()))
abs = UnaryPixelMath.AbsImageFilter[IType, IType].New(reader)
sources.append(("UnaryPixelMath", abs.GetOutput()))
bdilate = BinaryMorphology.BinaryDilateImageFilter[IType, IType, kernel].New(reader, Kernel=kernel)
sources.append(("BinaryMorphology", bdilate.GetOutput()))
minmax = Calculators.MinimumMaximumImageFilter[IType].New(reader)
sources.append(("Calculators", minmax.GetOutput()))
median = Denoising.MedianImageFilter[IType, IType].New(reader)
sources.append(("Denoising", median.GetOutput()))
distance = DistanceMap.DanielssonDistanceMapImageFilter[IType, IType].New(reader)
sources.append(("DistanceMap", distance.GetOutput()))
# sobel = EdgesAndContours.SobelEdgeDetectionImageFilter[IType, IType].New(reader)
# sources.append(("EdgesAndContours", sobel.GetOutput()))
# laplacian = Filtering.LaplacianImageFilter[IType, IType].New(reader)
# sources.append(("Filtering", laplacian.GetOutput()))
invert = IntensityFilters.InvertIntensityImageFilter[IType, IType].New(reader)
sources.append(("IntensityFilters", invert.GetOutput()))
hmax = Morphology.HMaximaImageFilter[IType, IType].New(reader)
sources.append(("Morphology", hmax.GetOutput()))
crop = Resize.CropImageFilter[IType, IType].New(reader)
sources.append(("Resize", crop.GetOutput()))
dests = []
dotsu = SegmentationAndThreshold.OtsuThresholdImageFilter[IType, IType].New(reader)
dests.append(("SegmentationAndThreshold", dotsu))
dflip = SimpleFilters.FlipImageFilter[IType].New()
dests.append(("SimpleFilters", dflip))
dabs = UnaryPixelMath.AbsImageFilter[IType, IType].New()
dests.append(("UnaryPixelMath", dabs))
dbdilate = BinaryMorphology.BinaryDilateImageFilter[IType, IType, kernel].New(Kernel=kernel)
dests.append(("BinaryMorphology", dbdilate))
dminmax = Calculators.MinimumMaximumImageFilter[IType].New()
dests.append(("Calculators", dminmax))
dmedian = Denoising.MedianImageFilter[IType, IType].New()
dests.append(("Denoising", dmedian))
ddistance = DistanceMap.DanielssonDistanceMapImageFilter[IType, IType].New()
dests.append(("DistanceMap", ddistance))
# dsobel = EdgesAndContours.SobelEdgeDetectionImageFilter[IType, IType].New()
# dests.append(("EdgesAndContours", dsobel))
# dlaplacian = Filtering.LaplacianImageFilter[IType, IType].New()
# dests.append(("Filtering", dlaplacian))
dinvert = IntensityFilters.InvertIntensityImageFilter[IType, IType].New()
dests.append(("IntensityFilters", dinvert))
dhmax = Morphology.HMaximaImageFilter[IType, IType].New()
dests.append(("Morphology", dhmax))
dcrop = Resize.CropImageFilter[IType, IType].New()
dests.append(("Resize", dcrop))
writer = IO.ImageFileWriter[IType].New(FileName='out.png')
dests.append(("IO", writer))
nb = 0
failList = []
for sname, s in sources:
for dname, d in dests:
nb += 1
d.SetInput( s )
try:
d.Update()
print "%s -> %s pass" % (sname, dname)
except RuntimeError, e:
print "%s -> %s fail" % (sname, dname)
failList.append((sname, dname))
print
print "%i tests succeed" % (nb - len(failList))
print "%i tests failed" % len(failList)
sys.exit(len(failList))
|