Skip to content

Commit eca4e0d

Browse files
authored
Merge pull request #133 from thewtex/filter-parameters
doc: Describe how to set filter parameters
2 parents 438286b + 19a5b80 commit eca4e0d

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

docs/Quick_start_guide.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ Some objects (matrix, vector, RGBPixel, ...) do not require the attribute `.New(
7878

7979
In case of doubt, look at the attributes of the object you are trying to instantiate.
8080

81+
Filter Parameters
82+
.................
83+
84+
ITK filter parameters can be specified in the following ways:
85+
86+
.. literalinclude:: code/FilterParameters.py
87+
:lines: 10-
88+
89+
8190
Mixing ITK and NumPy
8291
--------------------
8392

docs/code/FilterParameters.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/usr/bin/env python
2+
3+
import itk
4+
import sys
5+
6+
input_filename = sys.argv[1]
7+
8+
image = itk.imread(input_filename, itk.F)
9+
10+
# Pythonic snake case keyword arguments:
11+
#
12+
# number_of_iterations
13+
#
14+
smoothed = itk.anti_alias_binary_image_filter(image,
15+
number_of_iterations=3)
16+
17+
# CamelCase keyword arguments:
18+
#
19+
# NumberOfIterations
20+
#
21+
smoother = itk.AntiAliasBinaryImageFilter.New(image,
22+
NumberOfIterations=3)
23+
smoother.Update()
24+
smoothed = smoother.GetOutput()
25+
26+
# CamelCase Set method:
27+
#
28+
# SetNumberOfIterations
29+
#
30+
smoother = itk.AntiAliasBinaryImageFilter.New(image)
31+
smoother.SetNumberOfIterations(3)
32+
smoother.Update()
33+
smoothed = smoother.GetOutput()

docs/code/testDriver.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def cleanup(files):
5050
# Run test InstantiateITKObjects.py
5151
add_test(["InstantiateITKObjects.py"])
5252

53+
# Run test FilterParameters.py
54+
add_test(["FilterParameters.py", baseline_image])
55+
5356
# Run test MixingITKAndNumPy.py
5457
output_image = os.path.join(temp_folder, "filtered_image.png")
5558
add_test(["MixingITKAndNumPy.py", baseline_image, output_image])

0 commit comments

Comments
 (0)