Repository: KitwareMedical/ITKContourInterpolation (language: python)

Issue:
how to use this module in python?
Hi, i have installed the python package, and i can find it in `itk.MorphologicalContourInterpolator`, but i don't know how to use it? Can you give me a demo in python? best with `numpy.ndarray` as input...

Thanks.


Discussion / hints:
It is just a normal filter, so [basic use instructions](https://itkpythonpackage.readthedocs.io/en/latest/Quick_start_guide.html) should apply. If you write a bare-bones code to invoke it, it would be nice to submit it as [an example](https://github.com/KitwareMedical/ITKMorphologicalContourInterpolation/tree/master/examples).

NumPy array inputs will be supported with a rebuild against ITK 5.1 after it has been released.
Yeah, i have used it in Linux, there were some erros occurs in OSX. But the function consume much time and raise some errors for some mask with spotted region, like chest vessel mask.

Fix patch:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 447dafc..965d540 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,19 @@
 cmake_minimum_required(VERSION 3.10.2)
+
+if(CMAKE_CXX_STANDARD EQUAL "98" )
+   message(FATAL_ERROR "CMAKE_CXX_STANDARD:STRING=98 is not supported in ITK version 5 and greater.")
+endif()
+
+if(NOT CMAKE_CXX_STANDARD)
+  set(CMAKE_CXX_STANDARD 11) # Supported values are ``11``, ``14``, and ``17``.
+endif()
+if(NOT CMAKE_CXX_STANDARD_REQUIRED)
+  set(CMAKE_CXX_STANDARD_REQUIRED ON)
+endif()
+if(NOT CMAKE_CXX_EXTENSIONS)
+  set(CMAKE_CXX_EXTENSIONS OFF)
+endif()
+
 project(MorphologicalContourInterpolation)
 
 if(NOT ITK_SOURCE_DIR)
@@ -6,6 +21,7 @@ if(NOT ITK_SOURCE_DIR)
   list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
   include(ITKModuleExternal)
 else()
+  set(ITK_DIR ${CMAKE_BINARY_DIR})
   itk_module_impl()
 endif()
 
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 99f63be..b6d3d9f 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -2,22 +2,30 @@ cmake_minimum_required(VERSION 3.10.2)
 
 project(MorphologicalContourInterpolation_Examples CXX)
 
-find_package(ITK REQUIRED
-  COMPONENTS
-    MorphologicalContourInterpolation
-    ITKSmoothing
-    ITKIOImageBase
-    ITKIONRRD
-    )
+if(NOT ITK_SOURCE_DIR)
+  find_package(ITK 5.2 REQUIRED COMPONENTS MorphologicalContourInterpolation ITKSmoothing ITKImageIO ITKTestKernel)
+else()
+  # when being built as part of ITK, ITKImageIO and ITKTransformIO
+  # lists of modules are not yet ready, causing a configure error
+  find_package(ITK REQUIRED COMPONENTS MorphologicalContourInterpolation ITKSmoothing ITKIOImageBase ITKIONRRD ITKTestKernel)
+endif()
 include(${ITK_USE_FILE})
 
 add_executable(mciExample mciExample.cxx)
 target_link_libraries(mciExample ${ITK_LIBRARIES})
 
 
+# add some regression tests
 enable_testing()
 
 add_test(NAME mciExample_SevenLabels_3
   COMMAND mciExample ${CMAKE_CURRENT_SOURCE_DIR}/SevenLabels.nrrd
     ${CMAKE_CURRENT_BINARY_DIR}/SevenLabels_interpolated.nrrd
     3)
+
+if(ITK_WRAP_PYTHON)
+  add_test(NAME mciExample_ManyToMany
+    COMMAND python ${CMAKE_CURRENT_LIST_DIR}/mciExample.py
+      ${CMAKE_CURRENT_SOURCE_DIR}/ManyToMany.nrrd
+      ${CMAKE_CURRENT_BINARY_DIR}/ManyToMany_interpolated.nrrd)
+endif()
\ No newline at end of file
diff --git a/examples/ManyToMany.nrrd b/examples/ManyToMany.nrrd
new file mode 100644
index 0000000..298966e
Binary files /dev/null and b/examples/ManyToMany.nrrd differ
diff --git a/examples/mciExample.py b/examples/mciExample.py
new file mode 100644
index 0000000..075656a
--- /dev/null
+++ b/examples/mciExample.py
@@ -0,0 +1,10 @@
+import itk
+import sys
+
+if len (sys.argv) < 3:
+    print( "Usage: %s <input> <output>" % (sys.argv[0]) )
+    sys.exit(1)
+
+image = itk.imread(sys.argv[1], itk.UC)
+filled = itk.morphological_contour_interpolator(image)
+itk.imwrite(filled, sys.argv[2], compression=True)


Test patch:
diff --git a/.github/workflows/build-test-package.yml b/.github/workflows/build-test-package.yml
index 51affcb..7e663e3 100644
--- a/.github/workflows/build-test-package.yml
+++ b/.github/workflows/build-test-package.yml
@@ -108,6 +108,7 @@ jobs:
         endif()
         set(dashboard_cache "
         ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-b
+        Module_MorphologicalContourInterpolation_BUILD_EXAMPLES:BOOL=ON
         BUILD_TESTING:BOOL=ON
         ")
         string(TIMESTAMP build_date "%Y-%m-%d")