File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed
src/IO/ImageBase/WriteAnImage Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -21,3 +21,8 @@ install( FILES Code.cxx CMakeLists.txt
21
21
enable_testing ()
22
22
add_test ( NAME WriteAnImageTest
23
23
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} /WriteAnImage )
24
+
25
+ if (ITK_WRAP_PYTHON )
26
+ add_test (NAME WriteAnImageTestPython
27
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR} /Code.py )
28
+ endif ()
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+
3
+ import sys
4
+ import itk
5
+
6
+ if len (sys .argv ) > 1 :
7
+ output_filename = sys .argv [1 ]
8
+ else :
9
+ output_filename = "testPython.png"
10
+
11
+ pixel_type = itk .UC
12
+ dimension = 2
13
+ image_type = itk .Image [pixel_type , dimension ]
14
+
15
+ start = itk .Index [dimension ]()
16
+ start .Fill (0 )
17
+
18
+ size = itk .Size [dimension ]()
19
+ size [0 ] = 200
20
+ size [1 ] = 300
21
+
22
+ region = itk .ImageRegion [dimension ]()
23
+ region .SetIndex (start )
24
+ region .SetSize (size )
25
+
26
+ image = image_type .New (Regions = region )
27
+ image .Allocate ()
28
+
29
+ itk .imwrite (image , output_filename )
Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ Results
26
26
Code
27
27
----
28
28
29
+ Python
30
+ ......
31
+
32
+ .. literalinclude :: Code.py
33
+ :language: python
34
+ :lines: 1, 16-
35
+
29
36
C++
30
37
...
31
38
You can’t perform that action at this time.
0 commit comments