File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ itk_module(Cuberille
2727 ITKQuadEdgeMeshFiltering
2828 ITKThresholding
2929 ITKIOImageBase
30+ ITKIOMeta
31+ ITKIONRRD
32+ ITKIOMeshBase
33+ ITKIOVTK
3034 DESCRIPTION
3135 "${DOCUMENTATION} "
3236 EXCLUDE_FROM_DEFAULT
Original file line number Diff line number Diff line change 1+ itk_python_expression_add_test (
2+ NAME itkCuberilleImageToMeshFilterPythonTest
3+ EXPRESSION "filter = itk.CuberilleImageToMeshFilter.New()"
4+ )
5+
6+ set (test_input_dir ${CMAKE_CURRENT_SOURCE_DIR} /../../test/Input)
7+ # cmake_path(CONVERT ${test_input_dir} TO_CMAKE_PATH_LIST test_input_dir NORMALIZE) # CMake 3.20+
8+
9+ list (FIND ITK_WRAP_IMAGE_DIMS 3 wrap_3_index)
10+ if (wrap_3_index GREATER -1)
11+ itk_python_add_test (NAME Cuberille_blob0_python
12+ TEST_DRIVER_ARGS
13+ COMMAND cuberille_test.py
14+ DATA{${test_input_dir}/blob0.mha}
15+ ${ITK_TEST_OUTPUT_DIR} /blob0.vtk
16+ )
17+
18+ itk_python_add_test (NAME Cuberille_blob0_100_python
19+ TEST_DRIVER_ARGS
20+ COMMAND cuberille_test.py
21+ DATA{${test_input_dir}/blob0.mha}
22+ ${ITK_TEST_OUTPUT_DIR} /blob0_100.vtk
23+ 100 # iso-surface value
24+ )
25+
26+ itk_python_add_test (NAME Cuberille_hydrogenAtom_35_python
27+ TEST_DRIVER_ARGS
28+ COMMAND cuberille_test.py
29+ DATA{${test_input_dir}/hydrogenAtom.mha}
30+ ${ITK_TEST_OUTPUT_DIR} /hydrogenAtom35.vtk
31+ 35 # iso-surface value
32+ )
33+
34+ itk_python_add_test (NAME Cuberille_hydrogenAtom_50_python
35+ TEST_DRIVER_ARGS
36+ COMMAND cuberille_test.py
37+ DATA{${test_input_dir}/hydrogenAtom.mha}
38+ ${ITK_TEST_OUTPUT_DIR} /hydrogenAtom50.vtk
39+ 50 # iso-surface value
40+ )
41+ endif ()
Original file line number Diff line number Diff line change 1+ import sys
2+
3+ import itk
4+
5+ image = itk .imread (sys .argv [1 ])
6+
7+ if len (sys .argv ) > 3 :
8+ isosurface = sys .argv [3 ]
9+ else :
10+ calculator = itk .MinimumMaximumImageCalculator [type (image )].New ()
11+ calculator .SetImage (image )
12+ calculator .Compute ()
13+ isosurface = (calculator .GetMaximum () + calculator .GetMinimum ()) / 2
14+
15+ # convert number type
16+ (input_image_template , (input_pixel_type , input_image_dimension )) = itk .template (image )
17+ if input_pixel_type == itk .F or input_pixel_type == itk .D :
18+ isosurface = float (isosurface )
19+ else :
20+ isosurface = int (isosurface )
21+
22+ mesh = itk .cuberille_image_to_mesh_filter (
23+ image ,
24+ generate_triangle_faces = True ,
25+ iso_surface_value = isosurface ,
26+ project_vertices_to_iso_surface = True ,
27+ project_vertex_surface_distance_threshold = 0.05 ,
28+ )
29+
30+ itk .meshwrite (mesh , sys .argv [2 ])
You can’t perform that action at this time.
0 commit comments