Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
March 2009
- 9 participants
- 202 discussions
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-27 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update IGR related code.
* fabien/igr/Makefile: Update.
* fabien/igr/matlab.cc: Update.
* fabien/igr/time_max.cc: Create tmax image.
---
TODO | 5
igr/Makefile | 46 +++-----
igr/matlab.cc | 296 ++++++++++++++++++++++++++++++++++----------------------
igr/time_max.cc | 113 +++++++++++++++++++++
4 files changed, 318 insertions(+), 142 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/matlab.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3584)
+++ trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3585)
@@ -36,6 +36,8 @@
mln_precondition(first >=0 && first < arr_ima.nelements());
mln_precondition(last >=0 && last < arr_ima.nelements());
+ initialize(result, arr_ima[first]);
+
accu::image::init(result);
for (int i = first; i < last; ++i)
accu::image::take(result, arr_ima[i]);
@@ -58,10 +60,10 @@
for (int i = 0; i < input.nslices(); ++i)
arr_ima.append(duplicate(cast_image<float>(slice(input, i))));
- int acqui = 3; // durée acqui et temps interimages; en secondes
- int fseuil = 4; // ratio entre signaux trop faibles, éliminés, et bruit de fond mesuré sur l image
- int ini = 9; // nombre images ligne de base
- int ini2 = 20; // a la fin de la montée vasculaire, à la dixieme image post injection: lissage des images par trois
+ const int acqui = 3; // durée acqui et temps interimages; en secondes
+ const int fseuil = 4; // ratio entre signaux trop faibles, éliminés, et bruit de fond mesuré sur l image
+ const int ini = 9; // nombre images ligne de base
+ const int ini2 = 20; // a la fin de la montée vasculaire, à la dixieme image post injection: lissage des images par trois
// Calcul signal initialmoyen : 8 images de 2 à 9 moyennées=ligne de base
image2d<float> imageini = mean_slices(arr_ima, 1, 8);
@@ -86,10 +88,19 @@
data::fill(prodsignal1, 0.0);
data::paste(datasli | pw::value(roi_noise) == pw::cst(true), prodsignal1);
- // moyenne
+ /////////////
+ // //
+ // Moyenne //
+ // //
+ /////////////
accu::mean<float> accu_mean;
float moysignal1 = level::compute(accu_mean, prodsignal1 | pw::value(roi_noise) == pw::cst(true));
- // ecart type
+
+ ////////////////
+ // //
+ // Ecart type //
+ // //
+ ////////////////
int som1 = 0;
int kk = 0;
mln_piter_(image2d<float>) p(datasli.domain());
@@ -99,11 +110,16 @@
float ectys = std::sqrt(som1 / (nbrpix1 - 1));
float seuil = fseuil * ectys;
- // Calcul du masque
+ //////////////////////
+ // //
+ // Calcul du masque //
+ // //
+ //////////////////////
image2d<bool> masque;
initialize(masque, datasli);
data::fill(masque, false);
data::fill((masque | pw::value(datasli) > pw::cst(seuil)).rw(), true);
+
// si on a choisi une région avec roi
int nargin = 0;
image2d<bool> roi; // FIXME: init this ROI, should be a domain
@@ -123,6 +139,12 @@
// On cherche les maxi (intensité ima_c et temps ima_t) des courbes signal(temps)
// On masque toute la série d'images
+ /////////////
+ // //
+ // Lissage //
+ // //
+ /////////////
+
// Essai de lissage à parir de fin de montée vaculaire ini2 pour ameliorer
// les seuillages a 10 50 90 NON EVALUE RIGOUREUSEMENT
util::array<image2d<double> > arr_smooth;
@@ -131,17 +153,33 @@
arr_smooth.append(arr_ima[k] * 0.5 + arr_ima[k - 1] * 0.25 + arr_ima[k + 1] * 0.25);
arr_smooth.append(arr_ima[dim3 - 1] * 1.0);
+ ///////////////////////////////////
+ // //
+ // Calcul image max et temps max //
+ // //
+ ///////////////////////////////////
+ image2d<float> ima_c;
+ initialize(ima_c, arr_smooth[0]);
+ data::fill(ima_c, 0.0);
+ image2d<unsigned> ima_t;
+ initialize(ima_t, ima_c);
for_all(p)
if (masque(p) == false)
{
for (int k = 0; k < arr_smooth.nelements(); ++k)
arr_smooth[k](p) = 0.0;
ima_c(p) = 0.0;
- ima_t(p) = 0.0;
+ ima_t(p) = 0;
++kk;
}
- // FIXME: [c,T]=max(image,[ ],3);
+ for_all(p)
+ for (unsigned k = 0; k < dim3; ++k)
+ if (ima_c(p) < arr_smooth[k](p))
+ {
+ ima_c(p) = arr_smooth[k](p);
+ ima_t(p) = k;
+ }
// 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
@@ -149,151 +187,179 @@
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);
+ accu::image::init(accu_sum);
+ for (int k = 0; k < dim3; ++k)
+ accu::image::take(accu_sum, arr_smooth[k]);
+ image2d<float> ima_auc = accu::image::to_result(accu_sum);
// Conversion du temps du pic en secondes à partir fin période de base
- tmax = acqui * (ima_t - ini);
+ image2d<int> tmax = acqui * (ima_t - ini);
// calcul des temps 10 et 90 et de la pente correspondante
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
+ image2d<float> ima_c10;
+ initialize(ima_c10, arr_smooth[0]);
+ data::fill(ima_c10, 0.0);
+ image2d<unsigned> ima_idx10;
+ initialize(ima_idx10, ima_c10);
+ bool set_10 = false;
+
+ image2d<float> ima_c90;
+ initialize(ima_c90, arr_smooth[0]);
+ data::fill(ima_c90, 0.0);
+ image2d<unsigned> ima_idx90;
+ initialize(ima_idx90, ima_c90);
+ bool set_90 = false;
+
+ image2d<float> ima_c50;
+ initialize(ima_c50, arr_smooth[0]);
+ data::fill(ima_c50, 0.0);
+ image2d<unsigned> ima_idx50;
+ initialize(ima_idx50, ima_c50);
+ bool set_50 = false;
+
+ image2d<bool> masque2;
+ initialize(masque2, arr_smooth[0]);
+
+ // FIXME: This could be done with a bkw_piter.
+ for_all(p)
{
- [C10(i,j),idx_10(i,j)]=max(image(i,j,:)>=0.1*c(i,j));
- [C90(i,j),idx_90(i,j)]=max(image(i,j,:)>=0.9*c(i,j));
- [C50(i,j),idx_50(i,j)]=max(image(i,j,:)>=0.5*c(i,j));
- if (idx_90(i,j)-idx_10(i,j)==0)
- masque2(i,j)=0;
- else
- masque2(i,j)=1;
+ for (unsigned k = 0; k < dim3; ++k)
+ {
+ if (!set_10 && arr_smooth[k](p) >= 0.1 * ima_c(p))
+ {
+ ima_c10(p) = arr_smooth[k](p);
+ ima_idx10(p) = k;
+ set_10 = true;
+ }
+ if (!set_90 && arr_smooth[k](p) >= 0.9 * ima_c(p))
+ {
+ ima_c90(p) = arr_smooth[k](p);
+ ima_idx90(p) = k;
+ set_90 = true;
+ }
+ if (!set_50 && arr_smooth[k](p) >= 0.5 * ima_c(p))
+ {
+ ima_c50(p) = arr_smooth[k](p);
+ ima_idx50(p) = k;
+ set_50 = true;
+ }
+ }
+ masque2(p) = (ima_idx90(p) != ima_idx10(p));
}
- // calcul MTT
+ ////////////////
+ // //
+ // Calcul MTT //
+ // //
+ ////////////////
// QUAND le signal redescent significativement après le maximum
// elimination des voxels où le signal est encore 90// du maximum en fin
// d'acquisition
+ image2d<bool> masque3;
+ initialize(masque3, masque2);
int kk2 = 0;
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
- if (image(i,j,dim3)>=0.9*c(i,j))
+ for_all(p)
+ if (arr_smooth[dim3 - 1](p) >= 0.9 * ima_c(p))
{
- masque3(i,j)=0;
- kk2=kk2+1;
+ masque3(p) = false;
+ ++kk2;
}
else
- masque3(i,j)=1;
+ masque3(p) = true;
// pour les voxels non masqués on inverse t et on cherche le max 50// a partir de la fin
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
+ util::array<image2d<float> > arr_inv;
for (int k = 0; k < dim3; ++k)
- imageinv(i,j,k)=masque3(i,j)*image(i,j,dim3+1-k);
+ {
+ arr_inv.append(arr_ima[dim3 - 1 - k]);
+ data::fill((arr_inv[k] | pw::value(masque3) == false).rw(), 0.0);
+ }
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
- if (masque3(i,j)==0)
+ image2d<float> ima_c51;
+ initialize(ima_c51, arr_smooth[0]);
+ data::fill(ima_c51, 0.0);
+ image2d<unsigned> ima_idx51;
+ initialize(ima_idx51, ima_c51);
+ bool set_51 = false;
+ for_all(p)
+ {
+ if (masque3(p))
{
- idx_51(i,j)=0;
- C51(i,j)=0;
+ for (unsigned k = 0; k < dim3; ++k)
+ if (!set_50 && arr_smooth[k](p) >= 0.8 * ima_c(p))
+ {
+ ima_c51(p) = arr_inv[k](p);
+ ima_idx51(p) = k;
+ set_51 = true;
+ }
}
else
- [C51(i,j),idx_51(i,j)]=max(imageinv(i,j,:)>=0.8*c(i,j));
+ {
+ ima_c51(p) = 0;
+ ima_idx51(p) = 0;
+ }
+ }
std::cout << "kk2 = " << kk2 << std::endl;
// Calcul MTT defini comme largeur a mi hauteur de la courbe signal(temps)
// soit t50 montant et t50 descendant
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
- if (masque(i,j)*masque2(i,j)*masque3(i,j)==0)
- MTT(i,j)=0;
- else
- MTT(i,j)=acqui*(dim3-idx_51(i,j)-idx_50(i,j));
+ image2d<int> ima_mtt;
+ initialize(ima_mtt, masque);
+ data::fill(ima_mtt, 0);
+ for_all(p)
+ if (masque(p) && masque2(p) && masque3(p))
+ ima_mtt(p) = acqui * (dim3 - ima_idx51(p) - ima_idx50(p));
// calcul de la pente 10/90 (avec delta signal=80// du maximum c(i,j) et
// delta temps =t90 -t10
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
- if (masque(i,j)*masque2(i,j)==0)
- pente(i,j)=0;
- else
- pente(i,j)=(0.8*c(i,j))/(acqui*(idx_90(i,j)-idx_10(i,j)));
+ image2d<float> ima_pente;
+ initialize(ima_pente, masque);
+ data::fill(ima_pente, 0);
+ for_all(p)
+ if (masque(p) && masque2(p))
+ ima_pente(p) = (0.8 * ima_c(p)) / (acqui * (ima_idx90(p) - ima_idx10(p)));
- // calcul pente normalisée rehaussement normalisé et AUC normalisée
- for (int i = 0; i < dim1; ++i)
- for (int j = 0; j < dim2; ++j)
- if (masque(i,j)==0)
- {
- pentenorm(i,j)=0;
- reh(i,j)=0;
- AUCnorm(i,j)=0;
- }
- else
+ ////////////////////////////////////////////////
+ // //
+ // Normalisation de la pente, du rehaussement //
+ // et de l'AUC //
+ // //
+ ////////////////////////////////////////////////
+ image2d<float> ima_pentenorm;
+ initialize(ima_pentenorm, masque);
+ data::fill(ima_pentenorm, 0);
+
+ image2d<float> ima_reh;
+ initialize(ima_reh, masque);
+ data::fill(ima_reh, 0);
+
+ image2d<float> ima_aucnorm;
+ initialize(ima_aucnorm, masque);
+ data::fill(ima_aucnorm, 0);
+
+ for_all(p)
+ if (masque(p))
{
- pentenorm(i,j)=pente(i,j)/imageini(i,j);
- reh(i,j)=c(i,j)/imageini(i,j);
- AUCnorm(i,j)=AUC(i,j)/imageini(i,j);
- }
-
- /*figure (3)
- imagesc(AUCnorm);
- title('image aire normalisée sous la courbe');
- // l'aire sous la courbe est négative là où il y a eu du bougé (bord tube)
-
-
- figure (4)
- imagesc(pentenorm);
- title('pente normalisée10-90');
-
- figure(5)
- imagesc(reh);
- title('image rehaussement relatif');
- caxis([0 5]);
- // au dela de 5 il faut réviser la dose d'agent de contraste car surdosage
-
- figure(6)
- imagesc(MTT);
- title('image MTT');
-
- figure(9)
- imagesc(idx_51);
- title('idx_51');
-
- figure(10)
- imagesc(C51);
-
- figure(7)
- imagesc(tmax);
- title('image Tmaximum');
-
- figure(8)
- subplot(2,2,1);
- imagesc(pentenorm);
- title('pente normalisée10-90');
- subplot(2,2,2)
- imagesc(reh);
- title('image rehaussement relatif');
- caxis([0 3]);
- subplot(2,2,3)
- imagesc(tmax);
- title('image Tmaximum');*/
+ ima_pentenorm(p) = ima_pente(p) / imageini(p);
+ ima_reh(p) = ima_c(p) / imageini(p);
+ ima_aucnorm(p) = ima_auc(p) / imageini(p);
+ }
// COURBE S(t)sur pixel choisi graphiquement
// Permet de voir la courbe de rehaussement d'un voxel pointé
// SI LE VOXEL EST AU BORD DU TUBE TEMOIN: UN DETECTEUR DE MOUVEMENTS
// coordonx=1:size(image,3);
- x = size(image, 1) / 2;
- y = size(image, 2) / 2;
- while (x < size(image, 1) && y < size(image, 2))
+ float x = masque.nrows() / 2;
+ float y = masque.ncols() / 2;
+ /*while (x < masque.nrows() && y < masque.ncols())
{
// la saisie du point de coordonnées x,y se fait sur la figure ouverte en
// dernier
// pour sortir: cliquer dans le gris...
// pour affichage interactif coordonnées pixel, mais en fait pas utile
- h=figure(8)
+ h=figure(8);
pixval;
// saisie coordonnées du pixel pour lequel on veut afficher la courbe de
// décroissance et le fit
@@ -305,12 +371,12 @@
// test sortie du programme
if ((coordx > size(image, 1)) | (coordy > size(image, 2)))
break;
- fprintf(1,'\n// d\t// d\t// f\t// f\n',coordx,coordy,reh(coordx,coordy),image(coordx,coordy,1));
+ fprintf(1,"\n// d\t// d\t// f\t// f\n",coordx,coordy,reh(coordx,coordy),image(coordx,coordy,1));
titi = (abs(image(coordx, coordy, :)));
tata = squeeze(titi);
- subplot(2,2,4)
+ subplot(2,2,4);
plot(tata);
- }
+ }*/
return 0;
}
Index: trunk/milena/sandbox/fabien/igr/time_max.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/time_max.cc (revision 0)
+++ trunk/milena/sandbox/fabien/igr/time_max.cc (revision 3585)
@@ -0,0 +1,113 @@
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/image/cast_image.hh>
+#include <mln/core/image/slice_image.hh>
+#include <mln/core/routine/duplicate.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u12.hh>
+
+#include <mln/io/dicom/load.hh>
+#include <mln/io/magick/save.hh>
+
+#include <mln/accu/count.hh>
+#include <mln/accu/mean.hh>
+#include <mln/accu/sum.hh>
+#include <mln/accu/image/all.hh>
+
+#include <mln/arith/minus.hh>
+#include <mln/arith/all.hh>
+
+#include <mln/data/fill.hh>
+#include <mln/data/paste.hh>
+
+#include <mln/level/compute.hh>
+#include <mln/level/stretch.hh>
+
+#include <mln/math/abs.hh>
+#include <mln/pw/all.hh>
+#include <mln/trait/concrete.hh>
+#include <mln/util/array.hh>
+
+#include <cmath>
+
+using namespace mln;
+using value::int_u8;
+
+
+inline
+image2d<float> mean_slices(util::array<image2d<float> >& arr_ima, int first, int last)
+{
+ image2d<accu::mean<float> > result;
+
+ mln_precondition(first >=0 && first < arr_ima.nelements());
+ mln_precondition(last >=0 && last < arr_ima.nelements());
+
+ initialize(result, arr_ima[first]);
+
+ accu::image::init(result);
+ for (int i = first; i < last; ++i)
+ accu::image::take(result, arr_ima[i]);
+
+ return accu::image::to_result(result);
+}
+
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ {
+ std::cout << "Usage: " << argv[0] << " input" << std::endl;
+ return 1;
+ }
+
+ image3d<value::int_u12> input;
+ io::dicom::load(input, argv[1]);
+ util::array<image2d<float> > arr_ima;
+ for (unsigned int i = 0; i < input.nslices(); ++i)
+ arr_ima.append(duplicate(cast_image<float>(slice(input, i))));
+
+ // Calcul signal initialmoyen : 8 images de 2 à 9 moyennées=ligne de base
+ image2d<float> imageini = mean_slices(arr_ima, 1, 8);
+
+ unsigned dim3 = arr_ima.nelements();
+
+ /////////////
+ // //
+ // Lissage //
+ // //
+ /////////////
+ util::array<image2d<double> > arr_smooth;
+ arr_smooth.append(arr_ima[0] * 1.0);
+ for (unsigned k = 1; k < dim3 - 1; ++k)
+ arr_smooth.append(arr_ima[k] * 0.5 + arr_ima[k - 1] * 0.25 + arr_ima[k + 1] * 0.25);
+ arr_smooth.append(arr_ima[dim3 - 1] * 1.0);
+
+ ///////////////////////////////////
+ // //
+ // Calcul image max et temps max //
+ // //
+ ///////////////////////////////////
+ image2d<float> ima_c;
+ initialize(ima_c, arr_smooth[0]);
+ data::fill(ima_c, 0.0);
+ image2d<unsigned> ima_t;
+ initialize(ima_t, ima_c);
+ data::fill(ima_c, 0);
+ mln_piter_(image2d<float>) p(ima_c.domain());
+ for_all(p)
+ for (unsigned k = 0; k < dim3; ++k)
+ if (ima_c(p) < arr_ima[k](p))
+ {
+ ima_c(p) = arr_ima[k](p);
+ ima_t(p) = k;
+ }
+
+ image2d<int_u8> result_c = level::stretch(int_u8(), ima_c);
+ image2d<int_u8> result_t = level::stretch(int_u8(), ima_t);
+ io::magick::save(result_c, "result_max.png");
+ io::magick::save(result_t, "result_time.png");
+
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/igr/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/igr/Makefile (revision 3584)
+++ trunk/milena/sandbox/fabien/igr/Makefile (revision 3585)
@@ -1,38 +1,30 @@
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/ \
- -I${DCM_BIN}/Source/Common/ \
- -I${DCM_SRC}/Source/DataDictionary/ \
- -I${DCM_SRC}/Source/MediaStorageAndFileFormat/ \
- -I${DCM_SRC}/Source/DataStructureAndEncodingDefinition/
-DICOM_LIBS = -L${DCM_BIN}/bin \
- -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
+CXXFLAGS = -DNDEBUG -O4
+
+DICOM_INC = -I/usr/local/include/gdcm-2.0
+DICOM_LIBS = -lgdcmCommon -lgdcmDICT -lgdcmDSED -lgdcmIOD -lgdcmMSFF -lgdcmexpat -lgdcmjpeg12 -lgdcmjpeg16 -lgdcmjpeg8 -lgdcmopenjpeg -lgdcmuuid -lgdcmzlib \
-framework CoreFoundation
-CXXFLAGS = -DNDEBUG -O1
+DICOM = ${DICOM_INC} ${DICOM_LIBS}
-all: 2d 3d wsd2d wsd3d grad
+MAGICK = `Magick++-config --cppflags --ldflags --libs`
-2d: seg_vol_irm.hh seg2d.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg2d.cc -o seg2d
+seg2d: seg_vol_irm.hh seg2d.cc
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} seg2d.cc -o seg2d
-3d: seg_vol_irm.hh seg3d.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} seg3d.cc -o seg3d
+seg3d: seg_vol_irm.hh seg3d.cc
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} seg3d.cc -o seg3d
wsd2d: watershed.hh watershed2d.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd2d
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o wsd2d
wsd3d: watershed.hh watershed3d.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o wsd3d
-
-wsd3dg: watershed.hh watershed3d.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} -g $^ -o wsd3dg
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o wsd3d
nbasins: nbasins_finder.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o nbasins_finder
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o nbasins_finder
grad: grad.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o grad
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o grad
clo_vol: clo_vol.cc
${CXX} -I../../../ ${CXXFLAGS} $^ -o clo_vol
@@ -41,16 +33,20 @@
${CXX} -I../../../ ${CXXFLAGS} $^ -o wst
graph: graph.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o graph
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o graph
med: med.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} $^ -o med
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} $^ -o med
thres: thres.cc
${CXX} -I../../../ ${CXXFLAGS} $^ -o thres
matlab: matlab.cc
- ${CXX} -I../../../ ${DICOM_INC} ${DICOM_LIBS} ${CXXFLAGS} -lm $^ -o matlab
+ ${CXX} -I../../../ ${DICOM} ${CXXFLAGS} -lm $^ -o matlab
+
+time_max: time_max.cc
+ ${CXX} -I../../../ ${DICOM} ${MAGICK} ${CXXFLAGS} -lm $^ -o time_max
clean:
rm -rf *.dump *.p?m *.plot *.log *.csv *.dSYM
+ rm seg2d seg3d wsd2d wsd3d nbasins_finder grad clo_vol wst graph med thres matlab time_max
Index: trunk/milena/sandbox/fabien/TODO
===================================================================
--- trunk/milena/sandbox/fabien/TODO (revision 3584)
+++ trunk/milena/sandbox/fabien/TODO (revision 3585)
@@ -36,10 +36,11 @@
[X] 3D
[X] Print nb bg regions // nb fg objets
[ ] Profile for performance
-[ ] ImageMagick support
+[X] ImageMagick support
[ ] Integrate external libraries (GDCM, IM)
[ ] Send result images to lrde account
-[ ] Translate Matlab code
+[X] Translate Matlab code
[X] Subsample binary images
[X] Fast projected histogram
[ ] Triple histogram
+[ ] Create plot for each kind of point with each method
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add ICDAR-related code.
* theo/icdar/dibco/wst-based.sh: New.
* theo/icdar/hsc/boxes.cc: New.
* theo/icdar/hsc/main.cc: New.
dibco/wst-based.sh | 8 +
hsc/boxes.cc | 102 ++++++++++++++
hsc/main.cc | 385 +++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 495 insertions(+)
Index: theo/icdar/dibco/wst-based.sh
--- theo/icdar/dibco/wst-based.sh (revision 0)
+++ theo/icdar/dibco/wst-based.sh (revision 0)
@@ -0,0 +1,8 @@
+#! /bin/zsh
+
+./+bin/elementary_gradient $1 1 tmp_grad.pgm
+./+bin/closing_volume tmp_grad.pgm 500 tmp_clo.pgm
+./+bin/watershed_flooding tmp_clo.pgm tmp_wst.pgm
+./+bin/watershed_superpose $1 tmp_wst.pgm ${1%pgm}ppm
+
+rm tmp_grad.pgm tmp_clo.pgm tmp_wst.pgm
Property changes on: theo/icdar/dibco/wst-based.sh
___________________________________________________________________
Added: svn:executable
+ *
Index: theo/icdar/hsc/boxes.cc
--- theo/icdar/hsc/boxes.cc (revision 0)
+++ theo/icdar/hsc/boxes.cc (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#include <iostream>
+
+#include <mln/essential/2d.hh>
+#include <mln/debug/colorize.hh>
+#include <mln/debug/println.hh>
+
+#include <scribo/text/extract_bboxes.hh>
+#include <scribo/text/grouping/group_with_single_left_link.hh>
+#include <scribo/text/grouping/group_with_single_right_link.hh>
+#include <scribo/debug/save_linked_textbboxes_image.hh>
+#include <scribo/text/grouping/group_from_double_link.hh>
+#include <scribo/filter/small_components.hh>
+
+#include <scribo/debug/save_textbboxes_image.hh>
+#include <scribo/make/debug_filename.hh>
+
+#include <mln/logical/not.hh>
+#include <mln/io/dump/save.hh>
+
+
+int usage(const char *name)
+{
+ std::cout << "Usage: " << name << " input.pbm output.dump" << std::endl;
+ return 1;
+}
+
+
+int main(int argc, char* argv[])
+{
+ using namespace scribo;
+ using namespace mln;
+
+ if (argc != 3)
+ return usage(argv[0]);
+
+ scribo::make::internal::debug_filename_prefix = "extract_text_double_link";
+
+ image2d<bool> input;
+ io::pbm::load(input, argv[1]);
+
+ logical::not_inplace(input);
+
+ value::label_16 nbboxes;
+ scribo::util::text<image2d<value::label_16> >
+ text = text::extract_bboxes(input, c8(), nbboxes);
+
+ text = filter::small_components(text,4);
+
+ mln::util::array<unsigned>
+ left_link = text::grouping::group_with_single_left_link(text, 100),
+ right_link = text::grouping::group_with_single_right_link(text, 100);
+
+ std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
+
+
+ scribo::debug::save_linked_textbboxes_image(input,
+ text, left_link, right_link,
+ literal::red, literal::cyan, literal::yellow,
+ literal::green,
+ scribo::make::debug_filename("links.ppm"));
+
+ // Validation.
+ scribo::util::text<image2d<value::label_16> > grouped_text
+ = text::grouping::group_from_double_link(text, left_link, right_link);
+
+ std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
+
+ io::dump::save(grouped_text.label_image(), argv[2]);
+
+ scribo::debug::save_textbboxes_image(input, grouped_text.bboxes(),
+ literal::red,
+ scribo::make::debug_filename("boxes.ppm"));
+
+}
+
Index: theo/icdar/hsc/main.cc
--- theo/icdar/hsc/main.cc (revision 0)
+++ theo/icdar/hsc/main.cc (revision 0)
@@ -0,0 +1,385 @@
+#include <set>
+#include <vector>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image_if.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/pw/all.hh>
+#include <mln/data/fill.hh>
+#include <mln/level/saturate.hh>
+#include <mln/level/convert.hh>
+#include <mln/arith/revert.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/literal/colors.hh>
+#include <mln/debug/colorize.hh>
+
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/world/binary_2d/subsample.hh>
+
+#define MLN_FLOAT double
+#include <sandbox/theo/exec/gaussian_directional_2d.hh>
+
+#include <mln/morpho/closing/structural.hh>
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/accu/stat/variance.hh>
+
+
+
+namespace mln
+{
+
+
+ template <typename L>
+ inline
+ L find_root_(std::vector<L>& parent, L l)
+ {
+ if (parent[l] == l)
+ return l;
+ return parent[l] = find_root_(parent, parent[l]);
+ }
+
+
+
+ template <typename L>
+ image2d<L>
+ merge(const image2d<value::int_u8>& ima,
+ const image2d<L>& ws,
+ L n,
+ unsigned n_min_stats)
+ {
+ typedef accu::stat::variance<float> A;
+ std::vector<A>
+ vvar(n + 1),
+ hvar(n + 1);
+
+ mln_piter(box2d) p(ima.domain());
+ for_all(p)
+ if (ima(p) != 255 && ws(p) != 0)
+ vvar[ws(p)].take(255 - ima(p), p.row());
+
+
+ image2d<bool>
+ radj(n + 1, n + 1),
+ ladj(n + 1, n + 1);
+ data::fill(radj, false);
+ data::fill(ladj, false);
+
+ for_all(p) if (ws(p) == 0)
+ {
+ if (ws(p + left) == 0 || ws(p + right) == 0)
+ // ws is horizontal => forget it
+ continue;
+ L l1 = ws(p + left),
+ l2 = ws(p + right);
+ if (l1 == 0 || l2 == 0 || l2 == l1)
+ continue;
+ radj.at_(l1, l2) = true;
+ ladj.at_(l2, l1) = true;
+ }
+
+ std::vector<L>
+ best_right(n + 1, 0),
+ best_left(n + 1, 0);
+ L best_l2;
+ float best_score;
+
+ for (L l1 = 1; l1 <= n; ++l1)
+ {
+ if (! vvar[l1].is_valid() || vvar[l1].n_items() < n_min_stats)
+ // Non significative stats.
+ continue;
+
+
+ // Look right.
+
+# ifdef LOG
+ std::cout << l1 << ": ";
+# endif
+
+ best_l2 = 0;
+ best_score;
+
+ for (L l2 = 1; l2 <= n; ++l2)
+ {
+ if (! radj.at_(l1, l2)) // l1 -> l2
+ continue;
+
+ if (! vvar[l2].is_valid() || vvar[l2].n_items() < n_min_stats)
+ // Non significative stats.
+ continue;
+
+# ifdef LOG
+ std::cout << l2 << ' ';
+# endif
+
+ float vm, vM, sm, sM;
+ if (vvar[l1].mean() < vvar[l2].mean())
+ {
+ vm = vvar[l1].mean();
+ sm = vvar[l1].standard_deviation();
+ vM = vvar[l2].mean();
+ sM = vvar[l2].standard_deviation();
+ }
+ else
+ {
+ vm = vvar[l2].mean();
+ sm = vvar[l2].standard_deviation();
+ vM = vvar[l1].mean();
+ sM = vvar[l1].standard_deviation();
+ }
+
+ float score = (vm - sm) - (vM - sM);
+# ifdef LOG
+ std::cout << '(' << score << "), ";
+# endif
+ if (best_l2 == 0 || score > best_score)
+ {
+ best_score = score;
+ best_l2 = l2;
+ }
+ }
+
+ if (best_l2 != 0)
+ {
+ best_right[l1] = best_l2;
+# ifdef LOG
+ std::cout << " ... " << l1 << " -> " << best_l2 << std::endl;
+# endif
+ }
+
+ // Look left.
+
+# ifdef LOG
+ std::cout << l1 << ": ";
+# endif
+
+ best_l2 = 0;
+ best_score;
+
+ for (L l2 = 1; l2 <= n; ++l2)
+ {
+ if (! ladj.at_(l1, l2)) // l2 <- l1
+ continue;
+
+ if (! vvar[l2].is_valid() || vvar[l2].n_items() < n_min_stats)
+ // Non significative stats.
+ continue;
+
+# ifdef LOG
+ std::cout << l2 << ' ';
+# endif
+
+ float vm, vM, sm, sM;
+ if (vvar[l1].mean() < vvar[l2].mean())
+ {
+ vm = vvar[l1].mean();
+ sm = vvar[l1].standard_deviation();
+ vM = vvar[l2].mean();
+ sM = vvar[l2].standard_deviation();
+ }
+ else
+ {
+ vm = vvar[l2].mean();
+ sm = vvar[l2].standard_deviation();
+ vM = vvar[l1].mean();
+ sM = vvar[l1].standard_deviation();
+ }
+
+ float score = (vm - sm) - (vM - sM);
+# ifdef LOG
+ std::cout << '(' << score << "), ";
+# endif
+
+ if (best_l2 == 0 || score > best_score)
+ {
+ best_score = score;
+ best_l2 = l2;
+ }
+ }
+
+ if (best_l2 != 0)
+ {
+ best_left[l1] = best_l2;
+# ifdef LOG
+ std::cout << " ... " << best_l2 << " <- " << l1 << std::endl;
+# endif
+ }
+
+ }
+
+
+ std::vector<L> parent(n + 1);
+ for (L l = 0; l <= n; ++l)
+ parent[l] = l;
+
+ for (L l1 = 1; l1 <= n; ++l1)
+ {
+ L l2 = best_right[l1];
+ if (l2 == 0)
+ continue;
+ if (best_left[l2] == l1)
+ {
+ // cross-validation
+ L l1r = find_root_(parent, l1),
+ l2r = find_root_(parent, l2);
+ if (l2r == l1r)
+ continue; // already merged
+ if (l1r < l2r)
+ parent[l1r] = l2r;
+ else
+ parent[l2r] = l1r;
+ }
+ }
+
+
+ for (L l = 1; l <= n; ++l)
+ parent[l] = find_root_(parent, l);
+
+
+ image2d<L> out(ima.domain());
+ for_all(p)
+ out(p) = parent[ws(p)];
+
+ // io::pgm::save(out, "tmp_out.pgm");
+
+ return out;
+
+ } // end of 'merge'
+
+
+
+} // ! mln
+
+
+
+
+void usage(char* argv[])
+{
+ std::cerr << "usage: " << argv[0] << " input.pbm output.pgm [output.ppm]" << std::endl
+ << " ICDAR'2009: HSC." << std::endl;
+ std::abort();
+}
+
+
+
+int main(int argc, char* argv[])
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ if (argc != 3 && argc != 4)
+ usage(argv);
+
+
+ // Parameters.
+
+ const unsigned
+ subsampling_factor = 4,
+ height = 5,
+ width = 25,
+ n_min_stats = 1000;
+ const float
+ h_sigma = 31,
+ v_sigma = 1.3;
+
+ // end of Parameters.
+
+
+ trace::entering("main");
+
+ image2d<bool> input;
+ io::pbm::load(input, argv[1]);
+
+ // Sub-sampling.
+ image2d<int_u8>
+ small = world::binary_2d::subsample(input, subsampling_factor),
+ fuzzy, clo,
+ ws,
+ spc;
+
+
+# ifdef LOG
+ io::pgm::save(small, "tmp_small.pgm");
+# endif
+
+
+ // Fuzzifying.
+ {
+ image2d<MLN_FLOAT> temp(small.domain()), out;
+ data::fill(temp, small);
+
+ out = linear::gaussian_directional_2d(temp, 1, h_sigma, 0);
+ out = linear::gaussian_directional_2d(out, 0, v_sigma, 0);
+
+ fuzzy = level::saturate(int_u8(), out);
+
+# ifdef LOG
+ io::pgm::save(fuzzy, "tmp_fuzzy.pgm");
+# endif
+ }
+
+
+ clo = morpho::closing::structural(fuzzy, win::rectangle2d(height, width));
+
+ int_u8 n_basins;
+ ws = morpho::watershed::flooding(clo, c4(), n_basins);
+
+
+ spc = merge(small, ws, n_basins, n_min_stats); // Merging!
+
+
+# ifdef LOG
+
+ {
+ io::ppm::save(debug::colorize(rgb8(), spc, n_basins),
+ "tmp_spc.ppm");
+
+ io::pgm::save(ws, "tmp_ws.pgm");
+
+ image2d<rgb8> cool = level::convert(rgb8(), small);
+ data::fill((cool | (pw::value(ws) == pw::cst(0))).rw(),
+ literal::red);
+ io::ppm::save(cool, "tmp_ws.ppm");
+ }
+# endif
+
+
+ // Outputing.
+ {
+ image2d<int_u8> output(input.domain());
+
+ image2d<rgb8>
+ cool = debug::colorize(rgb8(), spc, n_basins),
+ lab(input.domain());
+
+ mln_piter_(box2d) p(input.domain());
+ for_all(p)
+ if (input(p))
+ {
+ output(p) = 0;
+ lab(p) = literal::black;
+ }
+ else
+ {
+ output(p) = spc.at_(p.row() / subsampling_factor, p.col() / subsampling_factor);
+ lab(p) = cool.at_(p.row() / subsampling_factor, p.col() / subsampling_factor);
+ }
+
+ io::pgm::save(output, argv[2]);
+ if (argc == 4)
+ io::ppm::save(lab, argv[3]);
+ }
+
+
+ trace::exiting("main");
+}
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-26 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update IO section of ref guide.
* doc/ref_guide/ref_guide.tex: Update IO section.
---
ref_guide.tex | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
Index: trunk/milena/doc/ref_guide/ref_guide.tex
===================================================================
--- trunk/milena/doc/ref_guide/ref_guide.tex (revision 3582)
+++ trunk/milena/doc/ref_guide/ref_guide.tex (revision 3583)
@@ -42,6 +42,7 @@
\usepackage{color}
\usepackage{hyperref}
\usepackage{pgf}
+\usepackage{hyperref}
\usepackage{doxyfuns}
\usepackage{milena}
@@ -1680,7 +1681,7 @@
\end{itemize}
\doxysection{ioim}{ImageMagick}
- http://www.imagemagick.org/
+ \href{http://www.imagemagick.org/}{http://www.imagemagick.org/}
You have to install ImageMagick with Magick++ support. You will be able to
load every file recognized as an image by ImageMagick.
@@ -1692,13 +1693,15 @@
To do so, just add the following line to your compilation:
+ \begin{verbatim}
`Magick++-config --cppflags --cxxflags --ldflags --libs`
+ \end{verbatim}
- Magick++-config will automatically fill the dependencies depending of your
+ \begin{verbatim}Magick++-config\end{verbatim} will automatically fill the dependencies depending of your
installation.
\doxysection{iodcm}{GDCM}
- http://apps.sourceforge.net/mediawiki/gdcm/
+ \href{http://apps.sourceforge.net/mediawiki/gdcm/}{http://apps.sourceforge.net/mediawiki/gdcm/}
GDCM is a library for manipulating DICOM files. DICOM files are used in
medical imaging.
1
0
* doc/milena.sty: fix scope of latexonly.
* doc/tutorial/Makefile.am,
* doc/ref_guide/Makefile.am: Pass path to .sty files to to_doxygen.sh.
* doc/tutorial/tutorial.tex,
* doc/white_paper/white_paper.tex,
* doc/ref_guide/ref_guide.tex: remove useless packages.
* doc/tools/todoxygen.sh: Pass latex packages to hevea.
---
milena/ChangeLog | 15 +++++++++++++++
milena/doc/milena.sty | 5 +++--
milena/doc/ref_guide/Makefile.am | 2 +-
milena/doc/ref_guide/ref_guide.tex | 5 ++---
milena/doc/tools/todoxygen.sh | 10 +++++++---
milena/doc/tutorial/Makefile.am | 2 +-
milena/doc/tutorial/tutorial.tex | 5 ++---
milena/doc/white_paper/white_paper.tex | 4 +---
8 files changed, 32 insertions(+), 16 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index e93ff15..3dd3baf 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,20 @@
2009-03-26 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+ Fix latex package includes in documentation.
+
+ * doc/milena.sty: fix scope of latexonly.
+
+ * doc/tutorial/Makefile.am,
+ * doc/ref_guide/Makefile.am: Pass path to .sty files to to_doxygen.sh.
+
+ * doc/tutorial/tutorial.tex,
+ * doc/white_paper/white_paper.tex,
+ * doc/ref_guide/ref_guide.tex: remove useless packages.
+
+ * doc/tools/todoxygen.sh: Pass latex packages to hevea.
+
+2009-03-26 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
Revamp documentation commands.
* doc/doxyfuns.sty,
diff --git a/milena/doc/milena.sty b/milena/doc/milena.sty
index 38af3df..4b13f59 100644
--- a/milena/doc/milena.sty
+++ b/milena/doc/milena.sty
@@ -37,14 +37,15 @@
% Doxygen color theme for listings.
%------------------------------------------
%
+\usepackage{listings}
+%%%LISTINGS SETTINGS
+%\begin{latexonly}
\definecolor{ccomment}{rgb}{0.5,0,0}
\definecolor{cstring}{rgb}{0,0.32,0.5}
\definecolor{cidentifier}{rgb}{0,0.5,0}
\definecolor{cbg}{rgb}{0.95,0.95,0.95}
-%%%LISTINGS SETTINGS
-%\begin{latexonly}
\lstset{frameround=fttt}
\lstloadlanguages{[ISO]C++}
\lstset{language=[ISO]C++,
diff --git a/milena/doc/ref_guide/Makefile.am b/milena/doc/ref_guide/Makefile.am
index 40cab40..774d69f 100644
--- a/milena/doc/ref_guide/Makefile.am
+++ b/milena/doc/ref_guide/Makefile.am
@@ -10,7 +10,7 @@ ref-guide:
ref-guide-html:
chmod u+x $(DOC_SRCDIR)/tools/todoxygen.sh
- $(DOC_SRCDIR)/tools/todoxygen.sh $(srcdir)/ref_guide.tex $(DOC_BUILDDIR)/ref_guide
+ $(DOC_SRCDIR)/tools/todoxygen.sh $(srcdir)/ref_guide.tex $(DOC_BUILDDIR)/ref_guide $(DOC_SRCDIR)
clean-local:
rm -f ref_guide.aux ref_guide.toc ref_guide.log ref_guide.bbl ref_guide.out
diff --git a/milena/doc/ref_guide/ref_guide.tex b/milena/doc/ref_guide/ref_guide.tex
index 01abf0e..8a7b6bd 100644
--- a/milena/doc/ref_guide/ref_guide.tex
+++ b/milena/doc/ref_guide/ref_guide.tex
@@ -35,13 +35,12 @@
%\usepackage{hevea}
+\usepackage{html}
\usepackage{graphicx}
-\usepackage{listings}
\usepackage{makeidx}
\usepackage{xcolor}
\usepackage{color}
-\usepackage{html}
-\usepackage{tikz}
+\usepackage{hyperref}
\usepackage{pgf}
\usepackage{doxyfuns}
\usepackage{milena}
diff --git a/milena/doc/tools/todoxygen.sh b/milena/doc/tools/todoxygen.sh
index fdf67ac..c61f5e1 100755
--- a/milena/doc/tools/todoxygen.sh
+++ b/milena/doc/tools/todoxygen.sh
@@ -1,15 +1,19 @@
#!/bin/sh
-if [ $# -ne 2 ]; then
- echo "Usage: $0 <file.tex> <output dir>";
+if [ $# -ne 3 ]; then
+ echo "Usage: $0 <file.tex> <output dir> <path to .sty>";
exit 1;
fi
out="$2/`basename $1 .tex`.hh"
html="$2/`basename $1 .tex`.html"
+DOC_PACKAGES="
+ $3/doxyfuns.sty \
+ $3/milena.sty"
+
#Convert .tex to .html
-hevea -O -fix $1 -o $html
+hevea -O -fix $DOC_PACKAGES $1 -o $html
bodyl=`grep -n "<BODY >" $html | cut -d ':' -f 1`
nlines=`wc -l $html | cut -d ' ' -f 1`
diff --git a/milena/doc/tutorial/Makefile.am b/milena/doc/tutorial/Makefile.am
index 885e8ae..ceeae75 100644
--- a/milena/doc/tutorial/Makefile.am
+++ b/milena/doc/tutorial/Makefile.am
@@ -10,7 +10,7 @@ tutorial:
tuto-html:
chmod u+x $(DOC_SRCDIR)/tools/todoxygen.sh
- $(DOC_SRCDIR)/tools/todoxygen.sh $(srcdir)/tutorial.tex $(DOC_BUILDDIR)/tutorial
+ $(DOC_SRCDIR)/tools/todoxygen.sh $(srcdir)/tutorial.tex $(DOC_BUILDDIR)/tutorial $(DOC_SRCDIR)
clean-local:
rm -f tutorial.aux tutorial.toc tutorial.log tutorial.bbl tutorial.out
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 3034989..3326b24 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -34,17 +34,16 @@
%\usepackage{hevea}
+\usepackage{html}
\usepackage{graphicx}
-\usepackage{listings}
\usepackage{makeidx}
\usepackage{xcolor}
\usepackage{color}
-\usepackage{html}
+\usepackage{hyperref}
\usepackage{pgf}
\usepackage{doxyfuns}
\usepackage{milena}
-
\title{Olena -- Tutorial}
\author{LRDE}
\date{}
diff --git a/milena/doc/white_paper/white_paper.tex b/milena/doc/white_paper/white_paper.tex
index 0e58ffc..2f48a9b 100644
--- a/milena/doc/white_paper/white_paper.tex
+++ b/milena/doc/white_paper/white_paper.tex
@@ -2,14 +2,12 @@
%\usepackage{hevea}
+\usepackage{html}
\usepackage{hyperref}
\usepackage{graphicx}
-\usepackage{listings}
\usepackage{makeidx}
\usepackage{xcolor}
\usepackage{color}
-\usepackage{html}
-\usepackage{tikz}
\usepackage{pgf}
\usepackage{doxyfuns}
\usepackage{milena}
--
1.5.6.5
1
0
* doc/doxyfuns.sty,
* doc/milena.sty: share commands between the various documents.
* doc/ref_guide/ref_guide.tex: Fix a compilation issue.
* doc/tools/todoxygen.sh: Split doxygen pages correctly.
* doc/white_paper/Makefile.am: add path to shared commands.
* doc/tutorial/tutorial.tex,
* doc/white_paper/white_paper.tex: use shared commands.
---
milena/ChangeLog | 16 ++
milena/doc/doxyfuns.sty | 227 ++++++++++++++++++++++
milena/doc/milena.sty | 164 ++++++++++++++++
milena/doc/ref_guide/ref_guide.tex | 326 ++++----------------------------
milena/doc/tools/todoxygen.sh | 1 +
milena/doc/tutorial/tutorial.tex | 326 ++++----------------------------
milena/doc/white_paper/Makefile.am | 2 +-
milena/doc/white_paper/white_paper.tex | 199 +-------------------
8 files changed, 481 insertions(+), 780 deletions(-)
create mode 100644 milena/doc/doxyfuns.sty
create mode 100644 milena/doc/milena.sty
diff --git a/milena/ChangeLog b/milena/ChangeLog
index fbcafd8..e93ff15 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,19 @@
+2009-03-26 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Revamp documentation commands.
+
+ * doc/doxyfuns.sty,
+ * doc/milena.sty: share commands between the various documents.
+
+ * doc/ref_guide/ref_guide.tex: Fix a compilation issue.
+
+ * doc/tools/todoxygen.sh: Split doxygen pages correctly.
+
+ * doc/white_paper/Makefile.am: add path to shared commands.
+
+ * doc/tutorial/tutorial.tex,
+ * doc/white_paper/white_paper.tex: use shared commands.
+
2009-03-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
Small fixes.
diff --git a/milena/doc/doxyfuns.sty b/milena/doc/doxyfuns.sty
new file mode 100644
index 0000000..5424d05
--- /dev/null
+++ b/milena/doc/doxyfuns.sty
@@ -0,0 +1,227 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory
+%%
+%% This file is part of the Olena Library. This library is free
+%% software; you can redistribute it and/or modify it under the terms
+%% of the GNU General Public License version 2 as published by the
+%% Free Software Foundation.
+%%
+%% This library is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%% General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this library; see the file COPYING. If not, write to
+%% the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+%% Boston, MA 02111-1307, USA.
+%%
+%% As a special exception, you may use this file as part of a free
+%% software library without restriction. Specifically, if other files
+%% instantiate templates or use macros or inline functions from this
+%% file, or you compile this file and link it with other files to
+%% produce an executable, this file does not by itself cause the
+%% resulting executable to be covered by the GNU General Public
+%% License. This exception does not however invalidate any other
+%% reasons why the executable file might be covered by the GNU General
+%% Public License.
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Set of commands to handle Doxygen and latex output. %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+% #1 - sub page ref name (one word in lower case).
+% #2 - sub page title.
+\newcommand{\doxychapter}[2]{%
+\label{#1}
+\backslash endhtmlonly%
+*/
+/*!
+\backslash page #1 #2%
+\backslash htmlonly %
+}
+
+% #1 - section ref name (one word in lower case).
+% #2 - section title.
+\newcommand{\doxysection}[2]{%
+\vspace{1cm}
+\label{#1}
+\backslash endhtmlonly%
+\backslash section #1 #2%
+\backslash htmlonly %
+}
+
+% #1 - subsection name (one word in lower case).
+% #2 - subsection title.
+\newcommand{\doxysubsection}[2]{%
+\label{#1}
+\backslash endhtmlonly%
+\backslash subsection #1 #2%
+\backslash htmlonly %
+}
+
+% #1 - subsubsection name (one word in lower case).
+% #2 - subsubsection title.
+\newcommand{\doxysubsubsection}[2]{%
+\label{#1}
+\backslash endhtmlonly%
+\backslash subsubsection #1 #2%
+\backslash htmlonly %
+}
+
+% #1 - part number (Optional).
+% #2 - sample file name.
+\newcommand{\doxycode}[2][1]{
+\backslash endhtmlonly%
+\backslash include #2-#1.cc%
+\backslash htmlonly %
+}
+
+% #1 - sample file name.
+\newcommand{\doxyrawcode}[1]{
+\backslash endhtmlonly%
+\backslash include #1.cc.raw%
+\backslash htmlonly %
+}
+
+% #1 - output file name.
+\newcommand{\doxyoutput}[1]{
+\backslash endhtmlonly%
+\backslash include #1.txt%
+\backslash htmlonly %
+}
+
+% Include file '#1' from a split output.
+% #1 - part number (Optional).
+% #2 - sample file name.
+\newcommand{\doxymoutput}[2][1]{
+\backslash endhtmlonly%
+\backslash include #2-#1.txt%
+\backslash htmlonly %
+}
+
+% Include an output image.
+% #1 - output image number.
+% #2 - related sample file name.
+% #3 - Size of the picture (Latex ONLY)
+\newcommand{\doxyfigure}[3][1]{
+\backslash endhtmlonly%
+\backslash image html #2-#1.png%
+\backslash htmlonly %
+}
+
+% Include an image from located in one of the path specified in IMAGE_PATH.
+% #1 - image name.
+% #2 - Size of the picture (Latex ONLY)
+\newcommand{\doxyimg}[2]{
+\backslash endhtmlonly%
+\backslash image html #1.png%
+\backslash htmlonly %
+}
+
+% Refer to a chapter, section...
+% #1 - the reference name.
+\newcommand{\doxyref}[1]{
+\backslash endhtmlonly%
+\backslash ref #1%
+\backslash htmlonly %
+}
+
+% Refers to classes, functions, methods, variables files or URL.
+% #1 - the reference name.
+\newcommand{\doxysee}[1]{
+\backslash endhtmlonly%
+\backslash see #1%
+\backslash htmlonly %
+}
+
+\newcommand{\tutotoc}[2]{%
+\begin{center}%
+ \longleftarrow ~Go to \doxyref{#1} \hspace{1cm} | \hspace{1cm} Go to \doxyref{#2}~ \longrightarrow%
+\end{center}%
+}
+
+\newenvironment{doxymath}
+{
+%\backslash endhtmlonly%
+%\backslash f\$
+%\begin{rawtext}
+$$
+}
+{
+$$
+%\end{rawtext}
+%\backslash f\$
+%\backslash htmlonly%
+}
+
+
+%
+% renew the previous command for latex only documents.
+%
+
+%\begin{latexonly}
+\renewcommand{\doxychapter}[2]{\chapter{#2}\label{#1}}
+\renewcommand{\doxysection}[2]{\section{#2}\label{#1}}
+\renewcommand{\doxysubsection}[2]{\subsection{#2}\label{#1}}
+\renewcommand{\doxysubsubsection}[2]{\subsubsection{#2}\label{#1}}
+\renewcommand{\doxycode}[2][1]{\lstinputlisting[frame=single]{examples/#2-#1.cc}}
+\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{examples/#1.cc.raw}}
+\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
+\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
+\renewcommand{\doxyfigure}[3][1]{%
+\pgfimage[width=#3]{figures/#2-#1}%
+\label{#1}%
+}
+\renewcommand{\doxyimg}[2]{%
+\pgfimage[width=#2]{#1.png}%
+\label{#1}%
+}
+\renewcommand{\doxyref}[1]{\ref{#1}}
+\renewcommand{\doxysee}[1]{\ref{#1}}
+\renewcommand{\tutotoc}[2]{}
+\renewenvironment{doxymath}
+{
+ $$
+}
+{
+ $$
+}
+
+%\end{latexonly}
+
+
+\newcommand{\code}[1]{%
+\textit{#1}%
+}
+\newcommand{\var}[1]{%
+\textit{$#1$}%
+}
+\newcommand{\val}[1]{%
+\textit{#1}%
+}
+\newcommand{\type}[1]{%
+\textit{#1}%
+}
+\newcommand{\namespace}[1]{%
+\textit{#1}%
+}
+\newcommand{\header}[1]{%
+\textit{#1}%
+}
+\newcommand{\hpath}[1]{%
+\textit{#1}%
+}
+
+\newcommand{\must}{%
+\textbf{must}
+}
+\newcommand{\should}{%
+\textbf{should}
+}
+
+\newcommand{\dir}[1]{
+\textbf{\textit{#1}}
+}
+
diff --git a/milena/doc/milena.sty b/milena/doc/milena.sty
new file mode 100644
index 0000000..38af3df
--- /dev/null
+++ b/milena/doc/milena.sty
@@ -0,0 +1,164 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory
+%%
+%% This file is part of the Olena Library. This library is free
+%% software; you can redistribute it and/or modify it under the terms
+%% of the GNU General Public License version 2 as published by the
+%% Free Software Foundation.
+%%
+%% This library is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%% General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this library; see the file COPYING. If not, write to
+%% the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+%% Boston, MA 02111-1307, USA.
+%%
+%% As a special exception, you may use this file as part of a free
+%% software library without restriction. Specifically, if other files
+%% instantiate templates or use macros or inline functions from this
+%% file, or you compile this file and link it with other files to
+%% produce an executable, this file does not by itself cause the
+%% resulting executable to be covered by the GNU General Public
+%% License. This exception does not however invalidate any other
+%% reasons why the executable file might be covered by the GNU General
+%% Public License.
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Common set of commands related to Milena. %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
+
+%
+%------------------------------------------
+% Doxygen color theme for listings.
+%------------------------------------------
+%
+
+\definecolor{ccomment}{rgb}{0.5,0,0}
+\definecolor{cstring}{rgb}{0,0.32,0.5}
+\definecolor{cidentifier}{rgb}{0,0.5,0}
+\definecolor{cbg}{rgb}{0.95,0.95,0.95}
+
+%%%LISTINGS SETTINGS
+%\begin{latexonly}
+\lstset{frameround=fttt}
+\lstloadlanguages{[ISO]C++}
+\lstset{language=[ISO]C++,
+ captionpos=b,
+ basicstyle={\small\sffamily}, % normal small footnotesize scriptsize tiny
+ commentstyle=\itshape,
+ showstringspaces=false,
+ numberstyle=\tiny,
+ morekeywords={where, auto, concept, concept_map, axiom, late_check, final, abstract},
+ morecomment=[s]{/*}{*/},
+ backgroundcolor=\color{cbg},
+ identifierstyle=\color{black},
+ stringstyle=\color{cstring}
+}
+%\end{latexonly}
+
+
+
+%
+%------------------------------------------
+% Set of Tikz drawings.
+%------------------------------------------
+%
+
+\usepackage{tikz}
+
+\usetikzlibrary{er}
+
+\newcommand{\neighcfour}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[fill=orange!20,draw=orange] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\neighceight}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[fill=orange!20,draw=orange] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+ %Top left
+ \draw (-0.25,0.25) node[entity,draw] {};
+ %Top right
+ \draw (0.26,0.25) node[entity,draw] {};%
+ %Bottom left
+ \draw (-0.25,-0.25) node[entity,draw] {};%
+ %Bottom Right
+ \draw (0.26,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\wincfour}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[entity,draw] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+
+\end{tikzpicture}%
+\end{latexonly}
+}
+
+\newcommand{\winceight}{%
+\begin{latexonly}
+\begin{tikzpicture}%
+ \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
+ %center
+ \draw (0,0) node[entity,draw] {} ;
+ %left
+ \draw (-0.25,0) node[entity,draw] {};
+ %right
+ \draw (0.26,0) node[entity,draw] {};%
+ %top
+ \draw (0,0.25) node[entity,draw] {};%
+ %bottom
+ \draw (0,-0.25) node[entity,draw] {};%
+ %Top left
+ \draw (-0.25,0.25) node[entity,draw] {};
+ %Top right
+ \draw (0.26,0.25) node[entity,draw] {};%
+ %Bottom left
+ \draw (-0.25,-0.25) node[entity,draw] {};%
+ %Bottom Right
+ \draw (0.26,-0.25) node[entity,draw] {};%
+\end{tikzpicture}%
+\end{latexonly}
+}
+
diff --git a/milena/doc/ref_guide/ref_guide.tex b/milena/doc/ref_guide/ref_guide.tex
index e7f9753..01abf0e 100644
--- a/milena/doc/ref_guide/ref_guide.tex
+++ b/milena/doc/ref_guide/ref_guide.tex
@@ -1,3 +1,36 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory
+%%
+%% This file is part of the Olena Library. This library is free
+%% software; you can redistribute it and/or modify it under the terms
+%% of the GNU General Public License version 2 as published by the
+%% Free Software Foundation.
+%%
+%% This library is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%% General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this library; see the file COPYING. If not, write to
+%% the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+%% Boston, MA 02111-1307, USA.
+%%
+%% As a special exception, you may use this file as part of a free
+%% software library without restriction. Specifically, if other files
+%% instantiate templates or use macros or inline functions from this
+%% file, or you compile this file and link it with other files to
+%% produce an executable, this file does not by itself cause the
+%% resulting executable to be covered by the GNU General Public
+%% License. This exception does not however invalidate any other
+%% reasons why the executable file might be covered by the GNU General
+%% Public License.
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% Milena's Quick Reference Guide. %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+
\documentclass{report}
%\usepackage{hevea}
@@ -10,301 +43,14 @@
\usepackage{html}
\usepackage{tikz}
\usepackage{pgf}
-
-\newcommand{\img}[4]{
-\begin{figure}[ht!]
- \begin{center}
- \includegraphics[width=#2]{figures/#1}
- \caption{#4\label{fig:#1}}
- \end{center}
- \end{figure}
-}
+\usepackage{doxyfuns}
+\usepackage{milena}
\title{Olena -- Quick Reference Guide}
\author{LRDE}
\date{}
\makeindex
-\definecolor{ccomment}{rgb}{0.5,0,0}
-\definecolor{cstring}{rgb}{0,0.32,0.5}
-\definecolor{cidentifier}{rgb}{0,0.5,0}
-\definecolor{cbg}{rgb}{0.95,0.95,0.95}
-
-%%%LISTINGS SETTINGS
-%\begin{latexonly}
-\lstset{frameround=fttt}
-\lstloadlanguages{[ISO]C++}
-\lstset{language=[ISO]C++,
- captionpos=b,
- basicstyle={\small\sffamily}, % normal small footnotesize scriptsize tiny
- commentstyle=\itshape,
- showstringspaces=false,
- numberstyle=\tiny,
- morekeywords={where, auto, concept, concept_map, axiom, late_check, final, abstract},
- morecomment=[s]{/*}{*/},
- backgroundcolor=\color{cbg},
- identifierstyle=\color{black},
- stringstyle=\color{cstring}
-}
-%\end{latexonly}
-
-% #1 : sub page name
-% #2 : sub page title
-\newcommand{\doxychapter}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash page #1 #2%
-\backslash htmlonly %
-}
-
-% #1 : section name
-% #2 : section title
-\newcommand{\doxysection}[2]{%
-\vspace{1cm}
-\label{#1}
-\backslash endhtmlonly%
-\backslash section #1 #2%
-\backslash htmlonly %
-}
-\newcommand{\doxysubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsection #1 #2%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysubsubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsubsection #1 #2%
-\backslash htmlonly %
-}
-
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxycode}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.cc%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyrawcode}[1]{
-\backslash endhtmlonly%
-\backslash include #1.cc.raw%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyoutput}[1]{
-\backslash endhtmlonly%
-\backslash include #1.txt%
-\backslash htmlonly %
-}
-
-% Include file '#1' from a split output.
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxymoutput}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.txt%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyfigure}[3][1]{
-\backslash endhtmlonly%
-\backslash image html #2-#1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyimg}[2]{
-\backslash endhtmlonly%
-\backslash image html #1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyref}[1]{
-\backslash endhtmlonly%
-\backslash ref #1%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysee}[1]{
-\backslash endhtmlonly%
-\backslash see #1%
-\backslash htmlonly %
-}
-
-\newcommand{\tutotoc}[2]{%
-\begin{center}%
- \longleftarrow ~Go to \doxyref{#1} \hspace{1cm} | \hspace{1cm} Go to \doxyref{#2}~ \longrightarrow%
-\end{center}%
-}
-
-\newenvironment{doxymath}
-{
-%\backslash endhtmlonly%
-%\backslash f\$
-%\begin{rawtext}
-$$
-}
-{
-$$
-%\end{rawtext}
-%\backslash f\$
-%\backslash htmlonly%
-}
-
-%\begin{latexonly}
-\renewcommand{\doxychapter}[2]{\chapter{#2}\label{#1}}
-\renewcommand{\doxysection}[2]{\section{#2}\label{#1}}
-\renewcommand{\doxysubsection}[2]{\subsection{#2}\label{#1}}
-\renewcommand{\doxysubsubsection}[2]{\subsubsection{#2}\label{#1}}
-\renewcommand{\doxycode}[2][1]{\lstinputlisting[frame=single]{examples/#2-#1.cc}}
-\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{examples/#1.cc.raw}}
-\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
-\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
-\renewcommand{\doxyfigure}[3][1]{%
-\pgfimage[width=#3]{figures/#2-#1}%
-\label{#1}%
-}
-\renewcommand{\doxyimg}[2]{%
-\pgfimage[width=#2]{#1.png}%
-\label{#1}%
-}
-\renewcommand{\doxyref}[1]{\ref{#1}}
-\renewcommand{\doxysee}[1]{\ref{#1}}
-\renewcommand{\tutotoc}[2]{}
-\renewenvironment{doxymath}
-{
- $$
-}
-{
- $$
-}
-
-%\end{latexonly}
-
-
-\newcommand{\code}[1]{%
-\textit{#1}%
-}
-\newcommand{\var}[1]{%
-\textit{$#1$}%
-}
-\newcommand{\val}[1]{%
-\textit{#1}%
-}
-\newcommand{\type}[1]{%
-\textit{#1}%
-}
-\newcommand{\namespace}[1]{%
-\textit{#1}%
-}
-\newcommand{\header}[1]{%
-\textit{#1}%
-}
-\newcommand{\hpath}[1]{%
-\textit{#1}%
-}
-
-\newcommand{\must}{%
-\textbf{must}
-}
-\newcommand{\should}{%
-\textbf{should}
-}
-
-
-\usetikzlibrary{er}
-
-\newcommand{\neighcfour}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[fill=orange!20,draw=orange] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\neighceight}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[fill=orange!20,draw=orange] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
- %Top left
- \draw (-0.25,0.25) node[entity,draw] {};
- %Top right
- \draw (0.26,0.25) node[entity,draw] {};%
- %Bottom left
- \draw (-0.25,-0.25) node[entity,draw] {};%
- %Bottom Right
- \draw (0.26,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\wincfour}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[entity,draw] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
-
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\winceight}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[entity,draw] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
- %Top left
- \draw (-0.25,0.25) node[entity,draw] {};
- %Top right
- \draw (0.26,0.25) node[entity,draw] {};%
- %Bottom left
- \draw (-0.25,-0.25) node[entity,draw] {};%
- %Bottom Right
- \draw (0.26,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
\begin{document}
% Doxygen use only - Generate the left menu.
@@ -1925,7 +1671,7 @@ site set.
\newpage
\doxychapter{inputoutput}{Input / Output}
-Olena offers a builtin support for PNM (PBM, PGM & PPM), PFM and dump file formats.
+Olena offers a builtin support for PNM (PBM, PGM \& PPM), PFM and dump file formats.
You can extend the range of supported files by installing third-parties libraries such as:
diff --git a/milena/doc/tools/todoxygen.sh b/milena/doc/tools/todoxygen.sh
index fa5d188..fdf67ac 100755
--- a/milena/doc/tools/todoxygen.sh
+++ b/milena/doc/tools/todoxygen.sh
@@ -32,6 +32,7 @@ sed -i -e 's/≡/\&equiv/g' $out
#\ref and \see do not need that extra new line.
for keyword in include section page subpage subsection subsubsection image; do
sed -i -e "s/\\\\endhtmlonly\\\\$keyword/\\\\endhtmlonly\n\n\\\\$keyword/g" $out
+ sed -i -e "s/\\\\endhtmlonly\*\//\\\\endhtmlonly\n\n\*\/\n\n/g" $out
sed -i -e "s/\\\\$keyword \(.*\)\\\\htmlonly/\\\\$keyword \1\n\n\\\\htmlonly\n/g" $out
done
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 37c37ce..3034989 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -1,3 +1,35 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory
+%%
+%% This file is part of the Olena Library. This library is free
+%% software; you can redistribute it and/or modify it under the terms
+%% of the GNU General Public License version 2 as published by the
+%% Free Software Foundation.
+%%
+%% This library is distributed in the hope that it will be useful,
+%% but WITHOUT ANY WARRANTY; without even the implied warranty of
+%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%% General Public License for more details.
+%%
+%% You should have received a copy of the GNU General Public License
+%% along with this library; see the file COPYING. If not, write to
+%% the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+%% Boston, MA 02111-1307, USA.
+%%
+%% As a special exception, you may use this file as part of a free
+%% software library without restriction. Specifically, if other files
+%% instantiate templates or use macros or inline functions from this
+%% file, or you compile this file and link it with other files to
+%% produce an executable, this file does not by itself cause the
+%% resulting executable to be covered by the GNU General Public
+%% License. This exception does not however invalidate any other
+%% reasons why the executable file might be covered by the GNU General
+%% Public License.
+
+
+%%%%%%%%%%%%%%%%%%%%%%
+% Milena's tutorial. %
+%%%%%%%%%%%%%%%%%%%%%%
+
\documentclass{report}
%\usepackage{hevea}
@@ -8,306 +40,16 @@
\usepackage{xcolor}
\usepackage{color}
\usepackage{html}
-\usepackage{tikz}
\usepackage{pgf}
+\usepackage{doxyfuns}
+\usepackage{milena}
-\newcommand{\img}[4]{
-\begin{figure}[ht!]
- \begin{center}
- \includegraphics[width=#2]{figures/#1}
- \caption{#4\label{fig:#1}}
- \end{center}
- \end{figure}
-}
\title{Olena -- Tutorial}
\author{LRDE}
\date{}
\makeindex
-\definecolor{ccomment}{rgb}{0.5,0,0}
-\definecolor{cstring}{rgb}{0,0.32,0.5}
-\definecolor{cidentifier}{rgb}{0,0.5,0}
-\definecolor{cbg}{rgb}{0.95,0.95,0.95}
-
-%%%LISTINGS SETTINGS
-%\begin{latexonly}
-\lstset{frameround=fttt}
-\lstloadlanguages{[ISO]C++}
-\lstset{language=[ISO]C++,
- captionpos=b,
- basicstyle={\small\sffamily}, % normal small footnotesize scriptsize tiny
- commentstyle=\itshape,
- showstringspaces=false,
- numberstyle=\tiny,
- morekeywords={where, auto, concept, concept_map, axiom, late_check, final, abstract},
- morecomment=[s]{/*}{*/},
- backgroundcolor=\color{cbg},
- identifierstyle=\color{black},
- stringstyle=\color{cstring}
-}
-%\end{latexonly}
-
-% #1 : sub page name
-% #2 : sub page title
-\newcommand{\doxychapter}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash page #1 #2%
-\backslash htmlonly %
-}
-
-% #1 : section name
-% #2 : section title
-\newcommand{\doxysection}[2]{%
-\vspace{1cm}
-\label{#1}
-\backslash endhtmlonly%
-\backslash section #1 #2%
-\backslash htmlonly %
-}
-\newcommand{\doxysubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsection #1 #2%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysubsubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsubsection #1 #2%
-\backslash htmlonly %
-}
-
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxycode}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.cc%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyrawcode}[1]{
-\backslash endhtmlonly%
-\backslash include #1.cc.raw%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyoutput}[1]{
-\backslash endhtmlonly%
-\backslash include #1.txt%
-\backslash htmlonly %
-}
-
-% Include file '#1' from a split output.
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxymoutput}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.txt%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyfigure}[3][1]{
-\backslash endhtmlonly%
-\backslash image html #2-#1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyimg}[2]{
-\backslash endhtmlonly%
-\backslash image html #1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyref}[1]{
-\backslash endhtmlonly%
-\backslash ref #1%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysee}[1]{
-\backslash endhtmlonly%
-\backslash see #1%
-\backslash htmlonly %
-}
-
-\newcommand{\tutotoc}[2]{%
-\begin{center}%
- \longleftarrow ~Go to \doxyref{#1} \hspace{1cm} | \hspace{1cm} Go to \doxyref{#2}~ \longrightarrow%
-\end{center}%
-}
-
-\newenvironment{doxymath}
-{
-%\backslash endhtmlonly%
-%\backslash f\$
-%\begin{rawtext}
-$$
-}
-{
-$$
-%\end{rawtext}
-%\backslash f\$
-%\backslash htmlonly%
-}
-
-%\begin{latexonly}
-\renewcommand{\doxychapter}[2]{\chapter{#2}\label{#1}}
-\renewcommand{\doxysection}[2]{\section{#2}\label{#1}}
-\renewcommand{\doxysubsection}[2]{\subsection{#2}\label{#1}}
-\renewcommand{\doxysubsubsection}[2]{\subsubsection{#2}\label{#1}}
-\renewcommand{\doxycode}[2][1]{\lstinputlisting[frame=single]{examples/#2-#1.cc}}
-\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{examples/#1.cc.raw}}
-\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
-\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
-\renewcommand{\doxyfigure}[3][1]{%
-\pgfimage[width=#3]{figures/#2-#1}%
-\label{#1}%
-}
-\renewcommand{\doxyimg}[2]{%
-\pgfimage[width=#2]{#1.png}%
-\label{#1}%
-}
-\renewcommand{\doxyref}[1]{\ref{#1}}
-\renewcommand{\doxysee}[1]{\ref{#1}}
-\renewcommand{\tutotoc}[2]{}
-\renewenvironment{doxymath}
-{
- $$
-}
-{
- $$
-}
-
-%\end{latexonly}
-
-
-\newcommand{\code}[1]{%
-\textit{#1}%
-}
-\newcommand{\var}[1]{%
-\textit{$#1$}%
-}
-\newcommand{\val}[1]{%
-\textit{#1}%
-}
-\newcommand{\type}[1]{%
-\textit{#1}%
-}
-\newcommand{\namespace}[1]{%
-\textit{#1}%
-}
-\newcommand{\header}[1]{%
-\textit{#1}%
-}
-\newcommand{\hpath}[1]{%
-\textit{#1}%
-}
-
-\newcommand{\must}{%
-\textbf{must}
-}
-\newcommand{\should}{%
-\textbf{should}
-}
-
-
-\usetikzlibrary{er}
-
-\newcommand{\neighcfour}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[fill=orange!20,draw=orange] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\neighceight}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[fill=orange!20,draw=orange] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
- %Top left
- \draw (-0.25,0.25) node[entity,draw] {};
- %Top right
- \draw (0.26,0.25) node[entity,draw] {};%
- %Bottom left
- \draw (-0.25,-0.25) node[entity,draw] {};%
- %Bottom Right
- \draw (0.26,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\wincfour}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[entity,draw] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
-
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\winceight}{%
-\begin{latexonly}
-\begin{tikzpicture}%
- \tikzstyle{every entity}=[draw=blue!50,fill=blue!20,thick]%
- %center
- \draw (0,0) node[entity,draw] {} ;
- %left
- \draw (-0.25,0) node[entity,draw] {};
- %right
- \draw (0.26,0) node[entity,draw] {};%
- %top
- \draw (0,0.25) node[entity,draw] {};%
- %bottom
- \draw (0,-0.25) node[entity,draw] {};%
- %Top left
- \draw (-0.25,0.25) node[entity,draw] {};
- %Top right
- \draw (0.26,0.25) node[entity,draw] {};%
- %Bottom left
- \draw (-0.25,-0.25) node[entity,draw] {};%
- %Bottom Right
- \draw (0.26,-0.25) node[entity,draw] {};%
-\end{tikzpicture}%
-\end{latexonly}
-}
-
-\newcommand{\dir}[1]{
-\textbf{\textit{#1}}
-}
\begin{document}
diff --git a/milena/doc/white_paper/Makefile.am b/milena/doc/white_paper/Makefile.am
index a332b17..e5d0986 100644
--- a/milena/doc/white_paper/Makefile.am
+++ b/milena/doc/white_paper/Makefile.am
@@ -1,5 +1,5 @@
include $(top_srcdir)/milena/doc/doc.mk
-TEXINPUTS = $(top_srcdir)/milena/doc/white_paper/figures:
+TEXINPUTS = $(DOC_SRCDIR):$(top_srcdir)/milena/doc/white_paper/figures:
white-paper:
TEXINPUTS=$(TEXINPUTS) pdflatex $(srcdir)/white_paper.tex
diff --git a/milena/doc/white_paper/white_paper.tex b/milena/doc/white_paper/white_paper.tex
index 9b2f03e..0e58ffc 100644
--- a/milena/doc/white_paper/white_paper.tex
+++ b/milena/doc/white_paper/white_paper.tex
@@ -11,15 +11,9 @@
\usepackage{html}
\usepackage{tikz}
\usepackage{pgf}
+\usepackage{doxyfuns}
+\usepackage{milena}
-\newcommand{\img}[4]{
-\begin{figure}[ht!]
- \begin{center}
- \includegraphics[width=#2]{figures/#1}
- \caption{#4\label{fig:#1}}
- \end{center}
- \end{figure}
-}
\title{Milena\\
\large{Generic image processing library} }
@@ -27,195 +21,6 @@
\date{}
\makeindex
-\definecolor{ccomment}{rgb}{0.5,0,0}
-\definecolor{cstring}{rgb}{0,0.32,0.5}
-\definecolor{cidentifier}{rgb}{0,0.5,0}
-\definecolor{cbg}{rgb}{0.95,0.95,0.95}
-
-%%%LISTINGS SETTINGS
-%\begin{latexonly}
-\lstset{frameround=fttt}
-\lstloadlanguages{[ISO]C++}
-\lstset{language=[ISO]C++,
- captionpos=b,
- basicstyle={\small\sffamily}, % normal small footnotesize scriptsize tiny
- commentstyle=\itshape,
- showstringspaces=false,
- numberstyle=\tiny,
- morekeywords={where, auto, concept, concept_map, axiom, late_check, final, abstract},
- morecomment=[s]{/*}{*/},
- backgroundcolor=\color{cbg},
- identifierstyle=\color{black},
- stringstyle=\color{cstring}
-}
-%\end{latexonly}
-
-% #1 : sub page name
-% #2 : sub page title
-\newcommand{\doxychapter}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash page #1 #2%
-\backslash htmlonly %
-}
-
-% #1 : section name
-% #2 : section title
-\newcommand{\doxysection}[2]{%
-\vspace{1cm}
-\label{#1}
-\backslash endhtmlonly%
-\backslash section #1 #2%
-\backslash htmlonly %
-}
-\newcommand{\doxysubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsection #1 #2%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysubsubsection}[2]{%
-\label{#1}
-\backslash endhtmlonly%
-\backslash subsubsection #1 #2%
-\backslash htmlonly %
-}
-
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxycode}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.cc%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyrawcode}[1]{
-\backslash endhtmlonly%
-\backslash include #1.cc.raw%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyoutput}[1]{
-\backslash endhtmlonly%
-\backslash include #1.txt%
-\backslash htmlonly %
-}
-
-% Include file '#1' from a split output.
-% #1 - part number (Optional)
-% #2 - file name
-\newcommand{\doxymoutput}[2][1]{
-\backslash endhtmlonly%
-\backslash include #2-#1.txt%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyfigure}[3][1]{
-\backslash endhtmlonly%
-\backslash image html #2-#1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyimg}[2]{
-\backslash endhtmlonly%
-\backslash image html #1.png%
-\backslash htmlonly %
-}
-
-\newcommand{\doxyref}[1]{
-\backslash endhtmlonly%
-\backslash ref #1%
-\backslash htmlonly %
-}
-
-\newcommand{\doxysee}[1]{
-\backslash endhtmlonly%
-\backslash see #1%
-\backslash htmlonly %
-}
-
-\newcommand{\tutotoc}[2]{%
-\begin{center}%
- \longleftarrow ~Go to \doxyref{#1} \hspace{1cm} | \hspace{1cm} Go to \doxyref{#2}~ \longrightarrow%
-\end{center}%
-}
-
-\newenvironment{doxymath}
-{
-%\backslash endhtmlonly%
-%\backslash f\$
-%\begin{rawtext}
-$$
-}
-{
-$$
-%\end{rawtext}
-%\backslash f\$
-%\backslash htmlonly%
-}
-
-%\begin{latexonly}
-\renewcommand{\doxychapter}[2]{\chapter{#2}\label{#1}}
-\renewcommand{\doxysection}[2]{\section{#2}\label{#1}}
-\renewcommand{\doxysubsection}[2]{\subsection{#2}\label{#1}}
-\renewcommand{\doxysubsubsection}[2]{\subsubsection{#2}\label{#1}}
-\renewcommand{\doxycode}[2][1]{\lstinputlisting[frame=single]{samples/#2-#1.cc}}
-\renewcommand{\doxyrawcode}[1]{\lstinputlisting[frame=single]{samples/#1.cc.raw}}
-\renewcommand{\doxyoutput}[1]{\lstinputlisting[frame=single]{outputs/#1.txt}}
-\renewcommand{\doxymoutput}[2][1]{\lstinputlisting[frame=single]{outputs/splitted/#2-#1.txt}}
-\renewcommand{\doxyfigure}[3][1]{%
-\pgfimage[width=#3]{figures/#2-#1}%
-\label{#1}%
-}
-\renewcommand{\doxyimg}[2]{%
-\pgfimage[width=#2]{#1}%
-\label{#1}%
-}
-\renewcommand{\doxyref}[1]{\ref{#1}}
-\renewcommand{\doxysee}[1]{\ref{#1}}
-\renewcommand{\tutotoc}[2]{}
-\renewenvironment{doxymath}
-{
- $$
-}
-{
- $$
-}
-
-%\end{latexonly}
-
-
-\newcommand{\code}[1]{%
-\textit{#1}%
-}
-\newcommand{\var}[1]{%
-\textit{$#1$}%
-}
-\newcommand{\val}[1]{%
-\textit{#1}%
-}
-\newcommand{\type}[1]{%
-\textit{#1}%
-}
-\newcommand{\namespace}[1]{%
-\textit{#1}%
-}
-\newcommand{\header}[1]{%
-\textit{#1}%
-}
-\newcommand{\hpath}[1]{%
-\textit{#1}%
-}
-
-\newcommand{\must}{%
-\textbf{must}
-}
-\newcommand{\should}{%
-\textbf{should}
-}
-
-
\begin{document}
--
1.5.6.5
1
0
* exec/Makefile,
* exec/bw_negate_in_color.cc: new tool.
---
milena/sandbox/ChangeLog | 7 ++++
milena/sandbox/exec/Makefile | 7 ++++
milena/sandbox/exec/bw_negate_in_color.cc | 46 +++++++++++++++++++++++++++++
3 files changed, 60 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/exec/Makefile
create mode 100644 milena/sandbox/exec/bw_negate_in_color.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 1290810..11b814e 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2009-03-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add a small tool to invert b&w in a color image.
+
+ * exec/Makefile,
+ * exec/bw_negate_in_color.cc: new tool.
+
+2009-03-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Update Scribo's code.
* scribo/Makefile: add a new target.
diff --git a/milena/sandbox/exec/Makefile b/milena/sandbox/exec/Makefile
new file mode 100644
index 0000000..050d9cd
--- /dev/null
+++ b/milena/sandbox/exec/Makefile
@@ -0,0 +1,7 @@
+TARGET = \
+ bw_negate_in_color
+
+.cc:
+ g++ -I../../ -O1 -DNDEBUG $< -o $@
+
+all: $(TARGET)
diff --git a/milena/sandbox/exec/bw_negate_in_color.cc b/milena/sandbox/exec/bw_negate_in_color.cc
new file mode 100644
index 0000000..2c69f75
--- /dev/null
+++ b/milena/sandbox/exec/bw_negate_in_color.cc
@@ -0,0 +1,46 @@
+//
+// Invert black and white in a color image.
+//
+
+#include <mln/essential/2d.hh>
+
+namespace mln
+{
+
+ struct bw_negate_in_color
+ : Function_v2v<bw_negate_in_color>
+ {
+ typedef value::rgb8 result;
+
+ value::rgb8 operator()(const value::rgb8& v) const
+ {
+ if (v == literal::white)
+ return literal::black;
+ else if (v == literal::black)
+ return literal::white;
+ else
+ return v;
+ }
+
+ };
+
+}
+
+
+int main(int argc, char *argv[])
+{
+ using namespace mln;
+
+ if (argc < 3)
+ {
+ std::cout << "Usage: " << argv[0] << " <input.ppm> <out.ppm>"
+ << std::endl;
+ return 1;
+ }
+
+ image2d<value::rgb8> input;
+ io::ppm::load(input, argv[1]);
+
+ bw_negate_in_color f;
+ io::ppm::save(level::transform(input, f), argv[2]);
+}
--
1.5.6.5
1
0
* scribo/Makefile: add a new target.
* scribo/Makefile.am,
* scribo/scribo.mk,
* scribo/src/Makefile.am,
* scribo/tests/Makefile.am,
* scribo/tests/data.hh.in,
* scribo/tests/filter/Makefile.am,
* scribo/tests/text/Makefile.am,
* scribo/tests/table/Makefile.am: prepare build system integration.
* scribo/text/grouping/group_with_single_left_link.hh,
* scribo/text/grouping/group_with_single_right_link.hh,
* scribo/text/grouping/group_with_several_right_links.hh,
* scribo/text/grouping/group_with_several_left_links.hh,
* scribo/debug/save_linked_textbboxes_image.hh: do not compute mass
centers anymore.
* scribo/draw/bounding_box_links.hh: remove duplicate preconditions.
* scribo/tests/table/repair_lines.cc
* scribo/tests/filter/small_and_large_bboxes.cc
* scribo/tests/table/extract_lines_with_rank.cc
* scribo/src/table_rebuild_opening.cc
* scribo/src/table_rebuild_rank.cc
* scribo/src/table_extract.cc
* scribo/src/morpho.cc,
* scribo/filter/large_components.hh: fix.
* scribo/text/grouping/group_from_single_link.hh,
* scribo/text/grouping/group_from_double_link.hh,
* scribo/filter/thin_bboxes.hh,
* scribo/filter/small_components.hh: add a fixme.
* scribo/filter/thick_bboxes.hh: new routine.
* scribo/make/debug_filename.hh: use a std::string instead of a char*.
* scribo/make/text.hh: prepare a new routine.
* scribo/src/extract_text_double_several_links.cc: add timer info.
* scribo/src/extract_text_multiple_links.cc,,
* scribo/src/extract_text_several_multiple_links.cc,
* scribo/text/grouping/group_from_multiple_links.hh,
* scribo/text/grouping/group_with_multiple_links.hh,
* scribo/text/grouping/group_with_several_multiple_links.hh,
* scribo/text/grouping/internal/find_left_graph_link.hh,
* scribo/text/grouping/internal/update_link_graph.hh: rename as...
* scribo/src/extract_text_graph.cc,
* scribo/src/extract_text_several_graphes.cc,
* scribo/text/grouping/group_from_graph.hh,
* scribo/text/grouping/group_with_graph.hh,
* scribo/text/grouping/group_with_several_graphes.hh,
* scribo/text/grouping/internal/find_graph_link.hh,
* scribo/text/grouping/internal/update_graph_link.hh: ... this.
* scribo/src/photo_basic.cc: new sample code. Process text in photos.
* scribo/src/table_rebuild.cc: remove.
* scribo/text/extract_lines.hh: use double several links routines.
* scribo/util/text.hh: store the bbox mass centers.
---
milena/sandbox/ChangeLog | 70 +++++++++++++++++
milena/sandbox/scribo/Makefile | 3 +
milena/sandbox/scribo/Makefile.am | 6 ++
.../scribo/debug/save_linked_textbboxes_image.hh | 20 +----
milena/sandbox/scribo/draw/bounding_box_links.hh | 8 --
milena/sandbox/scribo/filter/large_components.hh | 67 ++++++++++-------
milena/sandbox/scribo/filter/small_components.hh | 1 +
.../filter/{thin_bboxes.hh => thick_bboxes.hh} | 57 +++++++-------
milena/sandbox/scribo/filter/thin_bboxes.hh | 1 +
milena/sandbox/scribo/make/debug_filename.hh | 6 +-
milena/sandbox/scribo/make/text.hh | 33 ++++++++
milena/sandbox/scribo/scribo.mk | 5 +
milena/sandbox/scribo/src/Makefile.am | 33 ++++++++
.../src/extract_text_double_several_links.cc | 27 +++++++
...ext_multiple_links.cc => extract_text_graph.cc} | 10 +-
...iple_links.cc => extract_text_several_graph.cc} | 10 +-
milena/sandbox/scribo/src/morpho.cc | 2 +-
...text_double_several_links.cc => photo_basic.cc} | 61 +++++++++-------
milena/sandbox/scribo/src/table_extract.cc | 2 +-
milena/sandbox/scribo/src/table_rebuild.cc | 79 --------------------
milena/sandbox/scribo/src/table_rebuild_opening.cc | 3 +-
milena/sandbox/scribo/src/table_rebuild_rank.cc | 3 +-
milena/sandbox/scribo/tests/Makefile.am | 7 ++
.../{src/table_extract.cc => tests/data.hh.in} | 46 ++---------
milena/sandbox/scribo/tests/filter/Makefile.am | 10 +++
.../scribo/tests/filter/small_and_large_bboxes.cc | 45 +++++++-----
milena/sandbox/scribo/tests/table/Makefile.am | 12 +++
.../scribo/tests/table/extract_lines_with_rank.cc | 47 ++++++++++--
milena/sandbox/scribo/tests/table/repair_lines.cc | 43 +++++++++--
milena/sandbox/scribo/tests/text/Makefile.am | 7 ++
milena/sandbox/scribo/text/extract_lines.hh | 26 ++++---
.../scribo/text/grouping/group_from_double_link.hh | 1 +
..._from_multiple_links.hh => group_from_graph.hh} | 21 +++---
.../scribo/text/grouping/group_from_single_link.hh | 1 +
..._with_multiple_links.hh => group_with_graph.hh} | 46 ++++--------
...iple_links.hh => group_with_several_graphes.hh} | 37 +++++-----
.../text/grouping/group_with_several_left_links.hh | 27 +++----
.../grouping/group_with_several_right_links.hh | 27 +++----
.../text/grouping/group_with_single_left_link.hh | 6 +-
.../text/grouping/group_with_single_right_link.hh | 6 +-
...{find_left_graph_link.hh => find_graph_link.hh} | 49 +++++++-----
.../{update_link_graph.hh => update_graph_link.hh} | 22 ++++--
milena/sandbox/scribo/util/text.hh | 59 ++++++++++++--
43 files changed, 628 insertions(+), 424 deletions(-)
create mode 100644 milena/sandbox/scribo/Makefile.am
copy milena/sandbox/scribo/filter/{thin_bboxes.hh => thick_bboxes.hh} (72%)
create mode 100644 milena/sandbox/scribo/scribo.mk
create mode 100644 milena/sandbox/scribo/src/Makefile.am
rename milena/sandbox/scribo/src/{extract_text_multiple_links.cc => extract_text_graph.cc} (91%)
rename milena/sandbox/scribo/src/{extract_text_several_multiple_links.cc => extract_text_several_graph.cc} (90%)
copy milena/sandbox/scribo/src/{extract_text_double_several_links.cc => photo_basic.cc} (60%)
delete mode 100644 milena/sandbox/scribo/src/table_rebuild.cc
create mode 100644 milena/sandbox/scribo/tests/Makefile.am
copy milena/sandbox/scribo/{src/table_extract.cc => tests/data.hh.in} (56%)
create mode 100644 milena/sandbox/scribo/tests/filter/Makefile.am
create mode 100644 milena/sandbox/scribo/tests/table/Makefile.am
create mode 100644 milena/sandbox/scribo/tests/text/Makefile.am
rename milena/sandbox/scribo/text/grouping/{group_from_multiple_links.hh => group_from_graph.hh} (87%)
rename milena/sandbox/scribo/text/grouping/{group_with_multiple_links.hh => group_with_graph.hh} (63%)
rename milena/sandbox/scribo/text/grouping/{group_with_several_multiple_links.hh => group_with_several_graphes.hh} (71%)
rename milena/sandbox/scribo/text/grouping/internal/{find_left_graph_link.hh => find_graph_link.hh} (68%)
rename milena/sandbox/scribo/text/grouping/internal/{update_link_graph.hh => update_graph_link.hh} (79%)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 59c395c..1290810 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,73 @@
+2009-03-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update Scribo's code.
+
+ * scribo/Makefile: add a new target.
+
+ * scribo/Makefile.am,
+ * scribo/scribo.mk,
+ * scribo/src/Makefile.am,
+ * scribo/tests/Makefile.am,
+ * scribo/tests/data.hh.in,
+ * scribo/tests/filter/Makefile.am,
+ * scribo/tests/text/Makefile.am,
+ * scribo/tests/table/Makefile.am: prepare build system integration.
+
+ * scribo/text/grouping/group_with_single_left_link.hh,
+ * scribo/text/grouping/group_with_single_right_link.hh,
+ * scribo/text/grouping/group_with_several_right_links.hh,
+ * scribo/text/grouping/group_with_several_left_links.hh,
+ * scribo/debug/save_linked_textbboxes_image.hh: do not compute mass
+ centers anymore.
+
+ * scribo/draw/bounding_box_links.hh: remove duplicate preconditions.
+
+ * scribo/tests/table/repair_lines.cc
+ * scribo/tests/filter/small_and_large_bboxes.cc
+ * scribo/tests/table/extract_lines_with_rank.cc
+ * scribo/src/table_rebuild_opening.cc
+ * scribo/src/table_rebuild_rank.cc
+ * scribo/src/table_extract.cc
+ * scribo/src/morpho.cc,
+ * scribo/filter/large_components.hh: fix.
+
+ * scribo/text/grouping/group_from_single_link.hh,
+ * scribo/text/grouping/group_from_double_link.hh,
+ * scribo/filter/thin_bboxes.hh,
+ * scribo/filter/small_components.hh: add a fixme.
+
+ * scribo/filter/thick_bboxes.hh: new routine.
+
+ * scribo/make/debug_filename.hh: use a std::string instead of a char*.
+
+ * scribo/make/text.hh: prepare a new routine.
+
+ * scribo/src/extract_text_double_several_links.cc: add timer info.
+
+ * scribo/src/extract_text_multiple_links.cc,,
+ * scribo/src/extract_text_several_multiple_links.cc,
+ * scribo/text/grouping/group_from_multiple_links.hh,
+ * scribo/text/grouping/group_with_multiple_links.hh,
+ * scribo/text/grouping/group_with_several_multiple_links.hh,
+ * scribo/text/grouping/internal/find_left_graph_link.hh,
+ * scribo/text/grouping/internal/update_link_graph.hh: rename as...
+
+ * scribo/src/extract_text_graph.cc,
+ * scribo/src/extract_text_several_graphes.cc,
+ * scribo/text/grouping/group_from_graph.hh,
+ * scribo/text/grouping/group_with_graph.hh,
+ * scribo/text/grouping/group_with_several_graphes.hh,
+ * scribo/text/grouping/internal/find_graph_link.hh,
+ * scribo/text/grouping/internal/update_graph_link.hh: ... this.
+
+ * scribo/src/photo_basic.cc: new sample code. Process text in photos.
+
+ * scribo/src/table_rebuild.cc: remove.
+
+ * scribo/text/extract_lines.hh: use double several links routines.
+
+ * scribo/util/text.hh: store the bbox mass centers.
+
2009-03-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update Fabien' sandbox.
diff --git a/milena/sandbox/scribo/Makefile b/milena/sandbox/scribo/Makefile
index 3c3e1a5..d8b9a68 100644
--- a/milena/sandbox/scribo/Makefile
+++ b/milena/sandbox/scribo/Makefile
@@ -55,6 +55,9 @@ table_erase:
thin_bboxes:
g++ $(CXX_FLAGS) src/thin_bboxes.cc -o bin/thin_bboxes.out
+photo_basic:
+ g++ $(CXX_FLAGS) src/photo_basic.cc -o bin/photo_basic.out
+
clean:
rm *.ppm *.pgm *.pbm
diff --git a/milena/sandbox/scribo/Makefile.am b/milena/sandbox/scribo/Makefile.am
new file mode 100644
index 0000000..bf33f79
--- /dev/null
+++ b/milena/sandbox/scribo/Makefile.am
@@ -0,0 +1,6 @@
+SUBDIRS = tests
+
+.PHONY: bin
+
+bin:
+ make -C src
diff --git a/milena/sandbox/scribo/debug/save_linked_textbboxes_image.hh b/milena/sandbox/scribo/debug/save_linked_textbboxes_image.hh
index e7d2a40..1b53262 100644
--- a/milena/sandbox/scribo/debug/save_linked_textbboxes_image.hh
+++ b/milena/sandbox/scribo/debug/save_linked_textbboxes_image.hh
@@ -119,11 +119,8 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = level::convert(value::rgb8(), input);
- mln::util::array<mln_site(I)::vec> mass_centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
draw::bounding_boxes(tmp, text.bboxes(), box_value);
- draw::bounding_box_links(tmp, mass_centers, link_array, link_value);
+ draw::bounding_box_links(tmp, text.mass_centers(), link_array, link_value);
io::ppm::save(tmp, filename);
@@ -147,11 +144,8 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = level::convert(value::rgb8(), input);
- mln::util::array<mln_site(I)::vec> mass_centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
draw::bounding_boxes(tmp, text.bboxes(), box_value);
- draw::bounding_box_links(tmp, mass_centers,
+ draw::bounding_box_links(tmp, text.mass_centers(),
left_link, right_link,
value);
@@ -179,11 +173,8 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = level::convert(value::rgb8(), input);
- mln::util::array<mln_site(I)::vec> mass_centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
draw::bounding_boxes(tmp, text.bboxes(), box_value);
- draw::bounding_box_links(tmp, mass_centers,
+ draw::bounding_box_links(tmp, text.mass_centers(),
left_link, right_link,
left_link_value, right_link_value,
validated_link_value);
@@ -211,10 +202,7 @@ namespace scribo
mln_ch_value(I,value::rgb8) tmp = level::convert(value::rgb8(), input);
- mln::util::array<mln_site(I)::vec> mass_centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
- draw::bounding_boxes(tmp, mass_centers, box_value);
+ draw::bounding_boxes(tmp, text.bboxes(), box_value);
draw::bounding_box_links(tmp, text.bboxes(), g, link_value);
io::ppm::save(tmp, filename);
diff --git a/milena/sandbox/scribo/draw/bounding_box_links.hh b/milena/sandbox/scribo/draw/bounding_box_links.hh
index 5d695f6..b7f410a 100644
--- a/milena/sandbox/scribo/draw/bounding_box_links.hh
+++ b/milena/sandbox/scribo/draw/bounding_box_links.hh
@@ -230,10 +230,8 @@ namespace scribo
const mln_value(I)& value)
{
trace::entering("scribo::draw::bounding_box_links");
- mln_precondition(exact(input).is_valid());
I& input = exact(input_);
-
mln_precondition(input.is_valid());
for_all_components(i, left_link)
@@ -259,10 +257,8 @@ namespace scribo
const mln_value(I)& value)
{
trace::entering("scribo::draw::bounding_box_links");
- mln_precondition(exact(input).is_valid());
I& input = exact(input_);
-
mln_precondition(input.is_valid());
for_all_components(i, left_link)
@@ -292,10 +288,8 @@ namespace scribo
const mln_value(I)& validated_link_value)
{
trace::entering("scribo::draw::bounding_box_links");
- mln_precondition(exact(input).is_valid());
I& input = exact(input_);
-
mln_precondition(input.is_valid());
mln_site(I)::vec dleft = literal::origin;
@@ -339,10 +333,8 @@ namespace scribo
const mln_value(I)& validated_link_value)
{
trace::entering("scribo::draw::bounding_box_links");
- mln_precondition(exact(input).is_valid());
I& input = exact(input_);
-
mln_precondition(input.is_valid());
mln_site(I)::vec dleft = literal::origin;
diff --git a/milena/sandbox/scribo/filter/large_components.hh b/milena/sandbox/scribo/filter/large_components.hh
index 9ea4e02..7b4964b 100644
--- a/milena/sandbox/scribo/filter/large_components.hh
+++ b/milena/sandbox/scribo/filter/large_components.hh
@@ -70,20 +70,17 @@ namespace scribo
const V& label_type,
unsigned max_size);
-
- /// Remove large bboxes in a binary image.
- /// Set to 'false' all the removed bboxes.
+ /// Remove too large text components.
///
- /// \param[in] input_ A binary image.
- /// \param[in] bboxes Bounding boxes of components extracted from \p
- /// input_.
- /// \param[in] max_size The minimum cardinality of a component.
+ /// \param[in] text Text data.
+ /// \param[in] min_size The minimum cardinality of a component.
///
- /// \return A binary image without large bboxes.
- template <typename P>
- util::array< box<P> >
- large_components(const util::array< box<P> >& bboxes,
- unsigned max_size);
+ /// \return updated text data.
+ template <typename I>
+ scribo::util::text<I>
+ small_components(const scribo::util::text<I>& text,
+ unsigned min_size);
+
# ifndef MLN_INCLUDE_ONLY
@@ -97,9 +94,9 @@ namespace scribo
/// large.
template <typename R>
struct filter_large_components_functor
- : Function_l2b< filter_large_and_large_functor<R> >
+ : Function_l2b< filter_large_components_functor<R> >
{
- filter_large_components_functor(const util::array<R>& nsitecomp,
+ filter_large_components_functor(const mln::util::array<R>& nsitecomp,
unsigned max_size)
: nsitecomp_(nsitecomp), max_size_(max_size)
{
@@ -114,7 +111,7 @@ namespace scribo
}
- const util::array<R>& nsitecomp_;
+ const mln::util::array<R>& nsitecomp_;
unsigned max_size_;
};
@@ -144,10 +141,10 @@ namespace scribo
typedef accu::count<mln_psite(I)> accu_count_t;
typedef mln_result(accu_count_t) accu_count_res_t;
- typedef util::array<accu_count_res_t> nsitecomp_t;
+ typedef mln::util::array<accu_count_res_t> nsitecomp_t;
nsitecomp_t nsitecomp = labeling::compute(accu_count_t(), lbl, nlabels);
- typedef internal::filter_large_and_large_functor<accu_count_res_t> func_t;
+ typedef internal::filter_large_components_functor<accu_count_res_t> func_t;
func_t fl2b(nsitecomp, max_size);
labeling::relabel_inplace(lbl, nlabels, fl2b);
@@ -159,31 +156,45 @@ namespace scribo
}
- template <typename P>
+ template <typename I>
inline
- util::array< box<P> >
- large_components(const util::array< box<P> >& bboxes,
+ scribo::util::text<I>
+ large_components(const scribo::util::text<I>& text,
unsigned max_size)
{
trace::entering("scribo::filter::large_components");
- mln_precondition(input.is_valid());
+ mln_precondition(text.is_valid());
+ typedef mln_site(I) P;
typedef accu::count<P> accu_count_t;
typedef mln_result(accu_count_t) accu_count_res_t;
- typedef util::array<accu_count_res_t> nsitecomp_t;
+ typedef mln::util::array<accu_count_res_t> nsitecomp_t;
- util::array<box<P> > result;
- result.append(box<P>());
- for_all_components(i, bboxes)
+ fun::i2v::array<bool> f(text.nbboxes().next(), false);
+ f(0) = true;
+ mln::util::array<box<P> > bresult;
+ bresult.append(box<P>());
+ for_all_components(i, text.bboxes())
{
- accu_count_res_t count = set::compute(accu_count_t(), bboxes[i]);
+ accu_count_res_t count = set::compute(accu_count_t(), text.bbox(i));
if (count <= max_size)
- result.append(bboxes[i]);
+ {
+ bresult.append(text.bbox(i));
+ f(i) = true;
+ }
}
+ mln_value(I) new_nbboxes;
+ I new_lbl = labeling::relabel(text.label_image(), text.nbboxes(),
+ mln::make::relabelfun(f, text.nbboxes(),
+ new_nbboxes));
+
+ mln_assertion(new_nbboxes.next() == bresult.nelements());
+
trace::exiting("scribo::filter::large_components");
- return result;
+ /// FIXME: construct a new util::text from the old one.
+ return scribo::make::text(bresult, new_lbl, new_nbboxes);
}
diff --git a/milena/sandbox/scribo/filter/small_components.hh b/milena/sandbox/scribo/filter/small_components.hh
index fb8ff5a..55ee9b1 100644
--- a/milena/sandbox/scribo/filter/small_components.hh
+++ b/milena/sandbox/scribo/filter/small_components.hh
@@ -198,6 +198,7 @@ namespace scribo
mln_assertion(new_nbboxes.next() == bresult.nelements());
trace::exiting("scribo::filter::small_components");
+ /// FIXME: construct a new util::text from the old one.
return scribo::make::text(bresult, new_lbl, new_nbboxes);
}
diff --git a/milena/sandbox/scribo/filter/thin_bboxes.hh b/milena/sandbox/scribo/filter/thick_bboxes.hh
similarity index 72%
copy from milena/sandbox/scribo/filter/thin_bboxes.hh
copy to milena/sandbox/scribo/filter/thick_bboxes.hh
index de99242..006065b 100644
--- a/milena/sandbox/scribo/filter/thin_bboxes.hh
+++ b/milena/sandbox/scribo/filter/thick_bboxes.hh
@@ -25,12 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef SCRIBO_FILTER_THIN_BBOXES_HH
-# define SCRIBO_FILTER_THIN_BBOXES_HH
+#ifndef SCRIBO_FILTER_THICK_BBOXES_HH
+# define SCRIBO_FILTER_THICK_BBOXES_HH
-/// \file scribo/filter/thin_bboxes.hh
+/// \file scribo/filter/thick_bboxes.hh
///
-/// Remove too thin bboxes.
+/// Remove too thick bboxes.
# include <mln/labeling/blobs.hh>
# include <mln/labeling/compute.hh>
@@ -53,27 +53,27 @@ namespace scribo
/// Filter Functor. Return false for all components which are too
/// large.
template <typename R>
- struct filter_too_thin_component_functor
- : Function_l2b< filter_too_thin_component_functor<R> >
+ struct filter_too_thick_component_functor
+ : Function_l2b< filter_too_thick_component_functor<R> >
{
- filter_too_thin_component_functor(const mln::util::array<R>& compbboxes,
- unsigned min_thickness)
- : compbboxes_(compbboxes), min_thickness_(min_thickness)
+ filter_too_thick_component_functor(const mln::util::array<R>& compbboxes,
+ unsigned max_thickness)
+ : compbboxes_(compbboxes), max_thickness_(max_thickness)
{
}
- /// Return false if the components is thinner than
- /// \p min_thickness_.
+ /// Return false if the components is thickner than
+ /// \p max_thickness_.
bool operator()(const value::label_16& l) const
{
- return compbboxes_[l].nrows() > min_thickness_
- && compbboxes_[l].ncols() > min_thickness_;
+ return compbboxes_[l].nrows() < max_thickness_
+ && compbboxes_[l].ncols() < max_thickness_;
}
const mln::util::array<R>& compbboxes_;
- unsigned min_thickness_;
+ unsigned max_thickness_;
};
@@ -83,12 +83,12 @@ namespace scribo
template <typename I, typename N, typename V>
inline
mln_concrete(I)
- thin_bboxes(const Image<I>& input_,
+ thick_bboxes(const Image<I>& input_,
const Neighborhood<N>& nbh_,
const V& label_type,
- unsigned min_thickness)
+ unsigned max_thickness)
{
- trace::entering("scribo::filter::thin_bboxes");
+ trace::entering("scribo::filter::thick_bboxes");
const I& input = exact(input_);
const N& nbh = exact(nbh_);
@@ -104,14 +104,14 @@ namespace scribo
typedef mln::util::array<accu_bbox_res_t> compbboxes_t;
compbboxes_t compbboxes = labeling::compute(accu_bbox_t(), lbl, nlabels);
- typedef internal::filter_too_thin_component_functor<accu_bbox_res_t> func_t;
- func_t fl2b(compbboxes, min_thickness);
+ typedef internal::filter_too_thick_component_functor<accu_bbox_res_t> func_t;
+ func_t fl2b(compbboxes, max_thickness);
labeling::relabel_inplace(lbl, nlabels, fl2b);
mln_concrete(I) output = duplicate(input);
data::fill((output | pw::value(lbl) == literal::zero).rw(), false);
- trace::exiting("scribo::filter::thin_bboxes");
+ trace::exiting("scribo::filter::thick_bboxes");
return output;
}
@@ -119,10 +119,10 @@ namespace scribo
template <typename L>
inline
scribo::util::text<L>
- thin_bboxes(const scribo::util::text<L>& text,
- unsigned min_thickness)
+ thick_bboxes(const scribo::util::text<L>& text,
+ unsigned max_thickness)
{
- trace::entering("scribo::filter::thin_bboxes");
+ trace::entering("scribo::filter::thick_bboxes");
mln_precondition(text.is_valid());
@@ -131,15 +131,15 @@ namespace scribo
typedef mln_result(accu_bbox_t) accu_bbox_res_t;
typedef mln::util::array<accu_bbox_res_t> nsitecomp_t;
- typedef internal::filter_too_thin_component_functor<accu_bbox_res_t> func_t;
- func_t is_not_too_thin(text.bboxes(), min_thickness);
+ typedef internal::filter_too_thick_component_functor<accu_bbox_res_t> func_t;
+ func_t is_not_too_thick(text.bboxes(), max_thickness);
fun::i2v::array<bool> f(text.nbboxes().next(), false);
f(0) = true;
mln::util::array<box<P> > bresult;
bresult.append(box<P>());
for_all_components(i, text.bboxes())
- if (is_not_too_thin(i))
+ if (is_not_too_thick(i))
{
bresult.append(text.bbox(i));
f(i) = true;
@@ -151,7 +151,8 @@ namespace scribo
mln_assertion(new_nbboxes.next() == bresult.nelements());
- trace::exiting("scribo::filter::thin_bboxes");
+ trace::exiting("scribo::filter::thick_bboxes");
+ /// FIXME: construct a new util::text from the old one.
return scribo::make::text(bresult, new_lbl, new_nbboxes);
}
@@ -162,4 +163,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_FILTER_THIN_BBOXES_HH
+#endif // ! SCRIBO_FILTER_THICK_BBOXES_HH
diff --git a/milena/sandbox/scribo/filter/thin_bboxes.hh b/milena/sandbox/scribo/filter/thin_bboxes.hh
index de99242..30d7bb9 100644
--- a/milena/sandbox/scribo/filter/thin_bboxes.hh
+++ b/milena/sandbox/scribo/filter/thin_bboxes.hh
@@ -152,6 +152,7 @@ namespace scribo
mln_assertion(new_nbboxes.next() == bresult.nelements());
trace::exiting("scribo::filter::thin_bboxes");
+ /// FIXME: construct a new util::text from the old one.
return scribo::make::text(bresult, new_lbl, new_nbboxes);
}
diff --git a/milena/sandbox/scribo/make/debug_filename.hh b/milena/sandbox/scribo/make/debug_filename.hh
index 5a9728c..839255c 100644
--- a/milena/sandbox/scribo/make/debug_filename.hh
+++ b/milena/sandbox/scribo/make/debug_filename.hh
@@ -56,7 +56,7 @@ namespace scribo
{
/// Set the default debug filename prefix.
- extern char *debug_filename_prefix;
+ extern std::string debug_filename_prefix;
} // end of namespace scribo::make::internal
@@ -67,7 +67,7 @@ namespace scribo
namespace internal
{
- char *debug_filename_prefix = 0;
+ std::string debug_filename_prefix = "";
} // end of namespace scribo::make::internal
@@ -80,7 +80,7 @@ namespace scribo
std::ostringstream os;
- if (internal::debug_filename_prefix != 0)
+ if (! internal::debug_filename_prefix.empty())
os << internal::debug_filename_prefix << "_";
else
mln::trace::warning("You may like to set a default filename prefix.");
diff --git a/milena/sandbox/scribo/make/text.hh b/milena/sandbox/scribo/make/text.hh
index 3c32ad0..c4a8a09 100644
--- a/milena/sandbox/scribo/make/text.hh
+++ b/milena/sandbox/scribo/make/text.hh
@@ -105,6 +105,39 @@ namespace scribo
return make::text(cboxes, lbl, nbboxes);
}
+ //FIXME: we want the following routine to construct a new util::text
+ // from another one and a relabeling function. It avoid recomputing
+ // the whole underlying data (mass centers, bboxes...)
+// template <typename L>
+// scribo::util::text<L>
+// text(const scribo::util::text<L>& text,
+// const Function_v2v<F>& f)
+// {
+// trace::entering("scribo::make::text");
+//
+// mln_precondition(text.is_valid());
+//
+// mln_value(L) new_nbboxes;
+// mln::fun::l2l::relabel<mln_value(L)> fl2l
+// = mln::make::relabelfun(f, nbboxes_, new_nbboxes);
+// lbl_ = labeling::relabel(lbl_, nbboxes_, l2l);
+// nbboxes_ = new_nbboxes;
+//
+// mln::util::array< accu::bbox<mln_site(I)> > tboxes(nbboxes_);
+// mln::util::array< accu::center<mln_site(I)> > tcenters(nbboxes_);
+// for_all_components(i, text.bboxes())
+// {
+// abboxes[fl2l(i)].take(text.bbox(i));
+// acenters[fl2l(i)].take(text.bbox(i));
+// }
+// convert::from_to(abboxes, text.bboxes());
+// convert::from_to(acenters, text.mass_centers_);
+//
+// trace::exiting("scribo::make::text");
+// return scribo::util::text<L>(;
+// }
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace scribo::make
diff --git a/milena/sandbox/scribo/scribo.mk b/milena/sandbox/scribo/scribo.mk
new file mode 100644
index 0000000..13b617a
--- /dev/null
+++ b/milena/sandbox/scribo/scribo.mk
@@ -0,0 +1,5 @@
+include $(top_srcdir)/milena/tests/tests.mk
+
+# Add path to Scribo's headers
+AM_CPPFLAGS += -I$(top_srcdir)/milena/sandbox/ -I$(top_builddir)/milena/sandbox/
+
diff --git a/milena/sandbox/scribo/src/Makefile.am b/milena/sandbox/scribo/src/Makefile.am
new file mode 100644
index 0000000..805ce84
--- /dev/null
+++ b/milena/sandbox/scribo/src/Makefile.am
@@ -0,0 +1,33 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+
+bin_PROGRAMS = \
+ dmap \
+ extract_text_single_link \
+ table_erase \
+ extract_text_double_link \
+ table_extract \
+ extract_text_double_several_links \
+ morpho \
+ extract_text_graph \
+ table_rebuild_opening \
+ extract_text_several_graph \
+ table_rebuild_rank \
+ extract_text_several_left_links \
+ thin_bboxes
+
+dmap_SOURCES = dmap.cc
+extract_text_single_link_SOURCES = extract_text_single_link.cc
+table_erase_SOURCES = table_erase.cc
+extract_text_double_link_SOURCES = extract_text_double_link.cc
+table_extract_SOURCES = table_extract.cc
+extract_text_double_several_links_SOURCES = extract_text_double_several_links.cc
+morpho_SOURCES = morpho.cc
+extract_text_graph_SOURCES = extract_text_graph.cc
+table_rebuild_opening_SOURCES = table_rebuild_opening.cc
+extract_text_several_graph_SOURCES = extract_text_several_graph.cc
+table_rebuild_rank_SOURCES = table_rebuild_rank.cc
+extract_text_several_left_links_SOURCES = extract_text_several_left_links.cc
+thin_bboxes_SOURCES = thin_bboxes.cc
+
diff --git a/milena/sandbox/scribo/src/extract_text_double_several_links.cc b/milena/sandbox/scribo/src/extract_text_double_several_links.cc
index ee7d384..1fead0a 100644
--- a/milena/sandbox/scribo/src/extract_text_double_several_links.cc
+++ b/milena/sandbox/scribo/src/extract_text_double_several_links.cc
@@ -29,6 +29,7 @@
#include <mln/essential/2d.hh>
#include <mln/debug/colorize.hh>
+#include <mln/util/timer.hh>
#include <scribo/text/extract_bboxes.hh>
#include <scribo/text/grouping/group_with_several_left_links.hh>
@@ -57,19 +58,40 @@ int main(int argc, char* argv[])
scribo::make::internal::debug_filename_prefix = "extract_text_double_several_links";
+ mln::util::timer t, t2;
image2d<bool> input;
+ std::cout << "Loading" << std::endl;
+ t.start();
io::pbm::load(input, argv[1]);
+ std::cout << t << std::endl;
+
value::label_16 nbboxes;
+ std::cout << "extract bboxes" << std::endl;
+ t.restart();
+ t2.start();
scribo::util::text<image2d<value::label_16> > text
= text::extract_bboxes(input, c8(), nbboxes);
+ std::cout << t << std::endl;
+ mln::util::timer t3;
+ std::cout << "Remove small components" << std::endl;
+ t.restart();
+ t3.start();
text = filter::small_components(text,4);
+ std::cout << t << std::endl;
+ std::cout << "Group with left link" << std::endl;
+ t.restart();
mln::util::array<unsigned> left_link
= text::grouping::group_with_several_left_links(text, 30);
+ std::cout << t << std::endl;
+
+ std::cout << "Group with right link" << std::endl;
+ t.restart();
mln::util::array<unsigned> right_link
= text::grouping::group_with_several_right_links(text, 30);
+ std::cout << t << std::endl;
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
@@ -80,8 +102,13 @@ int main(int argc, char* argv[])
scribo::make::debug_filename("links.ppm"));
// With validation.
+ std::cout << "Group from double link" << std::endl;
+ t.restart();
scribo::util::text<image2d<value::label_16> > grouped_text
= text::grouping::group_from_double_link(text, left_link, right_link);
+ std::cout << t << std::endl;
+ std::cout << "Full process: " << t2 << std::endl;
+ std::cout << "Cleanup and grouping process: " << t3 << std::endl;
io::ppm::save(mln::debug::colorize(value::rgb8(),
grouped_text.label_image(),
diff --git a/milena/sandbox/scribo/src/extract_text_multiple_links.cc b/milena/sandbox/scribo/src/extract_text_graph.cc
similarity index 91%
rename from milena/sandbox/scribo/src/extract_text_multiple_links.cc
rename to milena/sandbox/scribo/src/extract_text_graph.cc
index eacef81..fdcf54b 100644
--- a/milena/sandbox/scribo/src/extract_text_multiple_links.cc
+++ b/milena/sandbox/scribo/src/extract_text_graph.cc
@@ -30,8 +30,8 @@
#include <mln/essential/2d.hh>
#include <scribo/text/extract_bboxes.hh>
-#include <scribo/text/grouping/group_with_multiple_links.hh>
-#include <scribo/text/grouping/group_from_multiple_links.hh>
+#include <scribo/text/grouping/group_with_graph.hh>
+#include <scribo/text/grouping/group_from_graph.hh>
#include <scribo/debug/save_textbboxes_image.hh>
#include <scribo/debug/save_linked_textbboxes_image.hh>
@@ -51,7 +51,7 @@ int main(int argc, char* argv[])
if (argc < 1)
return usage(argv[0]);
- scribo::make::internal::debug_filename_prefix = "extract_text_multiple_links";
+ scribo::make::internal::debug_filename_prefix = "extract_text_graph";
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -60,7 +60,7 @@ int main(int argc, char* argv[])
scribo::util::text<image2d<value::label_16> > text
= text::extract_bboxes(input, c8(), nbboxes);
- mln::util::graph g = text::grouping::group_with_multiple_links(text, 30);
+ mln::util::graph g = text::grouping::group_with_graph(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() << std::endl;
scribo::debug::save_linked_textbboxes_image(input,
@@ -73,7 +73,7 @@ int main(int argc, char* argv[])
// scribo::make::debug_filename("lbl_before.ppm"));
scribo::util::text<image2d<value::label_16> > grouped_text
- = text::grouping::group_from_multiple_links(text, g);
+ = text::grouping::group_from_graph(text, g);
std::cout << "AFTER - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
diff --git a/milena/sandbox/scribo/src/extract_text_several_multiple_links.cc b/milena/sandbox/scribo/src/extract_text_several_graph.cc
similarity index 90%
rename from milena/sandbox/scribo/src/extract_text_several_multiple_links.cc
rename to milena/sandbox/scribo/src/extract_text_several_graph.cc
index 3c85c20..8c84bc9 100644
--- a/milena/sandbox/scribo/src/extract_text_several_multiple_links.cc
+++ b/milena/sandbox/scribo/src/extract_text_several_graph.cc
@@ -30,8 +30,8 @@
#include <mln/essential/2d.hh>
#include <scribo/text/extract_bboxes.hh>
-#include <scribo/text/grouping/group_with_several_multiple_links.hh>
-#include <scribo/text/grouping/group_from_multiple_links.hh>
+#include <scribo/text/grouping/group_with_several_graphes.hh>
+#include <scribo/text/grouping/group_from_graph.hh>
#include <scribo/debug/save_textbboxes_image.hh>
#include <scribo/debug/save_linked_textbboxes_image.hh>
@@ -51,7 +51,7 @@ int main(int argc, char* argv[])
if (argc < 1)
return usage(argv[0]);
- scribo::make::internal::debug_filename_prefix = "extract_text_several_multiple_links";
+ scribo::make::internal::debug_filename_prefix = "extract_text_several_graph";
image2d<bool> input;
io::pbm::load(input, argv[1]);
@@ -60,7 +60,7 @@ int main(int argc, char* argv[])
scribo::util::text<image2d<value::label_16> > text
= text::extract_bboxes(input, c8(), nbboxes);
- mln::util::graph g = text::grouping::group_with_several_multiple_links(text, 30);
+ mln::util::graph g = text::grouping::group_with_several_graphes(text, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes.next() << std::endl;
scribo::debug::save_linked_textbboxes_image(input,
@@ -69,7 +69,7 @@ int main(int argc, char* argv[])
scribo::make::debug_filename("left_linked.ppm"));
scribo::util::text<image2d<value::label_16> > grouped_text
- = text::grouping::group_from_multiple_links(text, g);
+ = text::grouping::group_from_graph(text, g);
std::cout << "AFTER - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
diff --git a/milena/sandbox/scribo/src/morpho.cc b/milena/sandbox/scribo/src/morpho.cc
index a527a3d..27b9f98 100644
--- a/milena/sandbox/scribo/src/morpho.cc
+++ b/milena/sandbox/scribo/src/morpho.cc
@@ -61,4 +61,4 @@ int main(int argc, char *argv[])
scribo::make::debug_filename("wsd_disk_51.ppm"));
}
-???
+}
diff --git a/milena/sandbox/scribo/src/extract_text_double_several_links.cc b/milena/sandbox/scribo/src/photo_basic.cc
similarity index 60%
copy from milena/sandbox/scribo/src/extract_text_double_several_links.cc
copy to milena/sandbox/scribo/src/photo_basic.cc
index ee7d384..baba806 100644
--- a/milena/sandbox/scribo/src/extract_text_double_several_links.cc
+++ b/milena/sandbox/scribo/src/photo_basic.cc
@@ -28,17 +28,20 @@
#include <iostream>
#include <mln/essential/2d.hh>
-#include <mln/debug/colorize.hh>
#include <scribo/text/extract_bboxes.hh>
-#include <scribo/text/grouping/group_with_several_left_links.hh>
-#include <scribo/text/grouping/group_with_several_right_links.hh>
-#include <scribo/debug/save_linked_textbboxes_image.hh>
+#include <scribo/text/grouping/group_with_single_left_link.hh>
+#include <scribo/text/grouping/group_with_single_right_link.hh>
#include <scribo/text/grouping/group_from_double_link.hh>
#include <scribo/filter/small_components.hh>
+#include <scribo/filter/large_components.hh>
+#include <scribo/filter/thin_bboxes.hh>
+#include <scribo/filter/thick_bboxes.hh>
+#include <scribo/util/text.hh>
-#include <scribo/debug/save_textbboxes_image.hh>
#include <scribo/make/debug_filename.hh>
+#include <scribo/debug/save_textbboxes_image.hh>
+#include <scribo/debug/save_linked_textbboxes_image.hh>
int usage(const char *name)
{
@@ -46,53 +49,57 @@ int usage(const char *name)
return 1;
}
-
int main(int argc, char* argv[])
{
using namespace scribo;
using namespace mln;
- if (argc < 1)
- return usage(argv[0]);
-
- scribo::make::internal::debug_filename_prefix = "extract_text_double_several_links";
+ scribo::make::internal::debug_filename_prefix = "photo_basic";
image2d<bool> input;
io::pbm::load(input, argv[1]);
+ logical::not_inplace(input);
+ typedef scribo::util::text<image2d<value::label_16> > text_t;
value::label_16 nbboxes;
- scribo::util::text<image2d<value::label_16> > text
- = text::extract_bboxes(input, c8(), nbboxes);
+ text_t textbboxes = text::extract_bboxes(input, c8(), nbboxes);
+
+ text_t filtered_textbboxes
+ = scribo::filter::small_components(textbboxes, 6);
+
+ filtered_textbboxes
+ = scribo::filter::thin_bboxes(filtered_textbboxes, 3);
+
+ filtered_textbboxes
+ = scribo::filter::thick_bboxes(filtered_textbboxes,
+ math::min(input.ncols(), input.nrows()) / 6);
- text = filter::small_components(text,4);
mln::util::array<unsigned> left_link
- = text::grouping::group_with_several_left_links(text, 30);
+ = text::grouping::group_with_single_left_link(filtered_textbboxes, 30);
mln::util::array<unsigned> right_link
- = text::grouping::group_with_several_right_links(text, 30);
+ = text::grouping::group_with_single_right_link(filtered_textbboxes, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
-
scribo::debug::save_linked_textbboxes_image(input,
- text, left_link, right_link,
+ filtered_textbboxes, left_link, right_link,
literal::red, literal::cyan, literal::yellow,
literal::green,
scribo::make::debug_filename("links.ppm"));
- // With validation.
- scribo::util::text<image2d<value::label_16> > grouped_text
- = text::grouping::group_from_double_link(text, left_link, right_link);
+ scribo::debug::save_textbboxes_image(input, filtered_textbboxes.bboxes(),
+ literal::red,
+ scribo::make::debug_filename("test_graph_filtered_text.ppm"));
+ text_t grouped_textbboxes
+ = text::grouping::group_from_double_link(filtered_textbboxes, left_link, right_link);
- io::ppm::save(mln::debug::colorize(value::rgb8(),
- grouped_text.label_image(),
- grouped_text.nbboxes()),
- scribo::make::debug_filename("label_color.ppm"));
+ std::cout << "AFTER - nbboxes = " << grouped_textbboxes.nbboxes().next() << std::endl;
- std::cout << "AFTER double grouping - nbboxes = " << grouped_text.bboxes().nelements() << std::endl;
- scribo::debug::save_textbboxes_image(input, grouped_text.bboxes(),
+ scribo::debug::save_textbboxes_image(input, grouped_textbboxes.bboxes(),
literal::red,
- scribo::make::debug_filename("bboxes.ppm"));
+ scribo::make::debug_filename("test_graph_grouped_text.ppm"));
+
}
diff --git a/milena/sandbox/scribo/src/table_extract.cc b/milena/sandbox/scribo/src/table_extract.cc
index 36142a2..273bd5d 100644
--- a/milena/sandbox/scribo/src/table_extract.cc
+++ b/milena/sandbox/scribo/src/table_extract.cc
@@ -57,7 +57,7 @@ int main(int argc, char* argv[])
trace::quiet = false;
value::label_16 ncells;
- image2d<value::label_16> tables = scribo::table::extract(input, ncells);
+ image2d<value::label_16> tables = scribo::table::extract(input, ncells).first();
std::cout << "ncells (including background) = " << ncells << std::endl;
io::ppm::save(mln::debug::colorize(value::rgb8(), tables, ncells),
diff --git a/milena/sandbox/scribo/src/table_rebuild.cc b/milena/sandbox/scribo/src/table_rebuild.cc
deleted file mode 100644
index d195b5b..0000000
--- a/milena/sandbox/scribo/src/table_rebuild.cc
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
-//
-// This file is part of the Olena Library. This library is free
-// software; you can redistribute it and/or modify it under the terms
-// of the GNU General Public License version 2 as published by the
-// Free Software Foundation.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this library; see the file COPYING. If not, write to
-// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
-// Boston, MA 02111-1307, USA.
-//
-// As a special exception, you may use this file as part of a free
-// software library without restriction. Specifically, if other files
-// instantiate templates or use macros or inline functions from this
-// file, or you compile this file and link it with other files to
-// produce an executable, this file does not by itself cause the
-// resulting executable to be covered by the GNU General Public
-// License. This exception does not however invalidate any other
-// reasons why the executable file might be covered by the GNU General
-// Public License.
-
-#include <iostream>
-
-#include <mln/essential/2d.hh>
-
-#include <scribo/table/rebuild.hh>
-#include <scribo/table/erase.hh>
-#include <scribo/table/extract_lines_with_rank.hh>
-#include <scribo/make/debug_filename.hh>
-
-
-int usage(const char *name)
-{
- std::cout << "Usage: " << name << " <input.pbm> " << std::endl;
- return 1;
-}
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace mln;
-
- if (argc < 1)
- return usage(argv[0]);
-
- scribo::make::internal::debug_filename_prefix = argv[0];
-
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
- logical::not_inplace(input);
-
- typedef util::couple<util::array<box2d>,util::array<box2d> > tblboxes_t;
-
- win::vline2d vline(51);
- win::hline2d hline(51);
- tblboxes_t lineboxes
- = table::extract_lines_with_rank(input, c8(), value::label_16(),
- vline, hline, 6, 6);
-
- value::label_8 ncells;
- image2d<value::label_8> tables = scribo::table::rebuild(input, lineboxes, 30, ncells);
-
-
- std::cout << "ncells (including background) = " << ncells << std::endl;
- io::ppm::save(mln::debug::colorize(value::rgb8(), tables, ncells),
- scribo::make::debug_filename("table_cells.ppm"));
- io::pgm::save(tables, scribo::make::debug_filename("table_cells.pgm"));
-
- image2d<bool> in_wo_tables = table::erase(input, lineboxes);
- io::pbm::save(in_wo_tables,
- scribo::make::debug_filename("input_wo_tables.pbm"));
-}
diff --git a/milena/sandbox/scribo/src/table_rebuild_opening.cc b/milena/sandbox/scribo/src/table_rebuild_opening.cc
index 375646d..0add582 100644
--- a/milena/sandbox/scribo/src/table_rebuild_opening.cc
+++ b/milena/sandbox/scribo/src/table_rebuild_opening.cc
@@ -66,7 +66,8 @@ int main(int argc, char* argv[])
vline, hline);
value::label_8 ncells;
- image2d<value::label_8> tables = scribo::table::rebuild(input, lineboxes, 30, ncells);
+ image2d<value::label_8> tables
+ = scribo::table::rebuild(input, lineboxes, 30, ncells).first();
std::cout << "ncells (including background) = " << ncells << std::endl;
diff --git a/milena/sandbox/scribo/src/table_rebuild_rank.cc b/milena/sandbox/scribo/src/table_rebuild_rank.cc
index 77b2b79..1368591 100644
--- a/milena/sandbox/scribo/src/table_rebuild_rank.cc
+++ b/milena/sandbox/scribo/src/table_rebuild_rank.cc
@@ -66,7 +66,8 @@ int main(int argc, char* argv[])
vline, hline, 6, 6);
value::label_8 ncells;
- image2d<value::label_8> tables = scribo::table::rebuild(input, lineboxes, 5, ncells);
+ image2d<value::label_8> tables
+ = scribo::table::rebuild(input, lineboxes, 5, ncells).first();
std::cout << "ncells (including background) = " << ncells << std::endl;
diff --git a/milena/sandbox/scribo/tests/Makefile.am b/milena/sandbox/scribo/tests/Makefile.am
new file mode 100644
index 0000000..2436042
--- /dev/null
+++ b/milena/sandbox/scribo/tests/Makefile.am
@@ -0,0 +1,7 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+SUBDIRS = \
+ filter \
+ table \
+ text
+
diff --git a/milena/sandbox/scribo/src/table_extract.cc b/milena/sandbox/scribo/tests/data.hh.in
similarity index 56%
copy from milena/sandbox/scribo/src/table_extract.cc
copy to milena/sandbox/scribo/tests/data.hh.in
index 36142a2..7196653 100644
--- a/milena/sandbox/scribo/src/table_extract.cc
+++ b/milena/sandbox/scribo/tests/data.hh.in
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,43 +25,15 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#include <iostream>
+#ifndef SCRIBO_TESTS_DATA_HH
+# define SCRIBO_TESTS_DATA_HH
-#include <mln/essential/2d.hh>
-#include <mln/io/dump/save.hh>
+# include <string>
-#include <scribo/table/extract.hh>
+/* Macros are evil, but they save us an extra compilation unit here
+ (as well as additional burden in Makefiles, too.). */
+/// \brief The absolute path to the img directory of Scribo.
+# define SCRIBO_IMG_DIR "@abs_top_srcdir@/milena/sandbox/scribo/tests/img"
-int usage(const char *name)
-{
- std::cout << "Usage: " << name << " <input.pbm> " << std::endl;
- return 1;
-}
-
-
-int main(int argc, char* argv[])
-{
- using namespace scribo;
- using namespace mln;
-
- if (argc < 1)
- return usage(argv[0]);
-
- scribo::make::internal::debug_filename_prefix = argv[0];
-
- image2d<bool> input;
- io::pbm::load(input, argv[1]);
- logical::not_inplace(input);
-
- trace::quiet = false;
-
- value::label_16 ncells;
- image2d<value::label_16> tables = scribo::table::extract(input, ncells);
-
- std::cout << "ncells (including background) = " << ncells << std::endl;
- io::ppm::save(mln::debug::colorize(value::rgb8(), tables, ncells),
- scribo::make::debug_filename("table_cells.ppm"));
-
- io::dump::save(tables, scribo::make::debug_filename("table_cells.dump"));
-}
+#endif // ! SCRIBO_TESTS_DATA_HH
diff --git a/milena/sandbox/scribo/tests/filter/Makefile.am b/milena/sandbox/scribo/tests/filter/Makefile.am
new file mode 100644
index 0000000..c2a02ef
--- /dev/null
+++ b/milena/sandbox/scribo/tests/filter/Makefile.am
@@ -0,0 +1,10 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+
+check_PROGRAMS = \
+ small_and_large_bboxes
+
+small_and_large_bboxes_SOURCES = small_and_large_bboxes.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/sandbox/scribo/tests/filter/small_and_large_bboxes.cc b/milena/sandbox/scribo/tests/filter/small_and_large_bboxes.cc
index 2cf7ebc..98fbcd7 100644
--- a/milena/sandbox/scribo/tests/filter/small_and_large_bboxes.cc
+++ b/milena/sandbox/scribo/tests/filter/small_and_large_bboxes.cc
@@ -30,13 +30,17 @@
#include <mln/essential/2d.hh>
#include <scribo/text/extract_bboxes.hh>
-#include <scribo/text/grouping/group_with_multiple_links.hh>
-#include <scribo/text/grouping/group_from_multiple_links.hh>
+#include <scribo/text/grouping/group_with_graph.hh>
+#include <scribo/text/grouping/group_from_graph.hh>
#include <scribo/filter/small_components.hh>
+#include <scribo/util/text.hh>
+#include <scribo/make/debug_filename.hh>
#include <scribo/debug/save_textbboxes_image.hh>
#include <scribo/debug/save_linked_textbboxes_image.hh>
+#include <scribo/tests/data.hh>
+
int usage(const char *name)
{
std::cout << "Usage: " << name << " <input.pbm> " << std::endl;
@@ -48,42 +52,47 @@ int main(int argc, char* argv[])
using namespace scribo;
using namespace mln;
- if (argc < 1)
- return usage(argv[0]);
+ std::string img;
+ if (argc < 2)
+ {
+ usage(argv[0]);
+ img = SCRIBO_IMG_DIR "/text_to_group.pbm";
+ }
+ else
+ img = argv[1];
scribo::make::internal::debug_filename_prefix = argv[0];
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ io::pbm::load(input, img.c_str());
+ typedef scribo::util::text<image2d<value::label_16> > text_t;
value::label_16 nbboxes;
- util::array<box2d> textbboxes = text::extract_bboxes(input, c8(), nbboxes);
+ text_t textbboxes = text::extract_bboxes(input, c8(), nbboxes);
- util::graph g = text::grouping::group_with_multiple_links(input,
- c8(), nbboxes,
- textbboxes, 30);
+ mln::util::graph g = text::grouping::group_with_graph(textbboxes, 30);
std::cout << "BEFORE - nbboxes = " << nbboxes << std::endl;
scribo::debug::save_linked_textbboxes_image(input,
textbboxes, g,
literal::red, literal::cyan,
- "test_multiple_links_left_linked.ppm");
+ "test_graph_left_linked.ppm");
- util::array<box2d> grouped_textbboxes
- = text::grouping::group_from_multiple_links(textbboxes, g);
+ text_t grouped_textbboxes
+ = text::grouping::group_from_graph(textbboxes, g);
- std::cout << "AFTER - nbboxes = " << grouped_textbboxes.nelements() << std::endl;
+ std::cout << "AFTER - nbboxes = " << grouped_textbboxes.nbboxes().next() << std::endl;
- scribo::debug::save_textbboxes_image(input, grouped_textbboxes,
+ scribo::debug::save_textbboxes_image(input, grouped_textbboxes.bboxes(),
literal::red,
- "test_multiple_links_grouped_text.ppm");
+ "test_graph_grouped_text.ppm");
- util::array<box2d> filtered_textbboxes
+ text_t filtered_textbboxes
= scribo::filter::small_components(grouped_textbboxes, 6);
- scribo::debug::save_textbboxes_image(input, filtered_textbboxes,
+ scribo::debug::save_textbboxes_image(input, filtered_textbboxes.bboxes(),
literal::red,
- "test_multiple_links_filtered_text.ppm");
+ "test_graph_filtered_text.ppm");
}
diff --git a/milena/sandbox/scribo/tests/table/Makefile.am b/milena/sandbox/scribo/tests/table/Makefile.am
new file mode 100644
index 0000000..1a4c5c3
--- /dev/null
+++ b/milena/sandbox/scribo/tests/table/Makefile.am
@@ -0,0 +1,12 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+
+check_PROGRAMS = \
+ extract_lines_with_rank \
+ repair_lines
+
+extract_lines_with_rank_SOURCES = extract_lines_with_rank.cc
+repair_lines_SOURCES = repair_lines.cc
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/sandbox/scribo/tests/table/extract_lines_with_rank.cc b/milena/sandbox/scribo/tests/table/extract_lines_with_rank.cc
index ed5ce3c..6b36b35 100644
--- a/milena/sandbox/scribo/tests/table/extract_lines_with_rank.cc
+++ b/milena/sandbox/scribo/tests/table/extract_lines_with_rank.cc
@@ -1,20 +1,51 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
#include <mln/essential/2d.hh>
+#include <mln/util/couple.hh>
+
#include <scribo/table/extract_lines_with_rank.hh>
#include <scribo/debug/save_table_image.hh>
-#include <mln/util/couple.hh>
+
+#include <scribo/tests/data.hh>
int main(int argc, char *argv[])
{
using namespace mln;
+ std::string img;
if (argc < 2)
- {
- std::cout << "Usage: " << argv[0] << " <image.pbm>" << std::endl;
- return 1;
- }
+ img = SCRIBO_IMG_DIR "/table_to_be_repaired.pbm";
+ else
+ img = argv[1];
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ io::pbm::load(input, img.c_str());
typedef util::couple<util::array<box2d>,
util::array<box2d> > tblboxes_t;
@@ -27,9 +58,9 @@ int main(int argc, char *argv[])
lineboxes.second().append(make::box2d(27,0, 31, 26));
lineboxes.second().append(make::box2d(27,34, 31,59));
-
+ value::label_16 nbboxes;
tblboxes_t lineboxes_test = scribo::table::extract_lines_with_rank(input, c8(),
- value::label_16(), win::vline2d(11),
+ nbboxes, win::vline2d(11),
win::hline2d(11), 2, 2);
mln_assertion(lineboxes == lineboxes_test);
diff --git a/milena/sandbox/scribo/tests/table/repair_lines.cc b/milena/sandbox/scribo/tests/table/repair_lines.cc
index ff5551c..ff7e92f 100644
--- a/milena/sandbox/scribo/tests/table/repair_lines.cc
+++ b/milena/sandbox/scribo/tests/table/repair_lines.cc
@@ -1,22 +1,53 @@
+// Copyright (C) 2009 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
#include <mln/essential/2d.hh>
+#include <mln/util/couple.hh>
+
#include <scribo/table/repair_vertical_lines.hh>
#include <scribo/table/repair_horizontal_lines.hh>
#include <scribo/table/extract_lines_with_rank.hh>
#include <scribo/debug/save_table_image.hh>
-#include <mln/util/couple.hh>
+
+#include <scribo/tests/data.hh>
int main(int argc, char *argv[])
{
using namespace mln;
+ std::string img;
if (argc < 2)
- {
- std::cout << "Usage: " << argv[0] << " <image.pbm>" << std::endl;
- return 1;
- }
+ img = SCRIBO_IMG_DIR "/table_to_be_repaired.pbm";
+ else
+ img = argv[1];
image2d<bool> input;
- io::pbm::load(input, argv[1]);
+ io::pbm::load(input, img.c_str());
typedef util::couple<util::array<box2d>,
util::array<box2d> > tblboxes_t;
diff --git a/milena/sandbox/scribo/tests/text/Makefile.am b/milena/sandbox/scribo/tests/text/Makefile.am
new file mode 100644
index 0000000..d9df32a
--- /dev/null
+++ b/milena/sandbox/scribo/tests/text/Makefile.am
@@ -0,0 +1,7 @@
+## Process this file through Automake to create Makefile.in -*- Makefile -*-
+
+include $(top_srcdir)/milena/sandbox/scribo/scribo.mk
+
+check_PROGRAMS =
+
+TESTS = $(check_PROGRAMS)
diff --git a/milena/sandbox/scribo/text/extract_lines.hh b/milena/sandbox/scribo/text/extract_lines.hh
index 6be2e37..c08a4c4 100644
--- a/milena/sandbox/scribo/text/extract_lines.hh
+++ b/milena/sandbox/scribo/text/extract_lines.hh
@@ -49,11 +49,13 @@
# include <mln/util/graph.hh>
# include <mln/value/label_16.hh>
-# include <scribo/text/grouping/group_with_multiple_links.hh>
-# include <scribo/text/grouping/group_from_multiple_links.hh>
+# include <scribo/text/grouping/group_with_several_left_links.hh>
+# include <scribo/text/grouping/group_with_several_right_links.hh>
+# include <scribo/text/grouping/group_from_double_link.hh>
# include <scribo/filter/small_components.hh>
# include <scribo/util/text.hh>
+# include <scribo/make/debug_filename.hh>
# include <scribo/debug/save_textbboxes_image.hh>
# include <scribo/debug/save_linked_textbboxes_image.hh>
@@ -95,22 +97,26 @@ namespace scribo
# ifndef SCRIBO_NDEBUG
debug::save_textbboxes_image(input, text.bboxes(), literal::red,
- scrib::make::debug_filename("character-bboxes.ppm"));
+ scribo::make::debug_filename("character-bboxes.ppm"));
# endif // ! SCRIBO_NDEBUG
//Link character bboxes to their left neighboor if possible.
- mln::util::graph g
- = text::grouping::group_with_multiple_links(text, 30);
+ mln::util::array<unsigned> left_link
+ = text::grouping::group_with_several_left_links(text, 30);
+ mln::util::array<unsigned> right_link
+ = text::grouping::group_with_several_right_links(text, 30);
+
# ifndef SCRIBO_NDEBUG
- debug::save_linked_textbboxes_image(input,
- text, g,
- literal::red, literal::cyan,
- scribo::make::debug_filename("multiple_links_left_linked.ppm"));
+ scribo::debug::save_linked_textbboxes_image(input,
+ text, left_link, right_link,
+ literal::red, literal::cyan,
+ literal::yellow, literal::green,
+ scribo::make::debug_filename("links.ppm"));
# endif // ! SCRIBO_NDEBUG
//Merge character bboxes through a graph.
scribo::util::text<mln_ch_value(I,V)> grouped_text
- = text::grouping::group_from_multiple_links(text, g);
+ = text::grouping::group_from_double_link(text, left_link, right_link);
# ifndef SCRIBO_NDEBUG
debug::save_textbboxes_image(input, grouped_text.bboxes(),
diff --git a/milena/sandbox/scribo/text/grouping/group_from_double_link.hh b/milena/sandbox/scribo/text/grouping/group_from_double_link.hh
index d4e5d71..8720c3a 100644
--- a/milena/sandbox/scribo/text/grouping/group_from_double_link.hh
+++ b/milena/sandbox/scribo/text/grouping/group_from_double_link.hh
@@ -124,6 +124,7 @@ namespace scribo
mln_assertion(bresult.nelements() == new_nbboxes.next());
+ /// FIXME: construct a new util::text from the old one.
scribo::util::text<I> result(bresult, new_lbl, new_nbboxes);
trace::exiting("scribo::text::grouping::group_from_double_link");
diff --git a/milena/sandbox/scribo/text/grouping/group_from_multiple_links.hh b/milena/sandbox/scribo/text/grouping/group_from_graph.hh
similarity index 87%
rename from milena/sandbox/scribo/text/grouping/group_from_multiple_links.hh
rename to milena/sandbox/scribo/text/grouping/group_from_graph.hh
index 059fa22..a9cfd93 100644
--- a/milena/sandbox/scribo/text/grouping/group_from_multiple_links.hh
+++ b/milena/sandbox/scribo/text/grouping/group_from_graph.hh
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_FROM_MULTIPLE_LINKS_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_FROM_MULTIPLE_LINKS_HH
+#ifndef SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
+# define SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
-/// \file scribo/text/grouping/group_from_multiple_links.hh
+/// \file scribo/text/grouping/group_from_graph.hh
///
/// Link text bounding boxes with their neighbors.
@@ -63,8 +63,8 @@ namespace scribo
/// FIXME: Add much more doc!
template <typename I, typename G>
scribo::util::text<I>
- group_from_multiple_links(const scribo::util::text<I>& text,
- const Graph<G>& g_);
+ group_from_graph(const scribo::util::text<I>& text,
+ const Graph<G>& g_);
# ifndef MLN_INCLUDE_ONLY
@@ -116,10 +116,10 @@ namespace scribo
template <typename I, typename G>
inline
scribo::util::text<I>
- group_from_multiple_links(const scribo::util::text<I>& text,
- const Graph<G>& g_)
+ group_from_graph(const scribo::util::text<I>& text,
+ const Graph<G>& g_)
{
- trace::entering("scribo::text::grouping::group_from_multiple_links");
+ trace::entering("scribo::text::grouping::group_from_graph");
const G& g = exact(g_);
@@ -151,7 +151,8 @@ namespace scribo
mln_assertion(new_nbboxes.next() == bresult.nelements());
- trace::exiting("scribo::text::grouping::group_from_multiple_links");
+ trace::exiting("scribo::text::grouping::group_from_graph");
+ /// FIXME: construct a new util::text from the old one.
return scribo::make::text(bresult, new_lbl, new_nbboxes);
}
@@ -164,4 +165,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_FROM_MULTIPLE_LINKS_HH
+#endif // ! SCRIBO_TEXT_GROUPING_GROUP_FROM_GRAPH_HH
diff --git a/milena/sandbox/scribo/text/grouping/group_from_single_link.hh b/milena/sandbox/scribo/text/grouping/group_from_single_link.hh
index 43bb7b1..3dae34f 100644
--- a/milena/sandbox/scribo/text/grouping/group_from_single_link.hh
+++ b/milena/sandbox/scribo/text/grouping/group_from_single_link.hh
@@ -96,6 +96,7 @@ namespace scribo
convert::to<fun::l2l::relabel<mln_value(I)> >(parent_array));
mln_value(I) new_nbboxes = result.nelements() - 1;
trace::exiting("scribo::text::grouping::group_from_single_link");
+ /// FIXME: construct a new util::text from the old one.
return scribo::make::text(result, lbl, new_nbboxes);
}
diff --git a/milena/sandbox/scribo/text/grouping/group_with_multiple_links.hh b/milena/sandbox/scribo/text/grouping/group_with_graph.hh
similarity index 63%
rename from milena/sandbox/scribo/text/grouping/group_with_multiple_links.hh
rename to milena/sandbox/scribo/text/grouping/group_with_graph.hh
index bfe1bc3..3089d56 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_multiple_links.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_graph.hh
@@ -27,16 +27,14 @@
// Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_MULTIPLE_LINKS_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_MULTIPLE_LINKS_HH
+#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
+# define SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
-/// \file scribo/text/grouping/group_with_multiple_links.hh
+/// \file scribo/text/grouping/group_with_graph.hh
///
-/// Group character bounding boxes with multiple links.
+/// Group character bounding boxes with a graph.
# include <mln/core/concept/image.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/accu/center.hh>
# include <mln/math/abs.hh>
@@ -44,7 +42,7 @@
# include <scribo/core/macros.hh>
# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/update_link_graph.hh>
+# include <scribo/text/grouping/internal/find_graph_link.hh>
# include <scribo/util/text.hh>
namespace scribo
@@ -56,56 +54,40 @@ namespace scribo
namespace grouping
{
- /// Group character bounding boxes with multiple links.
+ /// Group character bounding boxes with a graph.
/// Look up for neighbors on the right of each box.
template <typename L>
mln::util::graph
- group_with_multiple_links(const scribo::util::text<L>& text,
- unsigned neighb_max_distance);
+ group_with_graph(const scribo::util::text<L>& text,
+ unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
template <typename L>
inline
mln::util::graph
- group_with_multiple_links(const scribo::util::text<L>& text,
- unsigned neighb_max_distance)
+ group_with_graph(const scribo::util::text<L>& text,
+ unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_multiple_links");
+ trace::entering("scribo::text::grouping::group_with_graph");
mln::util::graph g(text.nbboxes().next());
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
for_all_ncomponents(i, text.nbboxes())
{
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln_site(L) c = centers[i];
// -------
// | |
- // | |
- // | |
// | X------->
// | |
- // | |
- // | |
// -------
- /// First site on the right of the central site
- mln_site(L) p = c + right;
-
- const L& lbl = text.label_image();
- while (lbl.domain().has(p) && (lbl(p) == literal::zero || lbl(p) == i)
- && math::abs(p.col() - c.col()) < dmax)
- ++p.col();
-
- internal::update_link_graph(lbl, g, p, c, i, dmax);
+ internal::find_graph_link(g, text, i, dmax, text.mass_center(i));
}
- trace::exiting("scribo::text::grouping::group_with_multiple_links");
+ trace::exiting("scribo::text::grouping::group_with_graph");
return g;
}
@@ -117,4 +99,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_MULTIPLE_LINKS_HH
+#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_GRAPH_HH
diff --git a/milena/sandbox/scribo/text/grouping/group_with_several_multiple_links.hh b/milena/sandbox/scribo/text/grouping/group_with_several_graphes.hh
similarity index 71%
rename from milena/sandbox/scribo/text/grouping/group_with_several_multiple_links.hh
rename to milena/sandbox/scribo/text/grouping/group_with_several_graphes.hh
index 4dec5c7..d50b837 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_several_multiple_links.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_several_graphes.hh
@@ -27,12 +27,12 @@
// Public License.
-#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_MULTIPLE_LINKS_HH
-# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_MULTIPLE_LINKS_HH
+#ifndef SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
+# define SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
-/// \file scribo/text/grouping/group_with_several_multiple_links.hh
+/// \file scribo/text/grouping/group_with_several_graphes.hh
///
-/// Group character bounding boxes with several multiple links.
+/// Group character bounding boxes with several graphes.
# include <mln/core/concept/image.hh>
# include <mln/labeling/compute.hh>
@@ -44,8 +44,7 @@
# include <scribo/core/macros.hh>
# include <scribo/text/grouping/internal/init_link_array.hh>
-# include <scribo/text/grouping/internal/update_link_graph.hh>
-# include <scribo/text/grouping/internal/find_left_graph_link.hh>
+# include <scribo/text/grouping/internal/find_graph_link.hh>
# include <scribo/util/text.hh>
namespace scribo
@@ -57,11 +56,11 @@ namespace scribo
namespace grouping
{
- /// Group character bounding boxes with several_multiple links.
+ /// Group character bounding boxes with several graphes.
/// Look up for neighbors on the left of each box.
template <typename L>
mln::util::graph
- group_with_several_multiple_links(const scribo::util::text<L>& text,
+ group_with_several_graphes(const scribo::util::text<L>& text,
unsigned neighb_max_distance);
# ifndef MLN_INCLUDE_ONLY
@@ -69,22 +68,19 @@ namespace scribo
template <typename L>
inline
mln::util::graph
- group_with_several_multiple_links(const scribo::util::text<L>& text,
+ group_with_several_graphes(const scribo::util::text<L>& text,
unsigned neighb_max_distance)
{
- trace::entering("scribo::text::grouping::group_with_several_multiple_links");
+ trace::entering("scribo::text::grouping::group_with_several_graphes");
mln::util::graph g(text.nbboxes().next());
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
for_all_ncomponents(i, text.nbboxes())
{
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln_site(L) c = centers[i];
+ mln_site(L) c = text.mass_center(i);
// -------
// | X------->
@@ -96,22 +92,25 @@ namespace scribo
// | X------->
// -------
+ // FIXME: may create several times the same edge.
+ // We should use an adjacency matrix when available.
+
/// Left link from the top anchor.
mln_site(L) a1 = c;
a1.row() = text.bbox(i).pmin().row() + (c.row() - text.bbox(i).pmin().row()) / 4;
- internal::find_left_graph_link(g, text, i, dmax, a1);
+ internal::find_graph_link(g, text, i, dmax, a1);
/// First site on the right of the central site
- internal::find_left_graph_link(g, text, i, dmax, c);
+ internal::find_graph_link(g, text, i, dmax, c);
/// Left link from the bottom anchor.
mln_site(L) a2 = c;
a2.row() = text.bbox(i).pmax().row() - (c.row() - text.bbox(i).pmin().row()) / 4;
- internal::find_left_graph_link(g, text, i, dmax, a2);
+ internal::find_graph_link(g, text, i, dmax, a2);
}
- trace::exiting("scribo::text::grouping::group_with_several_multiple_links");
+ trace::exiting("scribo::text::grouping::group_with_several_graphes");
return g;
}
@@ -123,4 +122,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_MULTIPLE_LINKS_HH
+#endif // ! SCRIBO_TEXT_GROUPING_GROUP_WITH_SEVERAL_GRAPHES_HH
diff --git a/milena/sandbox/scribo/text/grouping/group_with_several_left_links.hh b/milena/sandbox/scribo/text/grouping/group_with_several_left_links.hh
index 84a743d..666a283 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_several_left_links.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_several_left_links.hh
@@ -38,8 +38,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/accu/center.hh>
# include <mln/util/array.hh>
@@ -88,22 +86,17 @@ namespace scribo
internal::init_link_array(link_2);
internal::init_link_array(link_3);
- //FIXME: should be removed if this information is stored in util::text.
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
- std::cout << "dmax = " << neighb_max_distance << std::endl;
for_all_ncomponents(i, text.nbboxes())
{
- // -------
- // | X------->
- // | |
- // | |
- // | X------->
- // | |
- // | |
- // | X------->
- // -------
+ // -------
+ // <------X |
+ // | |
+ // | |
+ // <------X |
+ // | |
+ // | |
+ // <------X |
+ // -------
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
@@ -116,7 +109,7 @@ namespace scribo
internal::find_left_link(text, link_1, i, dmax, a1);
/// Left link from the central site
- internal::find_left_link(text, link_2, i, dmax, centers[i]);
+ internal::find_left_link(text, link_2, i, dmax, text.mass_center(i));
/// Left link from the bottom anchor.
mln_site(L) a2 = c;
diff --git a/milena/sandbox/scribo/text/grouping/group_with_several_right_links.hh b/milena/sandbox/scribo/text/grouping/group_with_several_right_links.hh
index cc2ee2c..f7d38a7 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_several_right_links.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_several_right_links.hh
@@ -38,8 +38,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/compute.hh>
-# include <mln/accu/center.hh>
# include <mln/util/array.hh>
@@ -88,22 +86,17 @@ namespace scribo
internal::init_link_array(link_2);
internal::init_link_array(link_3);
- //FIXME: should be removed if this information is stored in util::text.
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
- std::cout << "dmax = " << neighb_max_distance << std::endl;
for_all_ncomponents(i, text.nbboxes())
{
- // -------
- // <------X |
- // | |
- // | |
- // <------X |
- // | |
- // | |
- // <------X |
- // -------
+ // -------
+ // | X------->
+ // | |
+ // | |
+ // | X------->
+ // | |
+ // | |
+ // | X------->
+ // -------
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
@@ -116,7 +109,7 @@ namespace scribo
internal::find_right_link(text, link_1, i, dmax, a1);
/// Right link from the central site
- internal::find_right_link(text, link_2, i, dmax, centers[i]);
+ internal::find_right_link(text, link_2, i, dmax, text.mass_center(i));
/// Right link from the bottom anchor.
mln_site(L) a2 = c;
diff --git a/milena/sandbox/scribo/text/grouping/group_with_single_left_link.hh b/milena/sandbox/scribo/text/grouping/group_with_single_left_link.hh
index 1b39485..7375c93 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_single_left_link.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_single_left_link.hh
@@ -38,7 +38,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/compute.hh>
# include <mln/math/abs.hh>
@@ -87,15 +86,12 @@ namespace scribo
mln::util::array<unsigned> left_link(text.nbboxes().next());
internal::init_link_array(left_link);
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
for_all_ncomponents(i, text.nbboxes())
{
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln_site(L) c = centers[i];
+ mln_site(L) c = text.mass_center(i);
/// Find a neighbor on the left
internal::find_left_link(text, left_link, i, dmax, c);
diff --git a/milena/sandbox/scribo/text/grouping/group_with_single_right_link.hh b/milena/sandbox/scribo/text/grouping/group_with_single_right_link.hh
index 6327d9f..0ad091f 100644
--- a/milena/sandbox/scribo/text/grouping/group_with_single_right_link.hh
+++ b/milena/sandbox/scribo/text/grouping/group_with_single_right_link.hh
@@ -38,7 +38,6 @@
# include <mln/core/concept/image.hh>
# include <mln/core/concept/neighborhood.hh>
-# include <mln/labeling/compute.hh>
# include <mln/math/abs.hh>
@@ -89,15 +88,12 @@ namespace scribo
mln::util::array<unsigned> right_link(text.nbboxes().next());
internal::init_link_array(right_link);
- mln::util::array<mln_site(L)::vec> centers
- = labeling::compute(accu::meta::center(), text.label_image(), text.nbboxes());
-
for_all_ncomponents(i, text.nbboxes())
{
unsigned midcol = (text.bbox(i).pmax().col()
- text.bbox(i).pmin().col()) / 2;
int dmax = midcol + neighb_max_distance;
- mln_site(L) c = centers[i];
+ mln_site(L) c = text.mass_center(i);
///
/// Find a neighbor on the right
diff --git a/milena/sandbox/scribo/text/grouping/internal/find_left_graph_link.hh b/milena/sandbox/scribo/text/grouping/internal/find_graph_link.hh
similarity index 68%
rename from milena/sandbox/scribo/text/grouping/internal/find_left_graph_link.hh
rename to milena/sandbox/scribo/text/grouping/internal/find_graph_link.hh
index 4055ea1..95edebb 100644
--- a/milena/sandbox/scribo/text/grouping/internal/find_left_graph_link.hh
+++ b/milena/sandbox/scribo/text/grouping/internal/find_graph_link.hh
@@ -26,21 +26,22 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_FIND_LEFT_GRAPH_LINK_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_LEFT_GRAPH_LINK_HH
+#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
+# define SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
-/// \file scribo/text/grouping/internal/find_left_graph_link.hh
+/// \file scribo/text/grouping/internal/find_graph_link.hh
///
///
# include <mln/core/concept/image.hh>
+# include <mln/core/concept/graph.hh>
# include <mln/math/abs.hh>
# include <mln/util/array.hh>
# include <scribo/util/text.hh>
-# include <scribo/text/grouping/internal/update_link_graph.hh>
+# include <scribo/text/grouping/internal/update_graph_link.hh>
//FIXME: not generic.
# include <mln/core/alias/dpoint2d.hh>
@@ -57,35 +58,43 @@ namespace scribo
namespace internal
{
- template <typename L>
+ template <typename G, typename L>
void
- find_left_graph_link(const scribo::util::text<L>& text,
- mln::util::array<unsigned>& left_link,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c);
+ find_graph_link(Graph<G>& g_,
+ const scribo::util::text<L>& text,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c);
# ifndef MLN_INCLUDE_ONLY
- template <typename L>
+ template <typename G, typename L>
void
- find_left_graph_link(mln::util::graph& g,
- const scribo::util::text<L>& text,
- unsigned current_comp,
- int dmax,
- const mln_site(L)& c)
+ find_graph_link(Graph<G>& g_,
+ const scribo::util::text<L>& text,
+ unsigned current_comp,
+ int dmax,
+ const mln_site(L)& c)
{
+ trace::entering("scribo::text::grouping::internal::find_graph_link");
+
+ G& g = exact(g_);
+ mln_precondition(g.is_valid());
+ mln_precondition(text.is_valid());
+
///FIXME: the following code is not generic...
/// First site on the right of the central site
- mln_site(L) p = c + left;
+ mln_site(L) p = c + right;
const L& lbl = text.label_image();
while (lbl.domain().has(p) && (lbl(p) == literal::zero
|| lbl(p) == current_comp)
&& math::abs(p.col() - c.col()) < dmax)
- --p.col();
+ ++p.col();
+
+ update_graph_link(lbl, g, p, c, current_comp, dmax);
- update_link_graph(lbl, g, p, c, current_comp, dmax);
+ trace::exiting("scribo::text::grouping::internal::find_graph_link");
}
# endif // MLN_INCLUDE_ONLY
@@ -99,4 +108,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_LEFT_GRAPH_LINK_HH
+#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_FIND_GRAPH_LINK_HH
diff --git a/milena/sandbox/scribo/text/grouping/internal/update_link_graph.hh b/milena/sandbox/scribo/text/grouping/internal/update_graph_link.hh
similarity index 79%
rename from milena/sandbox/scribo/text/grouping/internal/update_link_graph.hh
rename to milena/sandbox/scribo/text/grouping/internal/update_graph_link.hh
index f572a47..6373678 100644
--- a/milena/sandbox/scribo/text/grouping/internal/update_link_graph.hh
+++ b/milena/sandbox/scribo/text/grouping/internal/update_graph_link.hh
@@ -27,15 +27,15 @@
// Public License.
-#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_GRAPH_HH
-# define SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_GRAPH_HH
+#ifndef SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
+# define SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
/// \file scribo/text/grouping/internal/update_link_array.hh
///
/// Update graph edges if a valid neighbor is found.
# include <mln/core/concept/image.hh>
-# include <mln/util/graph.hh>
+# include <mln/core/concept/graph.hh>
namespace scribo
{
@@ -50,9 +50,9 @@ namespace scribo
{
/// Update graph edges if a valid neighbor is found.
- template <typename I>
+ template <typename I, typename G>
void
- update_link_graph(const Image<I>& lbl_, mln::util::graph& g,
+ update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
const mln_site(I)& p, const mln_site(I)& c,
unsigned i, int dmax);
@@ -60,21 +60,27 @@ namespace scribo
# ifndef MLN_INCLUDE_ONLY
- template <typename I>
+ template <typename I, typename G>
inline
void
- update_link_graph(const Image<I>& lbl_, mln::util::graph& g,
+ update_graph_link(const Image<I>& lbl_, Graph<G>& g_,
const mln_site(I)& p, const mln_site(I)& c,
unsigned i, int dmax)
{
+ trace::entering("scribo::text::grouping::internal::update_graph_link");
+
const I& lbl = exact(lbl_);
+ G& g = exact(g_);
mlc_is_a(mln_value(I), mln::value::Symbolic)::check();
mln_precondition(exact(lbl).is_valid());
+ mln_precondition(g.is_valid());
if (lbl.domain().has(p) && lbl(p) != literal::zero && lbl(p) != i
&& (math::abs(p.col() - c.col())) < dmax)
g.add_edge(lbl(p), i);
+
+ trace::exiting("scribo::text::grouping::internal::update_graph_link");
}
@@ -89,4 +95,4 @@ namespace scribo
} // end of namespace scribo
-#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_LINK_GRAPH_HH
+#endif // ! SCRIBO_TEXT_GROUPING_INTERNAL_UPDATE_GRAPH_LINK_HH
diff --git a/milena/sandbox/scribo/util/text.hh b/milena/sandbox/scribo/util/text.hh
index 2619a79..531d735 100644
--- a/milena/sandbox/scribo/util/text.hh
+++ b/milena/sandbox/scribo/util/text.hh
@@ -36,6 +36,8 @@
# include <mln/core/image/image2d.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/site_set/box.hh>
+# include <mln/accu/center.hh>
+# include <mln/labeling/compute.hh>
# include <mln/value/label_16.hh>
# include <mln/util/couple.hh>
# include <mln/util/array.hh>
@@ -55,14 +57,19 @@ namespace scribo
public:
typedef mln_site(L) site;
typedef mln::util::array<box<site> > boxes_t;
+ typedef mln::util::array<mln_site(L)::vec> mass_centers_t;
text();
text(const mln::util::array<box<mln_site(L)> >& bboxes,
+ const Image<L>& lbl,
+ const mln_value(L)& nbboxes,
+ const mln::util::array<mln_site(L)::vec>& mass_centers);
+ text(const mln::util::array<box<mln_site(L)> >& bboxes,
const Image<L>& lbl,
const mln_value(L)& nbboxes);
const L& label_image() const;
- L& label_image();
+ void set_label_image(const Image<L>& lbl);
const mln_value(L)& nbboxes() const;
mln_value(L)& nbboxes();
@@ -73,10 +80,16 @@ namespace scribo
const box<mln_site(L)>& bbox(unsigned i) const;
box<mln_site(L)>& bbox(unsigned i);
+ const mln::util::array<mln_site(L)::vec>& mass_centers() const;
+ mln_site(L) mass_center(unsigned i) const;
+
bool is_valid() const;
private:
+ void update();
+
boxes_t bboxes_;
+ mass_centers_t mass_centers_;
L lbl_;
mln_value(L) nbboxes_;
};
@@ -95,26 +108,31 @@ namespace scribo
inline
text<L>::text(const mln::util::array<box<mln_site(L)> >& bboxes,
const Image<L>& lbl,
- const mln_value(L)& nbboxes)
- : bboxes_(bboxes), lbl_(exact(lbl)), nbboxes_(nbboxes)
+ const mln_value(L)& nbboxes,
+ const mln::util::array<mln_site(L)::vec>& mass_centers)
+ : bboxes_(bboxes), mass_centers_(mass_centers),
+ lbl_(exact(lbl)), nbboxes_(nbboxes)
{
mln_assertion(bboxes.nelements() == nbboxes.next());
}
template <typename L>
inline
- const L&
- text<L>::label_image() const
+ text<L>::text(const mln::util::array<box<mln_site(L)> >& bboxes,
+ const Image<L>& lbl,
+ const mln_value(L)& nbboxes)
+ : bboxes_(bboxes), lbl_(exact(lbl)), nbboxes_(nbboxes)
{
- mln_precondition(lbl_.is_valid());
- return lbl_;
+ mln_assertion(bboxes.nelements() == nbboxes.next());
+ update();
}
template <typename L>
inline
- L&
- text<L>::label_image()
+ const L&
+ text<L>::label_image() const
{
+ mln_precondition(lbl_.is_valid());
return lbl_;
}
@@ -173,12 +191,35 @@ namespace scribo
template <typename L>
inline
+ const mln::util::array<mln_site(L)::vec>&
+ text<L>::mass_centers() const
+ {
+ return mass_centers_;
+ }
+
+ template <typename L>
+ inline
+ mln_site(L)
+ text<L>::mass_center(unsigned i) const
+ {
+ return mass_centers_[i];
+ }
+
+ template <typename L>
+ inline
bool
text<L>::is_valid() const
{
return lbl_.is_valid() && bboxes_.nelements() == nbboxes_.next();
}
+ template <typename L>
+ inline
+ void
+ text<L>::update()
+ {
+ mass_centers_ = labeling::compute(accu::meta::center(), lbl_, nbboxes_);
+ }
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0
* doc/tutorial/tutorial.tex: Fix a compilation issue.
* headers.mk: update distributed file list.
* mln/win/ball.hh,
* mln/core/concept/function.hh: avoid a warning.
* mln/util/array.hh,
* mln/fun/i2v/array.hh: revert invalid from_to overloads.
* mln/fun/internal/array_base.hh: add reserve().
* mln/fun/l2l/relabel.hh: reserve data before appending.
* mln/io/pnm/save.hh: Allow images of builtin types to be saved.
* tests/geom/Makefile.am,
* tests/morpho/Makefile.am,
* tests/util/Makefile.am: do not set tests as xfail tests anymore.
* tests/unit_test/unit-tests.mk: update unit test list.
---
milena/ChangeLog | 26 ++++++++++++++++++++++++++
milena/doc/tutorial/tutorial.tex | 2 +-
milena/headers.mk | 2 ++
milena/mln/core/concept/function.hh | 3 ++-
milena/mln/fun/i2v/array.hh | 18 ++----------------
milena/mln/fun/internal/array_base.hh | 11 +++++++++++
milena/mln/fun/l2l/relabel.hh | 2 ++
milena/mln/io/pnm/save.hh | 18 ++++++++++++++----
milena/mln/util/array.hh | 8 +-------
milena/mln/win/ball.hh | 2 +-
milena/tests/geom/Makefile.am | 2 --
milena/tests/morpho/Makefile.am | 3 +--
milena/tests/unit_test/unit-tests.mk | 4 ++++
milena/tests/util/Makefile.am | 3 +--
14 files changed, 68 insertions(+), 36 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index d793fb8..fbcafd8 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,29 @@
+2009-03-25 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes.
+
+ * doc/tutorial/tutorial.tex: Fix a compilation issue.
+
+ * headers.mk: update distributed file list.
+
+ * mln/win/ball.hh,
+ * mln/core/concept/function.hh: avoid a warning.
+
+ * mln/util/array.hh,
+ * mln/fun/i2v/array.hh: revert invalid from_to overloads.
+
+ * mln/fun/internal/array_base.hh: add reserve().
+
+ * mln/fun/l2l/relabel.hh: reserve data before appending.
+
+ * mln/io/pnm/save.hh: Allow images of builtin types to be saved.
+
+ * tests/geom/Makefile.am,
+ * tests/morpho/Makefile.am,
+ * tests/util/Makefile.am: do not set tests as xfail tests anymore.
+
+ * tests/unit_test/unit-tests.mk: update unit test list.
+
2009-03-25 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Clean binarisation processing chain using sharpness.
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index ede9d90..37c37ce 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -486,7 +486,7 @@ and/or use the other documentations ressources (\ref{tuto1documentation}).
Milena's packages can be downloaded from:
-\href{http://www.lrde.epita.fr/Olena/Download}
+\href{http://www.lrde.epita.fr/Olena/Download}{http://www.lrde.epita.fr/Olena/Download}
On this page you will find the latest and past releases.
Currently, we provide only '.tar.gz' and 'tar.bz2' archives.
diff --git a/milena/headers.mk b/milena/headers.mk
index 1a20506..fd5844c 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -55,6 +55,8 @@ mln/literal/one.hh \
mln/literal/min.hh \
mln/literal/white.hh \
mln/literal/essential.hh \
+mln/world/binary_2d/subsample.hh \
+mln/world/binary_2d/projected_histo.hh \
mln/registration/get_rtransf.hh \
mln/registration/internal/rms.hh \
mln/registration/get_rot.hh \
diff --git a/milena/mln/core/concept/function.hh b/milena/mln/core/concept/function.hh
index ff3015f..7cef23c 100644
--- a/milena/mln/core/concept/function.hh
+++ b/milena/mln/core/concept/function.hh
@@ -507,7 +507,8 @@ namespace mln
template <typename E>
inline
Function_i2b<E>::Function_i2b(const Function_i2b<E>& rhs)
- : Function_v2b<E>(rhs)
+ : Function_v2v<E>(rhs),
+ Function_v2b<E>(rhs)
{
}
diff --git a/milena/mln/fun/i2v/array.hh b/milena/mln/fun/i2v/array.hh
index c140cc3..91fe792 100644
--- a/milena/mln/fun/i2v/array.hh
+++ b/milena/mln/fun/i2v/array.hh
@@ -196,14 +196,7 @@ namespace mln
mlc_converts_to(T,U)::check();
to.reserve(from.nelements());
-
- //Special case. Handle background component data.
- if (from[0].is_valid())
- to.append(convert::to<U>(from[0]));
- else
- to.append(U());
-
- for (unsigned i = 1; i < from.nelements(); ++i)
+ for (unsigned i = 0; i < from.nelements(); ++i)
to.append(convert::to<U>(from[i]));
}
@@ -223,14 +216,7 @@ namespace mln
mlc_converts_to(T,U)::check();
to.reserve(from.nelements());
-
- //Special case. Handle background component data.
- if (from[0].is_valid())
- to.append(convert::to<U>(from[0]));
- else
- to.append(U());
-
- for (unsigned i = 1; i < from.size(); ++i)
+ for (unsigned i = 0; i < from.size(); ++i)
to.append(convert::to<U>(from[i]));
}
diff --git a/milena/mln/fun/internal/array_base.hh b/milena/mln/fun/internal/array_base.hh
index 637fab7..d288c53 100644
--- a/milena/mln/fun/internal/array_base.hh
+++ b/milena/mln/fun/internal/array_base.hh
@@ -57,6 +57,9 @@ namespace mln
typedef T result;
typedef typename std::vector<T>::reference mutable_result;
+ /// Pre-allocate space.
+ void reserve(unsigned n);
+
/// Set the function size to \p n.
void resize(unsigned n);
/// Set the function size to \p n and initialize the value with
@@ -156,6 +159,14 @@ namespace mln
template <typename T>
inline
void
+ array_base<T>::reserve(unsigned n)
+ {
+ v_.reserve(n);
+ }
+
+ template <typename T>
+ inline
+ void
array_base<T>::resize(unsigned n)
{
v_.resize(n);
diff --git a/milena/mln/fun/l2l/relabel.hh b/milena/mln/fun/l2l/relabel.hh
index a57f3d4..ef03973 100644
--- a/milena/mln/fun/l2l/relabel.hh
+++ b/milena/mln/fun/l2l/relabel.hh
@@ -174,6 +174,7 @@ namespace mln
{
mlc_converts_to(T,L)::check();
+ to.reserve(from.nelements());
for (unsigned i = 0; i < from.nelements(); ++i)
to.append(convert::to<L>(from[i]));
}
@@ -193,6 +194,7 @@ namespace mln
{
mlc_converts_to(T,L)::check();
+ to.reserve(from.size());
for (unsigned i = 0; i < from.size(); ++i)
to.append(convert::to<L>(from[i]));
}
diff --git a/milena/mln/io/pnm/save.hh b/milena/mln/io/pnm/save.hh
index 12dda4b..5989c92 100644
--- a/milena/mln/io/pnm/save.hh
+++ b/milena/mln/io/pnm/save.hh
@@ -39,12 +39,14 @@
# include <mln/core/concept/image.hh>
# include <mln/core/alias/point2d.hh>
+# include <mln/value/concept/scalar.hh>
# include <mln/value/rgb.hh>
# include <mln/value/rgb8.hh>
# include <mln/value/int_u8.hh>
# include <mln/metal/templated_by.hh>
+# include <mln/metal/not_equal.hh>
# include <mln/io/pnm/save_header.hh>
# include <mln/io/pnm/macros.hh>
@@ -100,11 +102,19 @@ namespace mln
void write_value(std::ofstream& file,
const V& v)
{
- // if V is not a struct you are probably trying to write binary images
- // use pbm files for binary images
- typedef typename V::enc E;
+ mlc_not_equal(V,bool)::check();
+ file.write((char*)(&v), sizeof(V));
+ }
+
+ // write a scalar value into for uncontiguous datas
+ template <typename S>
+ inline
+ void write_value(std::ofstream& file,
+ const value::Scalar<S>& s)
+ {
+ typedef typename S::enc E;
- E c = v.to_enc();
+ E c = s.to_enc();
file.write((char*)(&c), sizeof(E));
}
diff --git a/milena/mln/util/array.hh b/milena/mln/util/array.hh
index 9e646a5..0363727 100644
--- a/milena/mln/util/array.hh
+++ b/milena/mln/util/array.hh
@@ -337,13 +337,7 @@ namespace mln
to.reserve(from.nelements());
- //Special case. Handle background component data.
- if (from[0].is_valid())
- to.append(convert::to<T2>(from[0]));
- else
- to.append(T2());
-
- for (unsigned i = 1; i < from.nelements(); ++i)
+ for (unsigned i = 0; i < from.nelements(); ++i)
to.append(convert::to<T2>(from[i]));
}
diff --git a/milena/mln/win/ball.hh b/milena/mln/win/ball.hh
index 8497237..4dd4807 100644
--- a/milena/mln/win/ball.hh
+++ b/milena/mln/win/ball.hh
@@ -100,7 +100,7 @@ namespace mln
: diameter_(diameter)
{
mln_precondition(diameter % 2 == 1);
- int
+ unsigned
radius = diameter / 2,
sqr_radius = radius * radius;
typedef point<G,C> P;
diff --git a/milena/tests/geom/Makefile.am b/milena/tests/geom/Makefile.am
index 728d9a8..c162770 100644
--- a/milena/tests/geom/Makefile.am
+++ b/milena/tests/geom/Makefile.am
@@ -42,5 +42,3 @@ seed2tiling_roundness_SOURCES = seed2tiling_roundness.cc
TESTS = $(check_PROGRAMS)
-
-XFAIL_TESTS = seed2tiling_roundness
diff --git a/milena/tests/morpho/Makefile.am b/milena/tests/morpho/Makefile.am
index 6f9008c..fb5f467 100644
--- a/milena/tests/morpho/Makefile.am
+++ b/milena/tests/morpho/Makefile.am
@@ -86,5 +86,4 @@ meyer_wst_long_CXXFLAGS = $(TESTS_CXXFLAGS_SPEED)
TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = combined \
- thinning
+
diff --git a/milena/tests/unit_test/unit-tests.mk b/milena/tests/unit_test/unit-tests.mk
index d88724b..c6bf5dd 100644
--- a/milena/tests/unit_test/unit-tests.mk
+++ b/milena/tests/unit_test/unit-tests.mk
@@ -53,6 +53,8 @@ mln_literal_one \
mln_literal_min \
mln_literal_white \
mln_literal_essential \
+mln_world_binary_2d_subsample \
+mln_world_binary_2d_projected_histo \
mln_registration_get_rtransf \
mln_registration_internal_rms \
mln_registration_get_rot \
@@ -1170,6 +1172,8 @@ mln_literal_one_SOURCES = mln_literal_one.cc
mln_literal_min_SOURCES = mln_literal_min.cc
mln_literal_white_SOURCES = mln_literal_white.cc
mln_literal_essential_SOURCES = mln_literal_essential.cc
+mln_world_binary_2d_subsample_SOURCES = mln_world_binary_2d_subsample.cc
+mln_world_binary_2d_projected_histo_SOURCES = mln_world_binary_2d_projected_histo.cc
mln_registration_get_rtransf_SOURCES = mln_registration_get_rtransf.cc
mln_registration_internal_rms_SOURCES = mln_registration_internal_rms.cc
mln_registration_get_rot_SOURCES = mln_registration_get_rot.cc
diff --git a/milena/tests/util/Makefile.am b/milena/tests/util/Makefile.am
index b348587..c1d6c4d 100644
--- a/milena/tests/util/Makefile.am
+++ b/milena/tests/util/Makefile.am
@@ -39,5 +39,4 @@ tree_to_fast_SOURCES = tree_to_fast.cc
tree_to_image_SOURCES = tree_to_image.cc
TESTS = $(check_PROGRAMS)
-XFAIL_TESTS = tree_to_image \
- tree_fast_to_image
+
--
1.5.6.5
1
0
25 Mar '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-03-25 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Clean binarisation processing chain using sharpness.
* sandbox/edwin/tree/run.hh: Add trace entering/exiting functions.
* sandbox/edwin/tree/sharp.cc: Clean file.
---
Makefile | 3 +
configure | 4 ++
run.hh | 16 ++++++++-
sharp.cc | 108 +++++++++++++++++++++++++++++++++++++++-----------------------
4 files changed, 88 insertions(+), 43 deletions(-)
Index: trunk/milena/sandbox/edwin/tree/configure
===================================================================
--- trunk/milena/sandbox/edwin/tree/configure (revision 3576)
+++ trunk/milena/sandbox/edwin/tree/configure (revision 3577)
@@ -5,6 +5,10 @@
if [ "$arg" == "--debug" ]; then
debug=1;
fi
+
+ if [ "$arg" == "--release" ]; then
+ release=1;
+ fi
done
rm -f makefile.rules
@@ -12,3 +16,6 @@
if [ "$debug" ]; then
echo 'DEBUG=1' > makefile.rules
fi
\ No newline at end of file
+if [ "$release" ]; then
+ echo 'RELEASE=1' > makefile.rules
+fi
\ No newline at end of file
Index: trunk/milena/sandbox/edwin/tree/sharp.cc
===================================================================
--- trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3576)
+++ trunk/milena/sandbox/edwin/tree/sharp.cc (revision 3577)
@@ -24,7 +24,7 @@
/* io */
#include <mln/io/pgm/load.hh>
#include <mln/io/pgm/save.hh>
-#include <mln/io/ppm/save.hh>
+#include <mln/io/pbm/save.hh>
#include <../../theo/color/change_attributes.hh>
/* data & pw */
@@ -34,11 +34,8 @@
#include <mln/data/paste.hh>
#include <mln/pw/all.hh>
-/* labeling */
-#include <mln/value/label.hh>
-#include <mln/labeling/blobs.hh>
-#include <mln/debug/colorize.hh>
-
+/* trace */
+#include <mln/trace/quiet.hh>
/* std */
#include <string>
@@ -49,11 +46,11 @@
void usage(char** argv)
{
- std::cerr << "usage: " << argv[0] << " input [--debug]" << std::endl;
+ std::cerr << "usage: " << argv[0] << " input [--debug] [-n nbr_components | -s sharpness] [-c card]" << std::endl;
abort();
}
-void dsp(const char* str)
+void dsp(const std::string& str)
{
std::cout << std::endl
<< "*********************" << std::endl
@@ -67,11 +64,30 @@
{
using namespace mln;
using value::int_u8;
+ std::string arg;
+ unsigned nb_components = 0;
+ unsigned card = 0;
+ double sharpness = 0;
if (argc < 2)
usage(argv);
- mydebug = (argc >= 3 && std::string(argv[2]) == "--debug");
+ for (int i = 2; i < argc; i++)
+ {
+ arg = std::string(argv[i]);
+ if (arg == "--debug")
+ mydebug = true;
+ else if (arg == "-n" && i != argc)
+ nb_components = atoi(argv[++i]);
+ else if (arg == "-s" && i != argc)
+ sharpness = atof(argv[++i]);
+ else if (arg == "-c" && i != argc)
+ card = atoi(argv[++i]);
+ else if (arg == "--trace")
+ trace::quiet = false;
+ else
+ usage (argv);
+ }
/* Image loadin' */
@@ -91,13 +107,12 @@
typedef morpho::attribute::sharpness<I> sharp_t;
typedef mln_ch_value_(I, double) A;
+ if (mydebug)
+ dsp("Image sharp attribute");
+
A a = morpho::tree::compute_attribute_image(sharp_t (), tree);
morpho::tree::propagate_representant(tree, a);
- if (mydebug) {
- dsp("Image sharp attribute"); display_tree_attributes(tree, a);
- }
-
/* We don't want little components */
// So we compute card attribute and we filter big components
@@ -106,30 +121,41 @@
// optional extra argument to compute_attribute where the
// accumulators image will be stored.
+ if (card)
+ {
typedef morpho::attribute::card<I> card_t;
typedef mln_ch_value_(tree_t::function, mln_result_(card_t)) B;
+ if (mydebug)
+ dsp("Image card attribute");
+
B b = morpho::tree::compute_attribute_image(card_t (), tree);
morpho::tree::propagate_representant(tree, b);
- if (mydebug) {
- dsp("Image card attribute"); display_tree_attributes(tree, b);
+ a = duplicate((fun::p2v::ternary(pw::value(b) > pw::cst(card), pw::value(a), pw::cst(0.0))) | a.domain());
}
- a = duplicate((fun::p2v::ternary(pw::value(b) > pw::cst(100), pw::value(a), pw::cst(0.0))) | a.domain());
-
-
/* Run max accumulator */
accumulator::arg_max<A> argmax(a);
p_array< mln_psite_(A) > obj_array; // Array of object components.
- mln_VAR(predicate, pw::value(a) > pw::cst(0.7));
- obj_array = morpho::tree::run_while(tree, a, argmax, predicate);
-
if (mydebug) {
- dsp("Run max accumulator, lk 4 5 objs"); display_tree_attributes(tree, a);
+ std::stringstream s("Run max accumulator, look for ");
+ if (nb_components)
+ s << nb_components << " components.";
+ else
+ s << "components whose treshold > " << sharpness;
+ dsp(s.str());
}
+ if (!nb_components) {
+ mln_VAR(predicate, pw::value(a) > pw::cst(sharpness));
+ obj_array = morpho::tree::run_while(tree, a, argmax, predicate);
+ } else {
+ obj_array = morpho::tree::run_ntimes(tree, a, argmax, nb_components);
+ }
+
+
/* Print them */
if (mydebug) {
dsp("Image Filtered Components");
@@ -139,6 +165,10 @@
}
/* Now Back Propagate to component */
+
+ if (mydebug) {
+ dsp("Create mask and propagate");
+ }
typedef mln_ch_value_(I, bool) M;
M mask;
initialize(mask, a);
@@ -151,28 +181,26 @@
propagate_node_to_descendants(c, tree, mask);
}
morpho::tree::propagate_representant(tree, mask);
+ io::pbm::save(mask, "binary.pbm");
// mask now contains all nodes related to objects
- if (mydebug) {
- dsp("Create mask and propagate"); display_tree_attributes(tree, mask);
- }
- /* Labeling */
- typedef mln_ch_value_(I, value::label<8>) L;
- value::label<8> nlabel;
- L label = labeling::blobs(mask, c4(), nlabel);
- io::ppm::save(debug::colorize(value::rgb8(), label, nlabel), "label.pgm");
-
- /* Now store output image image */
- I out;
- initialize(out, input);
- data::fill(out, 0);
- data::paste(input | pw::value(mask), out);
+ /* EXTRA */
+
+ // /* Labeling */
+// typedef mln_ch_value_(I, value::label<8>) L;
+// value::label<8> nlabel;
+// L label = labeling::blobs(mask, c4(), nlabel);
+// io::ppm::save(debug::colorize(value::rgb8(), label, nlabel), "label.pgm");
+
+
+// /* Now store output image */
+// I out;
+// initialize(out, input);
+// data::fill(out, 0);
+// data::paste(input | pw::value(mask), out);
+// io::pgm::save(out, "output.pgm");
- if (mydebug) {
- dsp("Mask input"); display_tree_attributes(tree, out);
- }
- io::pgm::save(out, "output.pgm");
}
Index: trunk/milena/sandbox/edwin/tree/run.hh
===================================================================
--- trunk/milena/sandbox/edwin/tree/run.hh (revision 3576)
+++ trunk/milena/sandbox/edwin/tree/run.hh (revision 3577)
@@ -36,6 +36,9 @@
# include <mln/core/site_set/p_array.hh>
# include <mln/util/pix.hh>
+# include <mln/trace/entering.hh>
+# include <mln/trace/exiting.hh>
+
# include "propagate_node.hh"
namespace mln {
@@ -167,12 +170,15 @@
Accumulator<ACC>& acc,
Function_p2b<P2B>& pred)
{
+ trace::entering("mln::morpho::tree::run_while");
A& a = exact(a_);
mln_precondition(tree.f().domain() == a.domain());
mln_precondition(a.is_valid());
- return internal::run_while(tree, a, exact(acc), exact(pred));
+ p_array< mln_psite(A) > arr = internal::run_while(tree, a, exact(acc), exact(pred));
+ trace::exiting("mln::morpho::tree::run_while");
+ return arr;
}
template <typename T, typename A, typename ACC>
@@ -183,8 +189,11 @@
Accumulator<ACC>& acc,
unsigned n)
{
+ trace::entering("mln::morpho::tree::run_ntimes");
internal::ncard predicate(n - 1);
- return run_while(tree, a, acc, predicate);
+ p_array< mln_psite(A) > arr = run_while(tree, a, acc, predicate);
+ trace::exiting("mln::morpho::tree::run_ntimes");
+ return arr;
}
template <typename T, typename A, typename I>
@@ -193,15 +202,18 @@
const Image<I>& a_,
Accumulator<A>& accu_)
{
+ trace::entering("mln::morpho::tree::run");
A& accu = exact(accu_);
const I& a = exact(a_);
+
mln_precondition(tree.f().domain() == a.domain());
mln_precondition(a.is_valid());
mln_up_node_piter(T) n(tree);
for_all(n)
accu.take(make::pix(a, n));
+ trace::exiting("mln::morpho::tree::run");
return (accu.to_result());
}
Index: trunk/milena/sandbox/edwin/tree/Makefile
===================================================================
--- trunk/milena/sandbox/edwin/tree/Makefile (revision 3576)
+++ trunk/milena/sandbox/edwin/tree/Makefile (revision 3577)
@@ -9,7 +9,8 @@
CXXFLAGS=-I$(MILENADIR) -I./ -W -Wall
-CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG -O1)
+CXXFLAGS += $(if $(DEBUG), -g -ggdb, -DNDEBUG\
+ $(if $(RELEASE), -O3, -O1))
CXX=g++
LD=g++
1
0
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-03-25 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update Fabien' sandbox.
* fabien/binarization/Makefile: Update.
* fabien/binarization/test.cc: Update.
* fabien/igr/matlab.cc: Update.
* fabien/magick/Makefile: Update.
* fabien/magick/save.cc: New test file for IM support.
---
binarization/Makefile | 13 +--
binarization/test.cc | 123 +++++++++++++++++++++-----------
igr/matlab.cc | 187 +++++++++++++++++++++++++++++++++++++++++++++-----
magick/Makefile | 14 +++
magick/save.cc | 23 ++++++
5 files changed, 292 insertions(+), 68 deletions(-)
Index: trunk/milena/sandbox/fabien/igr/matlab.cc
===================================================================
--- trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3575)
+++ trunk/milena/sandbox/fabien/igr/matlab.cc (revision 3576)
@@ -14,8 +14,7 @@
#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/arith/all.hh>
#include <mln/data/fill.hh>
#include <mln/data/paste.hh>
#include <mln/level/compute.hh>
@@ -95,10 +94,8 @@
int kk = 0;
mln_piter_(image2d<float>) p(datasli.domain());
for_all(p)
- {
if (roi_noise(p))
som1 += std::pow(math::abs(datasli(p) - moysignal1), 2);
- }
float ectys = std::sqrt(som1 / (nbrpix1 - 1));
float seuil = fseuil * ectys;
@@ -106,40 +103,43 @@
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
+ data::fill((masque | pw::value(datasli) > pw::cst(seuil)).rw(), true);
+ // si on a choisi une région avec roi
+ int nargin = 0;
+ image2d<bool> roi; // FIXME: init this ROI, should be a domain
if (nargin>2)
- data::fill(masque | pw::value(roi2) == false, false);
+ data::fill((masque | pw::value(roi) == false).rw(), false);
// 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).rw(), 0.0);
+ data::fill((arr_sous[k] | pw::value(masque) == false).rw(), 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 cherche les maxi (intensité ima_c et temps ima_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];
+ util::array<image2d<double> > arr_smooth;
+ arr_smooth.append(arr_ima[0] * 1.0);
+ for (int k = ini2 - 1; k < dim3 - 1; ++k)
+ arr_smooth.append(arr_ima[k] * 0.5 + arr_ima[k - 1] * 0.25 + arr_ima[k + 1] * 0.25);
+ arr_smooth.append(arr_ima[dim3 - 1] * 1.0);
for_all(p)
- {
if (masque(p) == false)
{
- for (int k = 0; k < arr_ima.nelements(); ++k)
- arr_ima[k](p) = 0.0;
+ for (int k = 0; k < arr_smooth.nelements(); ++k)
+ arr_smooth[k](p) = 0.0;
ima_c(p) = 0.0;
ima_t(p) = 0.0;
++kk;
}
- }
// FIXME: [c,T]=max(image,[ ],3);
@@ -157,5 +157,160 @@
// Conversion du temps du pic en secondes à partir fin période de base
tmax = acqui * (ima_t - ini);
+ // calcul des temps 10 et 90 et de la pente correspondante
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ {
+ [C10(i,j),idx_10(i,j)]=max(image(i,j,:)>=0.1*c(i,j));
+ [C90(i,j),idx_90(i,j)]=max(image(i,j,:)>=0.9*c(i,j));
+ [C50(i,j),idx_50(i,j)]=max(image(i,j,:)>=0.5*c(i,j));
+ if (idx_90(i,j)-idx_10(i,j)==0)
+ masque2(i,j)=0;
+ else
+ masque2(i,j)=1;
+ }
+
+ // calcul MTT
+
+ // QUAND le signal redescent significativement après le maximum
+ // elimination des voxels où le signal est encore 90// du maximum en fin
+ // d'acquisition
+ int kk2 = 0;
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ if (image(i,j,dim3)>=0.9*c(i,j))
+ {
+ masque3(i,j)=0;
+ kk2=kk2+1;
+ }
+ else
+ masque3(i,j)=1;
+
+ // pour les voxels non masqués on inverse t et on cherche le max 50// a partir de la fin
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ for (int k = 0; k < dim3; ++k)
+ imageinv(i,j,k)=masque3(i,j)*image(i,j,dim3+1-k);
+
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ if (masque3(i,j)==0)
+ {
+ idx_51(i,j)=0;
+ C51(i,j)=0;
+ }
+ else
+ [C51(i,j),idx_51(i,j)]=max(imageinv(i,j,:)>=0.8*c(i,j));
+
+ std::cout << "kk2 = " << kk2 << std::endl;
+
+ // Calcul MTT defini comme largeur a mi hauteur de la courbe signal(temps)
+ // soit t50 montant et t50 descendant
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ if (masque(i,j)*masque2(i,j)*masque3(i,j)==0)
+ MTT(i,j)=0;
+ else
+ MTT(i,j)=acqui*(dim3-idx_51(i,j)-idx_50(i,j));
+
+ // calcul de la pente 10/90 (avec delta signal=80// du maximum c(i,j) et
+ // delta temps =t90 -t10
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ if (masque(i,j)*masque2(i,j)==0)
+ pente(i,j)=0;
+ else
+ pente(i,j)=(0.8*c(i,j))/(acqui*(idx_90(i,j)-idx_10(i,j)));
+
+ // calcul pente normalisée rehaussement normalisé et AUC normalisée
+ for (int i = 0; i < dim1; ++i)
+ for (int j = 0; j < dim2; ++j)
+ if (masque(i,j)==0)
+ {
+ pentenorm(i,j)=0;
+ reh(i,j)=0;
+ AUCnorm(i,j)=0;
+ }
+ else
+ {
+ pentenorm(i,j)=pente(i,j)/imageini(i,j);
+ reh(i,j)=c(i,j)/imageini(i,j);
+ AUCnorm(i,j)=AUC(i,j)/imageini(i,j);
+ }
+
+ /*figure (3)
+ imagesc(AUCnorm);
+ title('image aire normalisée sous la courbe');
+ // l'aire sous la courbe est négative là où il y a eu du bougé (bord tube)
+
+
+ figure (4)
+ imagesc(pentenorm);
+ title('pente normalisée10-90');
+
+ figure(5)
+ imagesc(reh);
+ title('image rehaussement relatif');
+ caxis([0 5]);
+ // au dela de 5 il faut réviser la dose d'agent de contraste car surdosage
+
+ figure(6)
+ imagesc(MTT);
+ title('image MTT');
+
+ figure(9)
+ imagesc(idx_51);
+ title('idx_51');
+
+ figure(10)
+ imagesc(C51);
+
+ figure(7)
+ imagesc(tmax);
+ title('image Tmaximum');
+
+ figure(8)
+ subplot(2,2,1);
+ imagesc(pentenorm);
+ title('pente normalisée10-90');
+ subplot(2,2,2)
+ imagesc(reh);
+ title('image rehaussement relatif');
+ caxis([0 3]);
+ subplot(2,2,3)
+ imagesc(tmax);
+ title('image Tmaximum');*/
+
+ // COURBE S(t)sur pixel choisi graphiquement
+ // Permet de voir la courbe de rehaussement d'un voxel pointé
+ // SI LE VOXEL EST AU BORD DU TUBE TEMOIN: UN DETECTEUR DE MOUVEMENTS
+ // coordonx=1:size(image,3);
+ x = size(image, 1) / 2;
+ y = size(image, 2) / 2;
+ while (x < size(image, 1) && y < size(image, 2))
+ {
+ // la saisie du point de coordonnées x,y se fait sur la figure ouverte en
+ // dernier
+ // pour sortir: cliquer dans le gris...
+ // pour affichage interactif coordonnées pixel, mais en fait pas utile
+ h=figure(8)
+ pixval;
+ // saisie coordonnées du pixel pour lequel on veut afficher la courbe de
+ // décroissance et le fit
+ [x,y]=ginput(1);
+ // on ajuste a l'entier supérieur pour trouver les "vraies" coordonnées
+ // en plus il faut inverser entre xy et ij...
+ coordx=ceil(y);
+ coordy=ceil(x);
+ // test sortie du programme
+ if ((coordx > size(image, 1)) | (coordy > size(image, 2)))
+ break;
+ fprintf(1,'\n// d\t// d\t// f\t// f\n',coordx,coordy,reh(coordx,coordy),image(coordx,coordy,1));
+ titi = (abs(image(coordx, coordy, :)));
+ tata = squeeze(titi);
+ subplot(2,2,4)
+ plot(tata);
+ }
+
return 0;
}
Index: trunk/milena/sandbox/fabien/binarization/test.cc
===================================================================
--- trunk/milena/sandbox/fabien/binarization/test.cc (revision 3575)
+++ trunk/milena/sandbox/fabien/binarization/test.cc (revision 3576)
@@ -1,30 +1,37 @@
#include <iostream>
#include <fstream>
+#include <mln/accu/median_h.hh>
+
#include <mln/algebra/vec.hh>
+#include <mln/convert/from_to.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/io/magick/all.hh>
+#include <mln/level/convert.hh>
#include <mln/level/stretch.hh>
+#include <mln/literal/colors.hh>
+
#include <mln/make/box2d.hh>
#include <mln/morpho/closing/volume.hh>
#include <mln/morpho/watershed/flooding.hh>
+#include <mln/util/array.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/value/rgb8.hh>
#include <mln/world/binary_2d/projected_histo.hh>
#include <mln/world/binary_2d/subsample.hh>
@@ -34,75 +41,109 @@
using value::int_u8;
using value::int_u12;
using value::label_16;
+using value::rgb8;
+
+
+int draw_lines(image2d<bool>& ima, int col_min, int col_max)
+{
+ box2d box = make::box2d(0, col_min, ima.nrows() - 1, col_max);
+ util::couple<image1d<float>, image1d<float> > histos = world::binary_2d::projected_histo(ima | box);
+ image1d<float> row_histo = histos.first();
+
+ /*int i = col_histo.ninds();
+ while (i > 0 && col_histo.at_(i) < 60.0)
+ {
+ col_histo.at_(i) = 100.0;
+ --i;
+ }*/
+
+ row_histo = morpho::closing::volume(row_histo, c2(), 41);
+
+ // Watershed
+ label_16 nbasins;
+ image1d<label_16> row_labels = morpho::watershed::flooding(row_histo, c2(), nbasins);
+
+ int median = 0;
+ util::array<int> inter_lines;
+ int begin = 0;
+ int end = 0;
+
+ // Draw lines
+ for (unsigned int i = 0; i < row_labels.ninds(); ++i)
+ if (row_labels.at_(i) == 0u)
+ {
+ if (end == 0)
+ {
+ begin = i;
+ end = i;
+ }
+ else if (end == begin)
+ {
+ end = i;
+ inter_lines.append(end - begin);
+ begin = end;
+ }
+ }
+
+ image1d<int> ima_lines;
+ convert::from_to(inter_lines, ima_lines);
+ accu::median_h<int_u12> accu_med;
+ median = level::compute(accu_med, ima_lines);
+
+ // 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 median;
+}
int main(int argc, char* argv[])
{
if (argc != 3)
{
- std::cout << "Usage: " << argv[0] << "input.ext output.pgm" << std::endl;
+ std::cout << "Usage: " << argv[0] << "input output" << std::endl;
return 1;
}
image2d<bool> ima;
io::magick::load(ima, argv[1]);
+ image2d<rgb8> ima_color = level::convert(rgb8(), ima);
//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;
- }
+ int median_left = draw_lines(ima, 0, (ima.ncols() / 3));
+ int median_middle = draw_lines(ima, (ima.ncols() / 3), (2 * ima.ncols() / 3));
+ int median_right = draw_lines(ima, (2 * ima.ncols() / 3), ima.ncols() - 1);
- // Closing
- row_histo = morpho::closing::volume(row_histo, c2(), 31);
+ int median = (median_left + median_middle + median_right) / 3;
- // Watershed
- label_16 nbasins;
- image1d<label_16> row_labels = morpho::watershed::flooding(row_histo, c2(), nbasins);
+ std::cout << "median = " << median << std::endl;
// 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;
+ for (unsigned int i = 0; i < ima.nrows(); ++i)
+ {
+ if (i % median == 0)
+ {
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);
+ draw::line(ima_color, pbeg, pend, literal::red);
}
}
- 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;
+ io::magick::save(ima_color, argv[2]);
return 0;
}
Index: trunk/milena/sandbox/fabien/binarization/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/binarization/Makefile (revision 3575)
+++ trunk/milena/sandbox/fabien/binarization/Makefile (revision 3576)
@@ -1,10 +1,5 @@
-GCCFLAGS = -DNDEBUG -O1
-LLVMFLAGS = -DNDEBUG -O4
+CXX = llvm-g++
+CXXFLAGS = -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
+all: test.cc
+ ${CXX} -I../../../ `Magick++-config --cppflags --cxxflags --ldflags --libs` ${CXXFLAGS} test.cc -o test
Index: trunk/milena/sandbox/fabien/magick/save.cc
===================================================================
--- trunk/milena/sandbox/fabien/magick/save.cc (revision 0)
+++ trunk/milena/sandbox/fabien/magick/save.cc (revision 3576)
@@ -0,0 +1,23 @@
+#include <mln/core/image/image2d.hh>
+
+#include <mln/io/magick/all.hh>
+#include <mln/io/pbm/all.hh>
+#include <mln/io/pgm/all.hh>
+#include <mln/io/ppm/all.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+using namespace mln;
+
+int main(int argc, char* argv[])
+{
+ if (argc != 2)
+ return 1;
+
+ image2d<value::rgb8> ima;
+ io::magick::load(ima, argv[1]);
+ io::magick::save(ima, "out_magick.png");
+ io::ppm::save(ima, "out_pnm.ppm");
+ return 0;
+}
Index: trunk/milena/sandbox/fabien/magick/Makefile
===================================================================
--- trunk/milena/sandbox/fabien/magick/Makefile (revision 3575)
+++ trunk/milena/sandbox/fabien/magick/Makefile (revision 3576)
@@ -1,2 +1,12 @@
-all: magick.cc
- g++ -I../../../ `Magick++-config --cppflags --cxxflags --ldflags --libs` magick.cc -o mln_magick
+CXX = llvm-g++
+CXXFLAGS = -DNDEBUG -O4
+LIBS = `Magick++-config --cppflags --cxxflags --ldflags --libs`
+INC = -I../../../
+
+all: magick
+
+magick: magick.cc
+ ${CXX} ${INC} ${LIBS} $^ -o mln_magick
+
+save: save.cc
+ ${CXX} ${INC} ${LIBS} $^ -o magick_save
1
0