URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-29 Etienne FOLIO <folio(a)lrde.epita.fr>
Histograms update.
* folio/mln/histo/compute_histo.hh: Some brainstorming.
* folio/mln/histo/compute_histo_3d.hh: Some corrections from compute_histo.
---
compute_histo.hh | 60 +++++++++++++++++++++++++++++++++++-----------------
compute_histo_3d.hh | 34 +++++++++++++++++++++++------
2 files changed, 68 insertions(+), 26 deletions(-)
Index: trunk/milena/sandbox/folio/mln/histo/compute_histo.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/histo/compute_histo.hh (revision 3724)
+++ trunk/milena/sandbox/folio/mln/histo/compute_histo.hh (revision 3725)
@@ -6,42 +6,64 @@
#include <mln/core/image/image.hh>
#include <mln/trait/value/comp.hh>
-#include <mln/trait/image_from_grid.hh>
-
namespace mln
{
namespace histo
{
- template <typename C, typename I>
- Image<C> compute_histo(Image<I> ima_)
+ template <typename I>
+ struct compute_histo
+ {
+ Image<unsigned> operator()(const Image<I>& ima_) const;
+
+ namespace internal
+ {
+ }
+
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename I>
+ inline
+ ImageNd<dim, unsigned> // ? dim? imageNd?
+ operator()(const Image<I>& ima_) const
{
I ima = exact(ima);
typedef mln_value(I) V;
- typedef mln_regular_grid_from_dim(V::dim + 1) G;
- typedef mln_image_from_grid(G, C) O;
- O out;
- for (unsigned i = 0; i < V::dim + 1; ++i)
+ // Create image Nd from value types of ima.
+ algebra::vec<V::dim, unsigned> pmin, pmax;
+ for (unsigned i = 0; i < V::dim; ++i)
{
- typedef mln_trait_value_comp(I, i)::enc enc[i];
- // FIXME: define here the domain of `out'.
- // out(mln_max(enc[0]) + abs(mln_min(enc[0])) + 1,
- // mln_max(enc[1]) + abs(mln_min(enc[1])) + 1,
- // mln_max(enc[2]) + abs(mln_min(enc[2])) + 1);
+ typedef mln_trait_value_comp(V, i)::enc enc;
+ pmin[i] = mln_min(enc);
+ pmax[i] = mln_max(enc);
}
- data::fill(out, mln_min(C));
- // count
+ typedef box<site> _box; // ? site?
+ _box box(pmin, pmax);
+ ImageNd<V::dim, unsigned> out(box); // ? ImageNd?
+
+
+ // Count occurences.
+ data::fill(out, 0);
+
mln_fwd_piter(box2d) p(ima.domain());
for_all(p)
- // FIXME: call macro comp()?
- // FIXME: pointnd
- ++out(point3d(ima(p).comp(0), ima(p).comp(1), ima(p).comp(2)));
+ {
+ algebra::vec<V::dim, site> // ? site?
+ for (unsigned i = 0; i < V::dim; ++i)
+ // comp() not implemented everywhere!
+ pt[i] = ima(p).comp(i);
+ ++out(pointNd(pt)); // ? pointNd?
+ }
- // return
return out;
}
+# endif // !MLN_INCLUDE_ONLY
+
}
}
Index: trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh
===================================================================
--- trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh (revision 3724)
+++ trunk/milena/sandbox/folio/mln/histo/compute_histo_3d.hh (revision 3725)
@@ -12,27 +12,47 @@
namespace histo
{
- template <typename C, typename T>
- image3d<C> compute_histo_3d(image2d<T> ima)
+ template <typename T>
+ struct compute_histo_3d
+ {
+ image3d<unsigned> operator()(const image2d<T>& ima) const;
+
+ namespace internal
+ {
+ }
+
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ image3d<unsigned>
+ operator()(const image2d<T>& ima) const
{
- // out
typedef mln_trait_value_comp(T, 0)::enc enc_0;
typedef mln_trait_value_comp(T, 1)::enc enc_1;
typedef mln_trait_value_comp(T, 2)::enc enc_2;
- image3d<C> out(mln_max(enc_0) + abs(mln_min(enc_0)) + 1,
+
+ // FIXME: wrong for negative sites!
+ image3d<unsigned> out(mln_max(enc_0) + abs(mln_min(enc_0)) + 1,
mln_max(enc_1) + abs(mln_min(enc_1)) + 1,
mln_max(enc_2) + abs(mln_min(enc_2)) + 1);
- data::fill(out, mln_min(C));
- // count
+ // Count occurences.
+ data::fill(out, 0);
+
mln_fwd_piter(box2d) p(ima.domain());
for_all(p)
- // FIXME: call macro comp()?
+ // comp() not implemented everywhere!
++out(point3d(ima(p).comp(0), ima(p).comp(1), ima(p).comp(2)));
// return
return out;
}
+# endif // !MLN_INCLUDE_ONLY
+
}
}