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
2121enable_testing ()
2222add_test ( NAME WriteAnImageTest
2323 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
2626Code
2727----
2828
29+ Python
30+ ......
31+
32+ .. literalinclude :: Code.py
33+ :language: python
34+ :lines: 1, 16-
35+
2936C++
3037...
3138
You can’t perform that action at this time.
0 commit comments