https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
INIM Classification++.
* classif/iccvg04.cc: Revamp + Area Closure.
* classif/plotscript: Basic plotting script.
* classif/chiche.pgm: Revamp chiche.
iccvg04.cc | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++----------
plotscript | 4 ++++
2 files changed, 55 insertions(+), 10 deletions(-)
Index: classif/iccvg04.cc
--- classif/iccvg04.cc (revision 2556)
+++ classif/iccvg04.cc (working copy)
@@ -1,4 +1,3 @@
-
#include <iostream>
#include <mln/core/image/image2d.hh>
@@ -7,6 +6,10 @@
#include <mln/value/all.hh>
#include <mln/level/fill.hh>
+#include <mln/morpho/closing_area.hh>
+#include <mln/arith/revert.hh>
+#include <mln/morpho/meyer_wst.hh>
+#include <mln/core/alias/neighb2d.hh>
#include <mln/io/ppm/load.hh>
@@ -14,12 +17,15 @@
using namespace mln;
+unsigned max = 0;
+
template <typename I>
mln::image3d<unsigned>
fill_histo(const I& ima)
{
image3d<unsigned> histo(256,256,256);
level::fill(histo, 0);
+ unsigned i = 0;
mln_piter(I) p(ima.domain());
for_all(p)
@@ -30,21 +36,56 @@
return histo;
}
-int main(int argc, char **argv)
+template <typename I>
+void gplot(const I& ima)
{
- image2d<value::rgb8> ima;
- ima = io::ppm::load<value::rgb8>(argv[1]);
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ {
+ if (ima(p) != 0)
+ std::cout << p[0] << ' ' << p[1] << ' '
<< p[2] << std::endl;
+ }
+}
- image3d<unsigned> histo = fill_histo(ima);
+template <typename I>
+void display_proj(const I& histo)
+{
+ image2d< unsigned long long > proj_histo(256,256);
+ level::fill(proj_histo, 0);
- image2d< value::int_u16 > out(256,256);
- level::fill(out, 0);
- mln_piter_(image2d< value::int_u16 >) p(out.domain());
+ mln_piter_(image2d< unsigned long long >) p(proj_histo.domain());
+ double max = 0;
for_all(p)
{
for (unsigned i = 0; i < 256; i++)
- if ((out(p) + histo(point3d(p[0],p[1],i))) < 65536)
- out(p) += histo(point3d(p[0],p[1],i));
+ proj_histo(p) += histo(point3d(p[0], p[1], i));
+
+ if (proj_histo(p) > max)
+ max = proj_histo(p);
+ }
+
+ image2d< value::int_u8 > out(256, 256);
+ for_all(p)
+ {
+ out(p) = (proj_histo(p) / max) * 255;
}
+
io::pgm::save(out,"./chiche.pgm");
}
+
+int main(int argc, char **argv)
+{
+ image2d<value::rgb8> ima;
+ ima = io::ppm::load<value::rgb8>(argv[1]);
+
+ image3d<unsigned> histo = fill_histo(ima);
+
+ histo = arith::revert(histo);
+ image3d<value::int_u8> histo_closed(histo.domain());
+
+ morpho::closing_area(histo, c4(), 510, histo_closed);
+
+ //display_proj(arith::revert(histo));
+
+ //display_proj(histo);
+}
Index: classif/plotscript
--- classif/plotscript (revision 0)
+++ classif/plotscript (revision 0)
@@ -0,0 +1,4 @@
+set xlabel "red"
+set ylabel "green"
+set zlabel "blue"
+splot "plot"
Index: classif/chiche.pgm
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream