URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-20 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add binarization directory for tests.
* fabien/binarization/Makefile: New.
* fabien/binarization/test.cc: New test.
* fabien/igr/matlab.cc: Update.
---
TODO | 2 +
binarization/Makefile | 10 ++++++++
binarization/test.cc | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
igr/matlab.cc | 56 ++++++++++++++++++++++++++++++++++++++------------
4 files changed, 109 insertions(+), 13 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/matlab.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3558)
+++ trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3559)
@@ -14,6 +14,8 @@
#include <mln/accu/sum.hh>
#include <mln/accu/image/all.hh>
#include <mln/arith/minus.hh>
+#include <mln/arith/plus.hh>
+#include <mln/arith/times.hh>
#include <mln/data/fill.hh>
#include <mln/data/paste.hh>
#include <mln/level/compute.hh>
@@ -101,26 +103,54 @@
float seuil = fseuil * ectys;
// Calcul du masque
- image2d<bool> masque; // FIXME: init this ROI, should be a domain
+ image2d<bool> masque;
initialize(masque, datasli);
data::fill(masque, false)
data::fill(masque | pw::value(datasli) > pw::cst(seuil), true);
// si on a choisi une région avec roi2
if (nargin>2)
- masque=masque.*roi2;
+ data::fill(masque | pw::value(roi2) == false, false);
- //on applique le masque sur image et imasoustraite
+ // On applique le masque sur image et imasoustraite
+ for (int k = 0; k < arr_ima.nelements(); ++k)
+ {
+ data::fill(arr_ima[k] | pw::value(masque) == false; 0.0);
+ data::fill(arr_sous[k] | pw::value(masque) == false; 0.0);
+ }
+
+ // On regarde si le seuillage et le masquage sont OK
+ // FIXME: imagesc(abs(image(:,:,2)));
+
+ // On cherche les maxi (intensité c et temps T) des courbes signal(temps)
+ // On masque toute la série d'images
+
+ // Essai de lissage à parir de fin de montée vaculaire ini2 pour ameliorer
+ // les seuillages a 10 50 90 NON EVALUE RIGOUREUSEMENT
+ for (int k = init2 - 1; k < dim3 - 1; ++k)
+ arr_ima[k] = 0.5 * arr_ima[k] + 0.25 * arr_ima[k - 1] + 0.25 * arr_ima[k + 1];
+
+ for_all(p)
+ {
+ if (masque(p) == false)
+ {
+ for (int k = 0; k < arr_ima.nelements(); ++k)
+ arr_ima[k](p) = 0.0;
+ ima_c(p) = 0.0;
+ ima_t(p) = 0.0;
+ ++kk;
+ }
+ }
+
+ // FIXME: [c,T]=max(image,[ ],3);
+
+ std::cout << "kk = " << kk << std::endl;
+
+ image2d<accu::sum<float> > accu_sum;
+ accu::image::init(result);
+ for (int i = first; i < last; ++i)
+ accu::image::take(result, arr_ima[i]);
- for k=2:dim3
- for i=1:dim1
- for j=1:dim2
- if(masque(i,j)==0)
- image(i,j,k)=0;
- imasoustraite(i,j,k)=0;
- end;
- end;
- end;
- end;
+ ima_auc accu::image::to_result(result);
return 0;
}
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3558)
+++ trunk/milena/sandbox/fabien/TODO (revision 3559)
@@ -40,3 +40,5 @@
[ ] Integrate external libraries (GDCM, IM)
[ ] Send result images to lrde account
[ ] Translate Matlab code
+[ ] Subsample binary images
+[ ] Fast projected histogram
Index: trunk/milena/sandbox/fabien/binarization/test.cc
===================================================================
--- trunk/milena/sandbox/fabien/binarization/test.cc (revision 0)
+++ trunk/milena/sandbox/fabien/binarization/test.cc (revision 3559)
@@ -0,0 +1,54 @@
+#include <iostream>
+#include <fstream>
+
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/magick/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/stretch.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+
+#include <mln/world/binary_2d/projected_histo.hh>
+#include <mln/world/binary_2d/subsample.hh>
+
+
+using namespace mln;
+using value::int_u8;
+using value::int_u12;
+
+int main(int argc, char* argv[])
+{
+ if (argc != 3)
+ {
+ std::cout << "Usage: " << argv[0] << "input.ext
output.pgm" << std::endl;
+ return 1;
+ }
+
+ image2d<bool> ima;
+ io::magick::load(ima, argv[1]);
+
+ image2d<int_u8> ima_sampled = world::binary_2d::subsample(ima, 3);
+ io::pgm::save(ima_sampled, argv[2]);
+
+ image1d<float> row_histo(ima.nrows());
+ image1d<float> col_histo(ima.ncols());
+ world::binary_2d::projected_histo(ima, row_histo, col_histo);
+
+ std::ofstream fout_row("row.plot");
+ for (unsigned int i = 0; i < row_histo.ninds(); ++i)
+ {
+ fout_row << i << " " << row_histo.at_(i) <<
std::endl;
+ }
+
+ std::ofstream fout_col("col.plot");
+ for (unsigned int i = 0; i < col_histo.ninds(); ++i)
+ {
+ fout_col << i << " " << col_histo.at_(i) <<
std::endl;
+ }
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/binarization/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/binarization/Makefile (revision 0)
+++ trunk/milena/sandbox/fabien/binarization/Makefile (revision 3559)
@@ -0,0 +1,10 @@
+GCCFLAGS = -DNDEBUG -O1
+LLVMFLAGS = -DNDEBUG -O4
+
+all: gcc llvm
+
+gcc: test.cc
+ g++ -I../../../ `Magick++-config --cppflags --cxxflags --ldflags --libs` ${GCCFLAGS}
test.cc -o test_gcc
+
+llvm: test.cc
+ llvm-g++ -I../../../ `Magick++-config --cppflags --cxxflags --ldflags --libs`
${LLVMFLAGS} test.cc -o test_llvm