https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Misc. morpho-related fixes.
* mln/morpho/line_gradient.hh
(mln::morpho::line_gradient) [!NDEBUG]: Avoid a warning in debug
mode.
* mln/morpho/meyer_wst.hh: s/markers/output/.
* mln/level/sort_psites.hh: Remove outdated FIXME.
* mln/convert/to_p_array.hh
(mln::convert::to_p_array(const Point_Set<S>&)): Add a FIXME.
* tests/morpho/lena_line_graph_image_wst2.cc: Encode the number of
regions on an `unsigned' value.
Don't re-quantize the watershed result to 8 bits before processing
it, as it could merge bassins.
mln/convert/to_p_array.hh | 7 +++----
mln/level/sort_psites.hh | 14 ++++----------
mln/morpho/line_gradient.hh | 10 +++++++++-
mln/morpho/meyer_wst.hh | 20 ++++++++++----------
tests/morpho/lena_line_graph_image_wst2.cc | 18 +++++-------------
5 files changed, 31 insertions(+), 38 deletions(-)
Index: mln/morpho/line_gradient.hh
--- mln/morpho/line_gradient.hh (revision 1987)
+++ mln/morpho/line_gradient.hh (working copy)
@@ -34,6 +34,8 @@
# include <map>
# include <vector>
+# include <mln/math/abs.hh>
+
# include <mln/core/image2d.hh>
# include <mln/core/window2d.hh>
# include <mln/core/line_graph_image.hh>
@@ -94,10 +96,16 @@
for_all (q)
if (ima.has(q))
{
+ // Avoid a warning about an undefined variable when the
+ // NDEBUG is not defined.
+#ifdef NDEBUG
+ g.add_edge(points[p], points[q]);
+#else // !NDEBUG
util::edge_id id = g.add_edge(points[p], points[q]);
+#endif //!NDEBUG
// The computed value is a norm of the gradient between P and Q.
edge_values.push_back(math::abs(ima(p) - ima(q)));
- assert(id != mln_max(util::edge_id));
+ mln_assertion(id != mln_max(util::edge_id));
}
// Line graph point set.
Index: mln/morpho/meyer_wst.hh
--- mln/morpho/meyer_wst.hh (revision 1987)
+++ mln/morpho/meyer_wst.hh (working copy)
@@ -113,7 +113,7 @@
const marker unmarked = mln_min(marker);
// Initialize the output with the markers (minima components).
- mln_ch_value(I, marker) markers =
+ mln_ch_value(I, marker) output =
labeling::regional_minima (input, nbh, nbasins);
typedef mln_psite(I) psite;
@@ -130,12 +130,12 @@
// Insert every neighbor P of every marked area in a
// hierarchical queue, with a priority level corresponding to
// the grey level input(P).
- mln_piter(I) p(markers.domain());
+ mln_piter(I) p(output.domain());
mln_niter(N) n(nbh, p);
for_all (p)
- if (markers(p) == unmarked)
+ if (output(p) == unmarked)
for_all(n)
- if (markers.has(n) && markers(n) != unmarked)
+ if (output.has(n) && output(n) != unmarked)
{
queue.push(p);
break;
@@ -154,14 +154,14 @@
bool single_adjacent_marker_p = true;
mln_niter(N) n(nbh, p);
for_all(n)
- if (markers.has(n) && markers(n) != unmarked)
+ if (output.has(n) && output(n) != unmarked)
if (adjacent_marker == unmarked)
{
- adjacent_marker = markers(n);
+ adjacent_marker = output(n);
single_adjacent_marker_p = true;
}
else
- if (adjacent_marker != markers(n))
+ if (adjacent_marker != output(n))
{
single_adjacent_marker_p = false;
break;
@@ -172,13 +172,13 @@
hierarchical queue. */
if (single_adjacent_marker_p)
{
- markers(p) = adjacent_marker;
+ output(p) = adjacent_marker;
for_all(n)
- if (markers.has(n) && markers(n) == unmarked)
+ if (output.has(n) && output(n) == unmarked)
queue.push(n);
}
}
- return markers;
+ return output;
}
template <typename L, typename I, typename N>
Index: mln/level/sort_psites.hh
--- mln/level/sort_psites.hh (revision 1987)
+++ mln/level/sort_psites.hh (working copy)
@@ -28,16 +28,10 @@
#ifndef MLN_LEVEL_SORT_PSITES_HH
# define MLN_LEVEL_SORT_PSITES_HH
-/*! \file mln/level/sort_psites.hh
- *
- * \brief Sort_Psites the contents of an image into another one.
- *
- * \todo Factor code + optimize.
- */
-
-/* FIXME: Factor with mln/level/sort_points.hh, if needed (maybe wait
- for the upcoming big changes regarding types associated to images
- (point -> site, etc.). */
+/// \file mln/level/sort_psites.hh
+/// \brief Sort_Psites the contents of an image into another one.
+///
+/// \todo Factor code + optimize.
# include <algorithm>
Index: mln/convert/to_p_array.hh
--- mln/convert/to_p_array.hh (revision 1987)
+++ mln/convert/to_p_array.hh (working copy)
@@ -28,10 +28,8 @@
#ifndef MLN_CONVERT_TO_P_ARRAY_HH
# define MLN_CONVERT_TO_P_ARRAY_HH
-/*! \file mln/convert/to_p_array.hh
- *
- * \brief Conversions to mln::p_array.
- */
+/// \file mln/convert/to_p_array.hh
+/// \brief Conversions to mln::p_array.
# include <mln/core/p_array.hh>
# include <mln/core/concept/window.hh>
@@ -65,6 +63,7 @@
const S& pset = exact(pset_);
p_array<mln_psite(S)> v;
v.reserve(pset.npoints());
+ // FIXME: Why mln_fwd_piter and not mln_piter?
mln_fwd_piter(S) p(pset);
for_all(p)
v.append(p);
Index: tests/morpho/lena_line_graph_image_wst2.cc
--- tests/morpho/lena_line_graph_image_wst2.cc (revision 1987)
+++ tests/morpho/lena_line_graph_image_wst2.cc (working copy)
@@ -44,8 +44,7 @@
\li reduce the number of minima using an area opening (counting the
vertices to compute the area, not the edges);
\li perform a WST on this simplified line graph image;
- \li reduce the quantification of the result of the WST;
- \li create an 2-D, color output image with height and width double
+ \li create a 2-D, color output image with height and width double
the size the original one, and copy the data of the input image
in it, interpolating inter-pixel points;
\li print the watershed on lines into that same image, and save it. */
@@ -120,18 +119,11 @@
`------*/
// Perform a Watershed Transform.
- typedef int_u16 wst_full_val_t;
- wst_full_val_t nbasins;
- typedef line_graph_image<point2d, wst_full_val_t> wst_full_ima_t;
- wst_full_ima_t wshed_full = morpho::meyer_wst(closed_lg_ima, nbh, nbasins);
- std::cout << "nbasins = " << nbasins << std::endl;
-
- // Reduce the value set to 8-bit.
- typedef int_u8 wst_val_t;
+ typedef unsigned wst_val_t;
+ wst_val_t nbasins;
typedef line_graph_image<point2d, wst_val_t> wst_ima_t;
- wst_ima_t wshed;
- initialize(wshed, wshed_full);
- level::stretch(wshed_full, wshed);
+ wst_ima_t wshed = morpho::meyer_wst(closed_lg_ima, nbh, nbasins);
+ std::cout << "nbasins = " << nbasins << std::endl;
/*---------.
| Output. |