From fb73fdba0cd8fe3f6ca5fbd305d8fca4f621dd01 Mon Sep 17 00:00:00 2001 From: Kian Weimer Date: Thu, 3 Jun 2021 16:19:44 -0500 Subject: [PATCH] ENH: Added ReadAnImage Python script --- src/IO/ImageBase/ReadAnImage/CMakeLists.txt | 11 ++++++++- src/IO/ImageBase/ReadAnImage/Code.py | 24 +++++++++++++++++++ .../ImageBase/ReadAnImage/Documentation.rst | 7 ++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/IO/ImageBase/ReadAnImage/Code.py diff --git a/src/IO/ImageBase/ReadAnImage/CMakeLists.txt b/src/IO/ImageBase/ReadAnImage/CMakeLists.txt index c3e3f3f11..3c3fc8302 100644 --- a/src/IO/ImageBase/ReadAnImage/CMakeLists.txt +++ b/src/IO/ImageBase/ReadAnImage/CMakeLists.txt @@ -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() diff --git a/src/IO/ImageBase/ReadAnImage/Code.py b/src/IO/ImageBase/ReadAnImage/Code.py new file mode 100644 index 000000000..7886036f1 --- /dev/null +++ b/src/IO/ImageBase/ReadAnImage/Code.py @@ -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] + " ") + sys.exit(1) + +image = itk.imread(sys.argv[1]) diff --git a/src/IO/ImageBase/ReadAnImage/Documentation.rst b/src/IO/ImageBase/ReadAnImage/Documentation.rst index 21930a238..a574ab741 100644 --- a/src/IO/ImageBase/ReadAnImage/Documentation.rst +++ b/src/IO/ImageBase/ReadAnImage/Documentation.rst @@ -22,6 +22,13 @@ NA Code ---- +Python +...... + +.. literalinclude:: Code.py + :language: python + :lines: 1, 16- + C++ ...