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
ec114a08
Commit
ec114a08
authored
Jan 08, 2020
by
Edwin Carlinet
Browse files
Augment component tree documentation.
parent
f804ed18
Changes
2
Hide whitespace changes
Inline
Side-by-side
pylene/include/mln/morpho/experimental/component_tree.hpp
View file @
ec114a08
...
...
@@ -40,8 +40,31 @@ namespace mln::morpho::experimental
using
node_map_t
=
int
;
/// \brief Filter the tree given a predicate that removes some nodes according to the selected strategy.
///
/// The parent array is updated, as well as the node_map if provided. It does not invalidate the node id, i.e. node
/// that remain keeps the same position.
///
/// The strategy is one of DIRECT, MIN, MAX, SUBTRACTIVE
///
/// * Min
/// A node is remove if it does not pass the predicate and
/// all its descendant are removed as well.
/// Formally, a component Γ is kept if 𝓒(Γ) with
/// 𝓒(Γ) = ⋁ { 𝓟(Γ'), Γ ⊆ Γ' }.
///
/// * Max
/// A node is remove if every node in its childhood does not pass
/// the predicate. All its descendant are removed as well. Formally, a
/// component Γ is kept if 𝓒(Γ) with 𝓒(Γ) = ⋀ { 𝓟(Γ'), Γ' ⊆ Γ }.
///
/// * Direct
/// A node is remove if it does not pass the predicate, the others
/// remain.
///
///
/// \param strategy The filtering strategy
/// \param pred A boolean predicate for each node id
template
<
class
F
>
void
filter
(
ct_filtering
strategy
,
F
pred
);
...
...
@@ -51,43 +74,49 @@ namespace mln::morpho::experimental
/// \brief Compute the depth attribute over a tree
std
::
vector
<
int
>
compute_depth
_map
()
const
;
std
::
vector
<
int
>
compute_depth
()
const
;
/// \brief Compute attribute on values
///
/// Compute attribute with values given from an image
///
/// \param node_map Image point -> node_id mapping
/// \param values Image point -> value mapping
/// \param acc Accumulator to apply on values
template
<
class
I
,
class
J
,
class
Accu
>
std
::
vector
<
typename
accu
::
result_of
<
Accu
,
image_value_t
<
J
>>::
type
>
//
compute_attribute_on_values
(
I
node_map
,
J
input
,
Accu
acc
);
compute_attribute_on_values
(
I
node_map
,
J
values
,
Accu
acc
);
/// \brief Compute attribute on points
/// \brief Compute attribute on values
///
/// Compute attribute on points
///
/// \param node_map Image point -> node_id mapping
/// \param values Image point -> value mapping
/// \param acc Accumulator to apply on points
template
<
class
I
,
class
Accu
>
std
::
vector
<
typename
accu
::
result_of
<
Accu
,
image_point_t
<
I
>>::
type
>
//
compute_attribute_on_points
(
I
node_map
,
Accu
acc
);
/// \brief Compute attribute on values
template
<
class
I
,
class
J
,
class
Accu
>
void
compute_attribute_on_pixels
(
I
node_map
,
J
input
,
Accu
acc
);
/// \brief Reconstruct an image from an attribute map
///
/// \param node_map Image point -> node_id mapping
/// \param values node_id -> value mapping
template
<
class
I
,
class
V
>
image_ch_value_t
<
I
,
V
>
reconstruct_from
(
I
node_map
,
::
ranges
::
span
<
V
>
values
)
const
;
template
<
class
I
,
class
F
>
void
update_node_map
(
I
node_map
,
F
pred
)
const
;
/// \brief Filter an image
// template <class I, class J, class F>
// void filter(e_filtering strategy, I node_map, J input, ::ranges::span<V> values, F pred) const;
using
node_t
=
int
;
std
::
vector
<
node_t
>
parent
;
private:
template
<
class
I
,
class
F
>
void
update_node_map
(
I
node_map
,
F
pred
)
const
;
void
filter_direct
(
const
std
::
vector
<
bool
>&
pred
);
template
<
class
F
>
...
...
pylene/src/morpho/component_tree.cpp
View file @
ec114a08
...
...
@@ -7,4 +7,18 @@ namespace mln::morpho::experimental
{
this
->
filter_direct_T
([
&
pred
](
int
x
)
{
return
pred
[
x
];
});
}
std
::
vector
<
int
>
component_tree
<
void
>::
compute_depth
()
const
{
std
::
size_t
n
=
parent
.
size
();
std
::
vector
<
int
>
depth
(
n
);
depth
[
0
]
=
0
;
for
(
std
::
size_t
i
=
1
;
i
<
n
;
++
i
)
depth
[
i
]
=
depth
[
parent
[
i
]]
+
1
;
return
depth
;
}
}
Write
Preview
Markdown
is supported
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