Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Added ReadAnImage Python script #290

Merged
merged 1 commit into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
dzenanz marked this conversation as resolved.
Show resolved Hide resolved

# 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