https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add segmentation scheme for volumes.
* theo/igr: New directory.
* theo/igr/pgms2pgm.cc: New.
* theo/igr/raw2pgm.cc: New.
* theo/igr/pgms2raw.cc: New.
* theo/igr/irm_anat_segm.cc: New.
* theo/igr/irm_anat_segm__2D_ONLY.cc: New.
irm_anat_segm.cc | 60 ++++++++++++++++++++++++++++++++++++++++++++++
irm_anat_segm__2D_ONLY.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++
pgms2pgm.cc | 41 +++++++++++++++++++++++++++++++
pgms2raw.cc | 38 +++++++++++++++++++++++++++++
raw2pgm.cc | 34 ++++++++++++++++++++++++++
5 files changed, 232 insertions(+)
Index: theo/igr/pgms2pgm.cc
--- theo/igr/pgms2pgm.cc (revision 0)
+++ theo/igr/pgms2pgm.cc (revision 0)
@@ -0,0 +1,41 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " output.pgm
input1.pgm .. inputn.pgm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+ typedef image2d<int_u8> I;
+
+ if (argc < 3)
+ usage(argv);
+
+
+ util::array<I> arr;
+ for (int i = 2; i < argc; ++i)
+ {
+ I ima;
+ io::pgm::load(ima, argv[i]);
+ arr.append(ima);
+ }
+ image3d<int_u8> vol = make::image3d(arr);
+
+ int_u8 bg = 0;
+ I out = debug::slices_2d(vol, 1.f, bg);
+ io::pgm::save(out, argv[1]);
+}
Index: theo/igr/raw2pgm.cc
--- theo/igr/raw2pgm.cc (revision 0)
+++ theo/igr/raw2pgm.cc (revision 0)
@@ -0,0 +1,34 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+#include <mln/debug/slices_2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/raw/load.hh>
+#include <mln/io/pgm/save.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.raw
output.pgm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3)
+ usage(argv);
+
+ image3d<int_u8> vol;
+ io::raw::load(vol, argv[1]);
+
+ int_u8 bg = 0;
+ image2d<int_u8> ima = debug::slices_2d(vol, 1.f, bg);
+ io::pgm::save(ima, argv[2]);
+}
Index: theo/igr/pgms2raw.cc
--- theo/igr/pgms2raw.cc (revision 0)
+++ theo/igr/pgms2raw.cc (revision 0)
@@ -0,0 +1,38 @@
+
+#include <mln/core/image/image2d.hh>
+#include <mln/make/image3d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/raw/save.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " output.raw
input1.pgm .. inputn.pgm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+ typedef image2d<int_u8> I;
+
+ if (argc < 3)
+ usage(argv);
+
+
+ util::array<I> arr;
+ for (int i = 2; i < argc; ++i)
+ {
+ I ima;
+ io::pgm::load(ima, argv[i]);
+ arr.append(ima);
+ }
+ image3d<int_u8> vol = make::image3d(arr);
+ io::raw::save(vol, argv[1]);
+}
Index: theo/igr/irm_anat_segm.cc
--- theo/igr/irm_anat_segm.cc (revision 0)
+++ theo/igr/irm_anat_segm.cc (revision 0)
@@ -0,0 +1,60 @@
+
+#include <mln/core/image/image3d.hh>
+#include <mln/core/alias/neighb3d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/raw/load.hh>
+#include <mln/io/raw/save.hh>
+
+#include <mln/morpho/elementary/gradient.hh>
+#include <mln/morpho/closing_volume.hh>
+#include <mln/morpho/meyer_wst.hh>
+
+#include <mln/accu/mean.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/level/transform.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.raw
output.raw" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3)
+ usage(argv);
+
+ trace::quiet = false;
+
+ image3d<int_u8> vol, grad, clo;
+ io::raw::load(vol, argv[1]);
+
+ grad = morpho::elementary::gradient(vol, c6());
+ clo = morpho::closing_volume(grad, c6(), 666);
+
+ typedef value::label_16 L;
+ L n_basins;
+ image3d<L> wst = morpho::meyer_wst(clo, c6(), n_basins);
+
+ std::cout << n_basins << std::endl;
+
+ accu::mean<int_u8, float, int_u8> a_;
+ util::array<int_u8> a = labeling::compute(a_, vol, wst, n_basins);
+ std::cout << a << std::endl;
+ a[0] = 0;
+
+ fun::i2v::array<int_u8> f;
+ convert::from_to(a, f);
+ image3d<int_u8> out = level::transform(wst, f);
+
+ io::raw::save(out, argv[2]);
+}
Index: theo/igr/irm_anat_segm__2D_ONLY.cc
--- theo/igr/irm_anat_segm__2D_ONLY.cc (revision 0)
+++ theo/igr/irm_anat_segm__2D_ONLY.cc (revision 0)
@@ -0,0 +1,59 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/elementary/gradient.hh>
+#include <mln/morpho/closing_volume.hh>
+#include <mln/morpho/meyer_wst.hh>
+
+#include <mln/accu/mean.hh>
+#include <mln/labeling/compute.hh>
+#include <mln/fun/i2v/array.hh>
+#include <mln/level/transform.hh>
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.pgm
output.pgm" << std::endl;
+ abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+
+ if (argc != 3)
+ usage(argv);
+
+ trace::quiet = false;
+
+ image2d<int_u8> vol, grad, clo;
+ io::pgm::load(vol, argv[1]);
+
+ grad = morpho::elementary::gradient(vol, c4());
+ clo = morpho::closing_volume(grad, c4(), 666);
+
+ typedef value::label_16 L;
+ L n_basins;
+ image2d<L> wst = morpho::meyer_wst(clo, c4(), n_basins);
+
+ std::cout << n_basins << std::endl;
+
+ accu::mean<int_u8, float, int_u8> a_;
+ util::array<int_u8> a = labeling::compute(a_, vol, wst, n_basins);
+ std::cout << a << std::endl;
+ a[0] = 0;
+
+ fun::i2v::array<int_u8> f;
+ convert::from_to(a, f);
+ image2d<int_u8> out = level::transform(wst, f);
+
+ io::pgm::save(out, argv[2]);
+}