URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-23 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update binarization test with projected histograms.
* fabien/binarization/test.cc: Update.
* fabien/igr/Makefile: Update.
* fabien/igr/matlab.cc: Update.
---
TODO | 5 ++-
binarization/test.cc | 72 ++++++++++++++++++++++++++++++++++++++++++++-------
igr/Makefile | 27 +++++++++----------
igr/matlab.cc | 13 ++++++---
4 files changed, 89 insertions(+), 28 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/matlab.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3560)
+++ trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3561)
@@ -105,7 +105,7 @@
// Calcul du masque
image2d<bool> masque;
initialize(masque, datasli);
- data::fill(masque, false)
+ 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)
@@ -114,8 +114,8 @@
// 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);
+ 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
@@ -143,14 +143,19 @@
// FIXME: [c,T]=max(image,[ ],3);
+ // Ou 'ima_c' est la valeur du max et 'ima_t' son index, le long de la
dimension 3
+ // kk est le nombre de points masques
+
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]);
-
ima_auc accu::image::to_result(result);
+ // Conversion du temps du pic en secondes à partir fin période de base
+ tmax = acqui * (ima_t - ini);
+
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3560)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3561)
@@ -1,3 +1,4 @@
+CXX = llvm-g++
DCM_SRC=/Users/HiSoKa/Downloads/gdcm-2.0.10
DCM_BIN=/Users/HiSoKa/Downloads/gdcmbin
DICOM_INC = -I${DCM_SRC}/Source/Common/ \
@@ -13,43 +14,43 @@
all: 2d 3d wsd2d wsd3d grad
2d: seg_vol_irm.hh seg2d.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg2d.cc -o seg2d
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg2d.cc -o seg2d
3d: seg_vol_irm.hh seg3d.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg3d.cc -o seg3d
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg3d.cc -o seg3d
wsd2d: watershed.hh watershed2d.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd2d
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd2d
wsd3d: watershed.hh watershed3d.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd3d
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd3d
wsd3dg: watershed.hh watershed3d.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} -g $^ -o wsd3dg
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} -g $^ -o wsd3dg
nbasins: nbasins_finder.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o nbasins_finder
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o nbasins_finder
grad: grad.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o grad
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o grad
clo_vol: clo_vol.cc
- g++ -I../../../ ${CXXFLAGS} $^ -o clo_vol
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o clo_vol
wst: wst.cc
- g++ -I../../../ ${CXXFLAGS} $^ -o wst
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o wst
graph: graph.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o graph
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o graph
med: med.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o med
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o med
thres: thres.cc
- g++ -I../../../ ${CXXFLAGS} $^ -o thres
+ ${CXX} -I../../../ ${CXXFLAGS} $^ -o thres
matlab: matlab.cc
- g++ -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} -lm $^ -o matlab
+ ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} -lm $^ -o matlab
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3560)
+++ trunk/milena/sandbox/fabien/TODO (revision 3561)
@@ -40,5 +40,6 @@
[ ] Integrate external libraries (GDCM, IM)
[ ] Send result images to lrde account
[ ] Translate Matlab code
-[ ] Subsample binary images
-[ ] Fast projected histogram
+[X] Subsample binary images
+[X] Fast projected histogram
+[ ] Triple histogram
Index: trunk/milena/sandbox/fabien/binarization/test.cc
===================================================================
--- trunk/milena/sandbox/fabien/binarization/test.cc (revision 3560)
+++ trunk/milena/sandbox/fabien/binarization/test.cc (revision 3561)
@@ -1,16 +1,30 @@
#include <iostream>
#include <fstream>
+#include <mln/algebra/vec.hh>
+
#include <mln/core/image/image1d.hh>
#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/neighb1d.hh>
+
+#include <mln/draw/line.hh>
#include <mln/io/magick/load.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/io/pbm/save.hh>
#include <mln/level/stretch.hh>
+#include <mln/make/box2d.hh>
+
+#include <mln/morpho/closing/volume.hh>
+#include <mln/morpho/watershed/flooding.hh>
+
+#include <mln/util/couple.hh>
+
#include <mln/value/int_u8.hh>
#include <mln/value/int_u12.hh>
+#include <mln/value/label_16.hh>
#include <mln/world/binary_2d/projected_histo.hh>
#include <mln/world/binary_2d/subsample.hh>
@@ -19,6 +33,9 @@
using namespace mln;
using value::int_u8;
using value::int_u12;
+using value::label_16;
+
+
int main(int argc, char* argv[])
{
@@ -31,24 +48,61 @@
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]);
+ //image2d<int_u8> ima_sampled = world::binary_2d::subsample(ima, 3);
+ //io::pgm::save(ima_sampled, argv[2]);
+
+ box2d left_box = make::box2d(0, 0, ima.nrows() - 1, (ima.ncols() / 3));
+ util::couple<image1d<float>, image1d<float> > histos_left =
world::binary_2d::projected_histo(ima | left_box);
+
+ box2d middle_box = make::box2d(0, (ima.ncols() / 3), ima.nrows() - 1, (2 * ima.ncols()
/ 3));
+ util::couple<image1d<float>, image1d<float> > histos_middle =
world::binary_2d::projected_histo(ima | middle_box);
+
+ box2d right_box = make::box2d(0, (2 * ima.ncols() / 3), ima.nrows() - 1, ima.ncols() -
1);
+ util::couple<image1d<float>, image1d<float> > histos_right =
world::binary_2d::projected_histo(ima | right_box);
+
+ image1d<float> row_histo = histos_right.first();
+ image1d<float> col_histo = histos_right.second();
+
+ int i = col_histo.ninds();
+ while (i > 0 && col_histo.at_(i) < 60.0)
+ {
+ col_histo.at_(i) = 100.0;
+ --i;
+ }
+
+ // Closing
+ row_histo = morpho::closing::volume(row_histo, c2(), 31);
- image1d<float> row_histo(ima.nrows());
- image1d<float> col_histo(ima.ncols());
- world::binary_2d::projected_histo(ima, row_histo, col_histo);
+ // Watershed
+ label_16 nbasins;
+ image1d<label_16> row_labels = morpho::watershed::flooding(row_histo, c2(),
nbasins);
+
+ // Draw lines
+ for (unsigned int i = 0; i < row_labels.ninds(); ++i)
+ {
+ if (row_labels.at_(i) == 0u)
+ {
+ algebra::vec<2, unsigned int> vmin;
+ algebra::vec<2, unsigned int> vmax;
+ vmin[0] = i;
+ vmin[1] = 0;
+ vmax[0] = i;
+ vmax[1] = ima.ncols() - 1;
+ mln_site_(image2d<bool>) pbeg(vmin);
+ mln_site_(image2d<bool>) pend(vmax);
+ draw::line(ima, pbeg, pend, 0);
+ }
+ }
+ io::pbm::save(ima, argv[2]);
+ // Gnuplot files creation
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;
}