Beispiel #1
0
median.SetInput(None)
assert median.GetInput() is None

# ImageSource

median2 = itk.MedianImageFilter.IUC2IUC2.New()
median.SetInput(median2.GetOutput())
assert median.GetInput() == median2.GetOutput()

# catching exception
try:
    median.Update()
    print("Exception not throwed!", file=sys.stderr)
    sys.exit(1)
except RuntimeError as e:
    print("Exception catched as expected", e)

#   ----- keep that at the end! -----


# pycommand masked
def exit():
    sys.exit(0)


median2.AddObserver(itk.DeleteEvent(), exit)
del median

# we shouldn't reach that point
sys.exit(1)
Beispiel #2
0
median.SetInput(im)
assert median.GetInput() == im
assert median.GetInput() != median.GetOutput()

median.SetInput(None)
assert median.GetInput() is None

# ImageSource

median2 = itk.MedianImageFilter.IUC2IUC2.New()
median.SetInput(median2)
assert median.GetInput() == median2.GetOutput()

# catching exception
try:
    median.Update()
    print("Exception not throwed!", file=sys.stderr)
    sys.exit(1)
except RuntimeError as e:
    print("Exception catched as expected", e)

#   ----- keep that at the end! -----

# pycommand masked
median2.AddObserver(itk.DeleteEvent(), lambda: sys.exit(0))
del median

# we shouldn't reach that point
sys.exit(1)