Skip to content

Commit 35ca99d

Browse files
kian-weimerdzenanz
authored andcommitted
ENH: Added ReadAnImage Python script
1 parent 8d0cf11 commit 35ca99d

File tree

3 files changed

+41
-1
lines changed

3 files changed

+41
-1
lines changed

src/IO/ImageBase/ReadAnImage/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,17 @@ install( FILES Code.cxx CMakeLists.txt
1818
COMPONENT Code
1919
)
2020

21+
set( input_image ${CMAKE_CURRENT_BINARY_DIR}/Yinyang.png )
22+
2123
enable_testing()
2224
add_test( NAME ReadAnImageTest
2325
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ReadAnImage
24-
${CMAKE_CURRENT_BINARY_DIR}/Yinyang.png
26+
${input_image}
2527
)
28+
29+
if(ITK_WRAP_PYTHON)
30+
add_test(NAME ReadAnImageTestPython
31+
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py
32+
${input_image}
33+
)
34+
endif()

src/IO/ImageBase/ReadAnImage/Code.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
3+
# Copyright NumFOCUS
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0.txt
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
import sys
18+
import itk
19+
20+
if len(sys.argv) != 2:
21+
print("Usage: " + sys.argv[0] + " <InputFileName>")
22+
sys.exit(1)
23+
24+
image = itk.imread(sys.argv[1])

src/IO/ImageBase/ReadAnImage/Documentation.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ NA
2222
Code
2323
----
2424

25+
Python
26+
......
27+
28+
.. literalinclude:: Code.py
29+
:language: python
30+
:lines: 1, 16-
31+
2532
C++
2633
...
2734

0 commit comments

Comments
 (0)