Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Olena
pylene
Commits
9b5cc049
Commit
9b5cc049
authored
Jun 11, 2021
by
Quentin Kaci
Browse files
Add some tests for hierarchical watershed
parent
9994b1d0
Pipeline
#28498
passed with stages
in 22 minutes and 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tests/morpho/CMakeLists.txt
View file @
9b5cc049
set
(
test_prefix
"UTMorpho_"
)
add_core_test
(
${
test_prefix
}
running_max_1d running_max_1d.cpp
)
add_core_test
(
${
test_prefix
}
block_running_max block_running_max.cpp
)
add_core_test
(
${
test_prefix
}
fill_hole fill_hole.cpp
)
add_core_test
(
${
test_prefix
}
dilate dilate.cpp
)
add_core_test
(
${
test_prefix
}
erode erode.cpp
)
add_core_test
(
${
test_prefix
}
gradient gradient.cpp
)
add_core_test
(
${
test_prefix
}
opening opening.cpp
)
add_core_test
(
${
test_prefix
}
reconstruction reconstruction.cpp
)
add_core_test
(
${
test_prefix
}
extinction extinction.cpp
)
add_core_test
(
${
test_prefix
}
median_filter median_filter.cpp
)
add_core_test
(
${
test_prefix
}
rank_filter rank_filter.cpp
)
add_core_test
(
${
test_prefix
}
hit_or_miss hit_or_miss.cpp
)
add_core_test
(
${
test_prefix
}
watershed watershed.cpp
)
add_core_test
(
${
test_prefix
}
area_filter area_filter.cpp
)
add_core_test
(
${
test_prefix
}
dynamic_filter dynamic_filter.cpp
)
add_core_test
(
${
test_prefix
}
ToS tos.cpp tos_tests_helper.cpp
)
add_core_test
(
${
test_prefix
}
running_max_1d running_max_1d.cpp
)
add_core_test
(
${
test_prefix
}
block_running_max block_running_max.cpp
)
add_core_test
(
${
test_prefix
}
fill_hole fill_hole.cpp
)
add_core_test
(
${
test_prefix
}
dilate dilate.cpp
)
add_core_test
(
${
test_prefix
}
erode erode.cpp
)
add_core_test
(
${
test_prefix
}
gradient gradient.cpp
)
add_core_test
(
${
test_prefix
}
opening opening.cpp
)
add_core_test
(
${
test_prefix
}
reconstruction reconstruction.cpp
)
add_core_test
(
${
test_prefix
}
extinction extinction.cpp
)
add_core_test
(
${
test_prefix
}
median_filter median_filter.cpp
)
add_core_test
(
${
test_prefix
}
rank_filter rank_filter.cpp
)
add_core_test
(
${
test_prefix
}
hit_or_miss hit_or_miss.cpp
)
add_core_test
(
${
test_prefix
}
watershed watershed.cpp
)
add_core_test
(
${
test_prefix
}
watershed_hierarchy watershed_hierarchy.cpp
)
add_core_test
(
${
test_prefix
}
area_filter area_filter.cpp
)
add_core_test
(
${
test_prefix
}
dynamic_filter dynamic_filter.cpp
)
add_core_test
(
${
test_prefix
}
ToS tos.cpp tos_tests_helper.cpp
)
add_core_test
(
${
test_prefix
}
depth_first
depthfirst.cpp
)
add_core_test
(
${
test_prefix
}
maxtree
maxtree.cpp
)
add_core_test
(
${
test_prefix
}
alphatree
alphatree.cpp
)
add_core_test
(
${
test_prefix
}
depth_first depthfirst.cpp
)
add_core_test
(
${
test_prefix
}
maxtree maxtree.cpp
)
add_core_test
(
${
test_prefix
}
alphatree alphatree.cpp
)
add_core_test
(
${
test_prefix
}
private_directional_hqueue directional_hqueue.cpp
)
target_link_libraries
(
${
test_prefix
}
dilate PRIVATE TBB::TBB
)
target_link_libraries
(
${
test_prefix
}
dilate PRIVATE TBB::TBB
)
tests/morpho/watershed_hierarchy.cpp
0 → 100644
View file @
9b5cc049
#include
"mln/morpho/watershed_hierarchy.hpp"
#include
<mln/accu/accumulators/count.hpp>
#include
<mln/core/colors.hpp>
#include
<mln/core/image/ndimage.hpp>
#include
<mln/core/neighborhood/c4.hpp>
#include
<gtest/gtest.h>
TEST
(
Morpho
,
AreaWatershedHierarchyGray
)
{
mln
::
image2d
<
uint8_t
>
input
=
{
{
163
,
112
,
42
,
121
,
112
},
//
{
42
,
121
,
1
,
42
,
255
},
//
{
1
,
112
,
121
,
112
,
121
},
//
{
112
,
255
,
42
,
1
,
42
},
//
{
121
,
112
,
121
,
112
,
163
},
//
};
std
::
vector
<
int
>
expected_parent
=
{
0
,
0
,
1
,
2
,
2
,
3
,
5
,
0
,
6
,
1
,
9
,
4
,
3
,
11
,
7
,
14
,
15
,
16
,
8
,
18
,
19
,
20
,
4
,
21
,
7
,
14
,
15
,
16
,
17
,
9
,
10
,
10
,
5
,
17
,
18
,
19
,
20
,
21
,
12
,
6
,
11
,
13
,
23
,
12
,
22
,
22
,
13
,
23
,
8
};
std
::
vector
<
unsigned
long
>
expected_values
=
{
6
,
3
,
3
,
2
,
2
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
auto
[
tree
,
_
]
=
mln
::
morpho
::
watershed_hierarchy
(
input
,
mln
::
accu
::
features
::
count
<>
(),
mln
::
c4
,
[](
const
auto
&
a
,
const
auto
&
b
)
->
float
{
return
mln
::
functional
::
l2dist_t
<>
()(
a
,
b
);
});
ASSERT_EQ
(
expected_parent
.
size
(),
tree
.
parent
.
size
());
ASSERT_EQ
(
expected_values
.
size
(),
tree
.
values
.
size
());
ASSERT_EQ
(
tree
.
parent
.
size
(),
tree
.
values
.
size
());
for
(
std
::
size_t
i
=
0
;
i
<
expected_parent
.
size
();
++
i
)
{
EXPECT_EQ
(
expected_parent
[
i
],
tree
.
parent
[
i
]);
EXPECT_EQ
(
expected_values
[
i
],
tree
.
values
[
i
]);
}
}
TEST
(
Morpho
,
AreaWatershedHierarchyRGB
)
{
mln
::
image2d
<
mln
::
rgb8
>
input
=
{
{{
255
,
146
,
0
},
{
31
,
174
,
0
},
{
45
,
0
,
255
},
{
255
,
75
,
0
},
{
31
,
174
,
0
}},
//
{{
45
,
0
,
255
},
{
255
,
75
,
0
},
{
3
,
0
,
0
},
{
45
,
0
,
255
},
{
255
,
255
,
255
}},
//
{{
3
,
0
,
0
},
{
31
,
174
,
0
},
{
255
,
75
,
0
},
{
31
,
174
,
0
},
{
255
,
75
,
0
}},
//
{{
31
,
174
,
0
},
{
255
,
255
,
255
},
{
45
,
0
,
255
},
{
3
,
0
,
0
},
{
45
,
0
,
255
}},
//
{{
255
,
75
,
0
},
{
31
,
174
,
0
},
{
255
,
75
,
0
},
{
31
,
174
,
0
},
{
255
,
146
,
0
}},
//
};
std
::
vector
<
int
>
expected_parent
=
{
0
,
0
,
0
,
1
,
1
,
4
,
5
,
6
,
2
,
3
,
8
,
9
,
11
,
12
,
7
,
13
,
2
,
3
,
14
,
17
,
18
,
20
,
15
,
22
,
18
,
20
,
11
,
12
,
13
,
6
,
21
,
7
,
4
,
22
,
14
,
21
,
15
,
23
,
23
,
5
,
8
,
10
,
17
,
9
,
16
,
16
,
10
,
19
,
19
};
std
::
vector
<
unsigned
long
>
expected_values
=
{
3
,
3
,
2
,
2
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
};
auto
[
tree
,
_
]
=
mln
::
morpho
::
watershed_hierarchy
(
input
,
mln
::
accu
::
features
::
count
<>
(),
mln
::
c4
,
[](
const
auto
&
a
,
const
auto
&
b
)
->
float
{
return
mln
::
functional
::
l2dist_t
<>
()(
a
,
b
);
});
ASSERT_EQ
(
expected_parent
.
size
(),
tree
.
parent
.
size
());
ASSERT_EQ
(
expected_values
.
size
(),
tree
.
values
.
size
());
ASSERT_EQ
(
tree
.
parent
.
size
(),
tree
.
values
.
size
());
for
(
std
::
size_t
i
=
0
;
i
<
expected_parent
.
size
();
++
i
)
{
EXPECT_EQ
(
expected_parent
[
i
],
tree
.
parent
[
i
]);
EXPECT_EQ
(
expected_values
[
i
],
tree
.
values
[
i
]);
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment