Skip to content

Commit

Permalink
ENH: Added ReadAnImage Python script
Browse files Browse the repository at this point in the history
  • Loading branch information
kian-weimer committed Jun 3, 2021
1 parent 0c6e1af commit fb73fdb
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/IO/ImageBase/ReadAnImage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ install( FILES Code.cxx CMakeLists.txt
COMPONENT Code
)

set( input_image ${CMAKE_CURRENT_BINARY_DIR}/Yinyang.png )

enable_testing()
add_test( NAME ReadAnImageTest
COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ReadAnImage
${CMAKE_CURRENT_BINARY_DIR}/Yinyang.png
${input_image}
)

if(ITK_WRAP_PYTHON)
add_test(NAME ReadAnImageTestPython
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Code.py
${input_image}
)
endif()
24 changes: 24 additions & 0 deletions src/IO/ImageBase/ReadAnImage/Code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python

# Copyright NumFOCUS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0.txt
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import sys
import itk

if len(sys.argv) != 2:
print("Usage: " + sys.argv[0] + " <InputFileName>")
sys.exit(1)

image = itk.imread(sys.argv[1])
7 changes: 7 additions & 0 deletions src/IO/ImageBase/ReadAnImage/Documentation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ NA
Code
----

Python
......

.. literalinclude:: Code.py
:language: python
:lines: 1, 16-

C++
...

Expand Down

0 comments on commit fb73fdb

Please sign in to comment.