https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update use of transposition.
* icdar/2009/hsc/input_to_lines.hh: Update.
* icdar/2009/hsc/input_to_ws.hh: Add log.
Update.
* icdar/2009/hsc/ws_to_wsl.hh: Likewise.
* jardonnet/registration/cov.hh: Update.
* jardonnet/registration/quat7.hh: Update.
icdar/2009/hsc/input_to_lines.hh | 5 ++-
icdar/2009/hsc/input_to_ws.hh | 51 ++++++++++++++++++++++++++++++++++++++-
icdar/2009/hsc/ws_to_wsl.hh | 48 ++++++++++++------------------------
jardonnet/registration/cov.hh | 2 -
jardonnet/registration/quat7.hh | 4 +--
5 files changed, 72 insertions(+), 38 deletions(-)
Index: icdar/2009/hsc/input_to_lines.hh
--- icdar/2009/hsc/input_to_lines.hh (revision 3691)
+++ icdar/2009/hsc/input_to_lines.hh (working copy)
@@ -6,9 +6,10 @@
#include <mln/world/binary_2d/subsample.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/label.hh>
-#include <mln/labeling/relabel.hh>
+#include <mln/labeling/pack.hh>
#include <mln/core/image/violent_cast_image.hh>
+#include <mln/io/pgm/save.hh>
namespace mln
@@ -38,7 +39,7 @@
// Clean lines
wsl = clean_lines(input, wsl, tau);
- return labeling::relabel(violent_cast_image_<L>(wsl),
+ return labeling::pack(violent_cast_image_<L>(wsl),
n_lines);
}
Index: icdar/2009/hsc/input_to_ws.hh
--- icdar/2009/hsc/input_to_ws.hh (revision 3691)
+++ icdar/2009/hsc/input_to_ws.hh (working copy)
@@ -10,10 +10,18 @@
#include <sandbox/theo/exec/gaussian_directional_2d.hh>
#include <mln/win/rectangle2d.hh>
-
#include <mln/morpho/closing/structural.hh>
#include <mln/morpho/watershed/flooding.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/literal/colors.hh>
+#include <mln/debug/colorize.hh>
+#include <mln/level/convert.hh>
+#include <mln/labeling/wrap.hh>
+#include <mln/pw/all.hh>
+#include <mln/core/image/image_if.hh>
+
namespace mln
{
@@ -52,6 +60,12 @@
out = linear::gaussian_directional_2d(out, 0, v_sigma, 0);
fuzzy = level::saturate(value::int_u8(), out);
+
+#ifdef LOG
+ io::pgm::save(small, "temp_small.pgm");
+ io::pgm::save(fuzzy, "temp_fuzzy.pgm");
+#endif // LOG
+
}
// Closing.
@@ -60,6 +74,41 @@
// Watershed transform.
image2d<L> ws = morpho::watershed::flooding(clo, c4(), n_lines);
+
+# ifdef LOG
+ {
+ // Watershed line (red) over small image.
+ image2d<value::rgb8> cool = level::convert(value::rgb8(), small);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::red);
+ io::ppm::save(cool, "temp_small_ws.ppm");
+ }
+ {
+ // Watershed line (red) over fuzzy image.
+ image2d<value::rgb8> cool = level::convert(value::rgb8(), fuzzy);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::red);
+ io::ppm::save(cool, "temp_fuzzy_ws.ppm");
+ }
+ {
+ // Watershed basins colorize the small image.
+ image2d<value::rgb8> cool = debug::colorize(value::rgb8(), ws, n_lines);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::white);
+ mln_piter(box2d) p(small.domain());
+ for_all(p)
+ {
+ if (small(p) == 255)
+ continue;
+ float f = float(small(p)) / 255;
+ cool(p).red() = cool(p).red() * f;
+ cool(p).green() = cool(p).green() * f;
+ cool(p).blue() = cool(p).blue() * f;
+ }
+ io::ppm::save(cool, "temp_ws.ppm");
+ }
+# endif
+
return ws;
}
Index: icdar/2009/hsc/ws_to_wsl.hh
--- icdar/2009/hsc/ws_to_wsl.hh (revision 3691)
+++ icdar/2009/hsc/ws_to_wsl.hh (working copy)
@@ -44,25 +44,6 @@
{
- algebra::mat<1,2,float>
- trans(const algebra::vec<2,float>& v)
- {
- algebra::mat<1,2,float> tmp;
- tmp(0,0) = v[0];
- tmp(0,1) = v[1];
- return tmp;
- }
-
- algebra::mat<2,1,float>
- to_mat(const algebra::vec<2,float>& v)
- {
- algebra::mat<2,1,float> tmp;
- tmp(0,0) = v[0];
- tmp(1,0) = v[1];
- return tmp;
- }
-
-
struct mahalanobis : public mln::accu::internal::base< unsigned , mahalanobis >
{
typedef point2d argument;
@@ -113,7 +94,7 @@
if (n_ == 0)
return;
mean_ /= n_;
- cov_ = cov_ / n_ - to_mat(mean_) * trans(mean_);
+ cov_ = cov_ / n_ - mean_ * mean_.t();
float
a = cov_(0, 0), b = cov_(0, 1),
@@ -174,7 +155,7 @@
{
mln_invariant(valid_);
algebra::vec<2,float> v_ = v - mean_;
- return (trans(v_) * cov_1_ * v_)[0];
+ return v_.t() * cov_1_ * v_;
}
/// Get the number of items.
@@ -397,29 +378,32 @@
#ifdef LOG
{
- io::pgm::save(small, "tmp_small.pgm");
- io::pgm::save(ws, "tmp_ws.pgm");
-
using value::rgb8;
- image2d<rgb8> small_ws = level::convert(rgb8(), small);
- data::fill((small_ws | (pw::value(ws) == pw::cst(0))).rw(),
- literal::red);
- io::ppm::save(small_ws, "tmp_small_ws.ppm");
-
fun::i2v::array<L> f_relab(n_basins + 1);
f_relab(0) = 0;
for (L l = 1; l <= n_basins; ++l)
f_relab(l) = parent[l];
image2d<L> ws_ = level::transform(ws, f_relab);
- io::ppm::save(debug::colorize(rgb8(), ws_, n_basins), "tmp_ws.ppm");
+ image2d<rgb8> cool = debug::colorize(rgb8(), ws_, n_basins);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::white);
+ mln_piter(box2d) p(small.domain());
+ for_all(p)
+ {
+ if (small(p) == 255)
+ continue;
+ float f = float(small(p)) / 255;
+ cool(p).red() = cool(p).red() * f;
+ cool(p).green() = cool(p).green() * f;
+ cool(p).blue() = cool(p).blue() * f;
+ }
+ io::ppm::save(cool, "temp_wsl.ppm");
}
#endif // LOG
-
-
// Outputing.
image2d<L> output(input.domain());
Index: jardonnet/registration/cov.hh
--- jardonnet/registration/cov.hh (revision 3691)
+++ jardonnet/registration/cov.hh (working copy)
@@ -66,7 +66,7 @@
// FIXME: ugly cast.
algebra::vec<P::dim,float> a1i = a1[i];
algebra::vec<P::dim,float> a2i = a2[i];
- Mk += make::mat(a1i - mu_a1) * trans(make::mat(a2i - mu_a2));
+ Mk += (a1i - mu_a1) * (a2i - mu_a2).t();
}
return Mk / a1.nsites();
Index: jardonnet/registration/quat7.hh
--- jardonnet/registration/quat7.hh (revision 3691)
+++ jardonnet/registration/quat7.hh (working copy)
@@ -145,8 +145,8 @@
algebra::vec<P::dim,float> Ci = C[i];
algebra::vec<P::dim,float> Xki = map(Ck[i]);
- Mk += make::mat(Ci - mu_C) * trans(make::mat(Xki - mu_Xk));
- // or Mk += make::mat(Ci) * trans(make::mat(Xki)) - make::mat(mu_C) *
trans(make::mat(mu_Xk))
+ Mk += (Ci - mu_C) * (Xki - mu_Xk).t();
+ // or Mk += Ci * Xki.t() - mu_C * mu_Xk.t()
}
Mk /= c_length;