Skip to content

Commit c585070

Browse files
committed
ENH: Add a Python test
1 parent 5f66a80 commit c585070

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4106f7a97659761a7fd42594a4f19aa9dad312445a1c9ff63f397f0c32cb952ee5d6ba6c6582951d883e6f40587091437a872c5fce966670d57f4984125c7a5d
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
eb93426d1ee5f00d722979fd9dbfd8701f27bbb4256522e3d25c4db0f88f33b6a2db1ce572613e38c1a91787ca911e2399d206a137f7e987421b357bd5925b5d
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
set(test_input_dir ${itk-module_SOURCE_DIR}/test/Input)
2+
3+
# let's make sure 3D uchar images are wrapped
4+
list(FIND ITK_WRAP_IMAGE_DIMS 3 wrap_3_index)
5+
if(ITK_WRAP_PYTHON AND ITK_WRAP_unsigned_char AND wrap_3_index GREATER -1)
6+
itk_python_add_test(NAME OrientImageFilterTest
7+
TEST_DRIVER_ARGS
8+
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/itkLabelOverlapMeasuresImageFilterTest.py
9+
DATA{${test_input_dir}/DzZ_T1.seg.nrrd}
10+
DATA{${test_input_dir}/DzZ_Seeds.seg.nrrd}
11+
)
12+
endif()
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ==========================================================================
2+
#
3+
# Copyright NumFOCUS
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0.txt
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
# ==========================================================================*/
18+
19+
20+
import itk
21+
from sys import argv
22+
23+
itk.auto_progress(2)
24+
25+
ref = itk.imread(argv[1], itk.UC)
26+
seg = itk.imread(argv[2], itk.UC)
27+
28+
lom_filter = itk.LabelOverlapMeasuresImageFilter[itk.Image[itk.UC, 3]].New()
29+
lom_filter.SetTargetImage(seg)
30+
lom_filter.SetSourceImage(ref)
31+
lom_filter.UpdateLargestPossibleRegion()
32+
lsm = lom_filter.GetLabelSetMeasures()
33+
for label, measure in lsm.items():
34+
print(f"Label: {label}, i: {measure.m_Intersection}, u: {measure.m_Union}")

0 commit comments

Comments
 (0)