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
f74653cd
Commit
f74653cd
authored
Jun 30, 2021
by
Baptiste Esteban
Browse files
Refacto saliency map
parent
ee3f1d79
Pipeline
#28901
passed with stages
in 16 minutes and 26 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
doc/source/morpho/component_tree.rst
View file @
f74653cd
...
...
@@ -298,24 +298,25 @@ Saliency Computation
--------------
It is also possible to compute the saliency map to obtain another visualization.
.. cpp:function:: auto saliency(
I
mage node_map
)
.. cpp:function:: auto saliency(
i
mage
2d<int>
node_map
, ranges::span<double> values) const
Compute and return the saliency map of the tree.
Compute and return the saliency map of the tree.
**Works only for 2D images and with tree node values of type** ``double``.
:param node_map: An image thats maps ``point -> node id``
:param values: the levels of the tree for each node
:return: The saliency map as an image
.. list-table::
* - .. image:: /images/
watershed_hierarchy_are
a_gray.p
n
g
* - .. image:: /images/
len
a_gray.
j
pg
:width: 100%
- .. image:: /images/saliency_watershed.png
:width: 100%
* -
Watershed hierarchy by area with a cut at a threshold of 25
-
The corresponding saliency map
* -
Original image
-
Saliency map of the watershed hierarchy by area
A complete example
------------------
...
...
pylene/src/morpho/component_tree.cpp
View file @
f74653cd
#include
<mln/morpho/component_tree.hpp>
#include
<iostream>
namespace
mln
::
morpho
{
namespace
internal
...
...
@@ -51,27 +49,22 @@ namespace mln::morpho
}
return
b
;
};
std
::
vector
<
internal
::
edge_t
<
point2d
,
int
>>
s_map
;
mln_foreach
(
auto
p
,
node_map
.
domain
())
{
if
(
p
[
0
]
==
440
&&
p
[
1
]
==
224
)
std
::
cout
<<
""
;
for
(
auto
q
:
c4
.
after
(
p
))
{
if
(
node_map
.
domain
().
has
(
q
))
s_map
.
emplace_back
(
p
,
q
,
values
[
lca
(
node_map
(
p
),
node_map
(
q
))]);
}
}
const
auto
kwidth
=
node_map
.
width
()
*
2
-
1
;
const
auto
kheight
=
node_map
.
height
()
*
2
-
1
;
image2d
<
double
>
res
(
kwidth
,
kheight
);
fill
(
res
,
0
);
for
(
const
auto
[
u
,
v
,
w
]
:
s_map
)
mln_foreach
(
auto
p
,
node_map
.
domain
())
{
for
(
auto
q
:
c4
.
after
(
p
))
{
const
auto
dir
=
v
-
u
;
res
(
point2d
{
2
*
u
[
0
],
2
*
u
[
1
]}
+
dir
)
=
w
;
if
(
node_map
.
domain
().
has
(
q
))
{
const
auto
dir
=
q
-
p
;
res
(
point2d
{
2
*
p
[
0
],
2
*
p
[
1
]}
+
dir
)
=
values
[
lca
(
node_map
(
p
),
node_map
(
q
))];
}
}
}
return
res
;
...
...
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