---
milena/ChangeLog | 20 +++
.../tutorial/samples/accu-right-instanciation.tex | 1 +
.../tutorial/samples/accu-wrong-instanciation.tex | 1 +
milena/doc/tutorial/samples/estim-sites.tex | 1 +
.../tutorial/samples/ima2d-decl-2-blobs-output.tex | 7 +
milena/doc/tutorial/samples/ima2d-decl-2-blobs.tex | 2 +
milena/doc/tutorial/samples/ima2d-decl-2.tex | 12 +-
.../doc/tutorial/samples/labeling-compute-call.tex | 3 +
.../samples/labeling-compute-result-output.tex | 3 +
.../tutorial/samples/labeling-compute-result.tex | 2 +
milena/doc/tutorial/tutorial.tex | 148 ++++++++++++++++----
11 files changed, 166 insertions(+), 34 deletions(-)
create mode 100644 milena/doc/tutorial/samples/accu-right-instanciation.tex
create mode 100644 milena/doc/tutorial/samples/accu-wrong-instanciation.tex
create mode 100644 milena/doc/tutorial/samples/estim-sites.tex
create mode 100644 milena/doc/tutorial/samples/ima2d-decl-2-blobs-output.tex
create mode 100644 milena/doc/tutorial/samples/ima2d-decl-2-blobs.tex
create mode 100644 milena/doc/tutorial/samples/labeling-compute-call.tex
create mode 100644 milena/doc/tutorial/samples/labeling-compute-result-output.tex
create mode 100644 milena/doc/tutorial/samples/labeling-compute-result.tex
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a4dd0ec..aad3140 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,23 @@
+2008-10-20 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Update tutorial.
+
+ * doc/samples/accu-right-instanciation.tex,
+ * doc/samples/accu-wrong-instanciation.tex,
+ * doc/samples/estim-sites.tex,
+ * doc/samples/ima2d-decl-2-blobs-output.tex,
+ * doc/samples/ima2d-decl-2-blobs.tex,
+ * doc/samples/ima2d-decl-2.tex,
+ * doc/samples/labeling-compute-call.tex,
+ * doc/samples/labeling-compute-result-output.tex,
+ * doc/samples/labeling-compute-result.tex:
+ New sample code included in the doc.
+
+ * doc/tutorial.tex:
+ Write section about:
+ - accumulators and *::compute.
+ - blobs
+
2008-10-20 Nicolas Ballas <ballas(a)lrde.epita.fr>
Update dispatch of the fill_with image and paste routines.
diff --git a/milena/doc/tutorial/samples/accu-right-instanciation.tex b/milena/doc/tutorial/samples/accu-right-instanciation.tex
new file mode 100644
index 0000000..446893a
--- /dev/null
+++ b/milena/doc/tutorial/samples/accu-right-instanciation.tex
@@ -0,0 +1 @@
+level::compute(accu::meta::bbox(), ima);
diff --git a/milena/doc/tutorial/samples/accu-wrong-instanciation.tex b/milena/doc/tutorial/samples/accu-wrong-instanciation.tex
new file mode 100644
index 0000000..25e943d
--- /dev/null
+++ b/milena/doc/tutorial/samples/accu-wrong-instanciation.tex
@@ -0,0 +1 @@
+level::compute(accu::meta::bbox, ima);
diff --git a/milena/doc/tutorial/samples/estim-sites.tex b/milena/doc/tutorial/samples/estim-sites.tex
new file mode 100644
index 0000000..b6d7914
--- /dev/null
+++ b/milena/doc/tutorial/samples/estim-sites.tex
@@ -0,0 +1 @@
+unsigned nsites = estim::nsites(ima);
diff --git a/milena/doc/tutorial/samples/ima2d-decl-2-blobs-output.tex b/milena/doc/tutorial/samples/ima2d-decl-2-blobs-output.tex
new file mode 100644
index 0000000..0e08731
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima2d-decl-2-blobs-output.tex
@@ -0,0 +1,7 @@
+0 1 1 0 0
+0 1 1 0 0
+0 0 0 0 0
+2 2 0 3 0
+2 0 3 3 3
+2 0 0 0 0
+
diff --git a/milena/doc/tutorial/samples/ima2d-decl-2-blobs.tex b/milena/doc/tutorial/samples/ima2d-decl-2-blobs.tex
new file mode 100644
index 0000000..6699982
--- /dev/null
+++ b/milena/doc/tutorial/samples/ima2d-decl-2-blobs.tex
@@ -0,0 +1,2 @@
+int_u8 nlabels;
+image2d<int_u8> lbl = labeling::blobs(ima, c4(), nlabels);
diff --git a/milena/doc/tutorial/samples/ima2d-decl-2.tex b/milena/doc/tutorial/samples/ima2d-decl-2.tex
index e7a0953..478a627 100644
--- a/milena/doc/tutorial/samples/ima2d-decl-2.tex
+++ b/milena/doc/tutorial/samples/ima2d-decl-2.tex
@@ -1,9 +1,9 @@
bool vals[6][5] = {
-{0, 1, 1, 0, 0},
-{0, 1, 1, 0, 0},
-{0, 0, 0, 0, 0},
-{1, 1, 0, 1, 0},
-{1, 0, 1, 1, 1},
-{1, 0, 0, 0, 0}
+ {0, 1, 1, 0, 0},
+ {0, 1, 1, 0, 0},
+ {0, 0, 0, 0, 0},
+ {1, 1, 0, 1, 0},
+ {1, 0, 1, 1, 1},
+ {1, 0, 0, 0, 0}
};
image2d<bool> ima = make::image2d(vals);
diff --git a/milena/doc/tutorial/samples/labeling-compute-call.tex b/milena/doc/tutorial/samples/labeling-compute-call.tex
new file mode 100644
index 0000000..bbe6eff
--- /dev/null
+++ b/milena/doc/tutorial/samples/labeling-compute-call.tex
@@ -0,0 +1,3 @@
+util::array<box2d> boxes = labeling::compute(accu::meta::bbox(),
+ lbl,
+ nlabels);
diff --git a/milena/doc/tutorial/samples/labeling-compute-result-output.tex b/milena/doc/tutorial/samples/labeling-compute-result-output.tex
new file mode 100644
index 0000000..d7fbc06
--- /dev/null
+++ b/milena/doc/tutorial/samples/labeling-compute-result-output.tex
@@ -0,0 +1,3 @@
+[(1,2)...(2,3)]
+[(4,1)...(6,2)]
+[(4,3)...(5,5)]
diff --git a/milena/doc/tutorial/samples/labeling-compute-result.tex b/milena/doc/tutorial/samples/labeling-compute-result.tex
new file mode 100644
index 0000000..5f92904
--- /dev/null
+++ b/milena/doc/tutorial/samples/labeling-compute-result.tex
@@ -0,0 +1,2 @@
+for (unsigned i = 1; i <= nlabels; ++i)
+ std::cout << boxes[i] << std::endl;
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index 2e7ddfe..d91f56f 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -82,7 +82,9 @@ showstringspaces=false,linewidth=14cm}
- \backslash subpage iterators
- \backslash subpage imamemmgmt
- \backslash subpage basicops
-- \backslash subpage graphes
+- \backslash subpage graphandima
+- \backslash subpage arithmops
+- \backslash subpage mathtools
\backslash htmlonly
\end{htmlonly}
@@ -976,7 +978,22 @@ For instance, the algorithm level::paste tests that the set of sites of imgb
%====================================
\doxysection{blobs}{Blobs}
-//FIXME: write it!
+
+Labeling::blobs() is used to label an image. It returns a new image with the
+component id as value for each site. The background has 0 as id therefore the
+component ids start from 1.
+
+Consider the following image:
+\doxycode{ima2d-decl-2}
+
+Then label this image thanks to labeling::blobs:
+\doxycode{ima2d-decl-2-blobs}
+Output:
+\doxycode{ima2d-decl-2-blobs-output}
+
+Note that this routine returns the number of components in its third parameter.
+This parameter \textbf{must} be of the same type as the returned image value.
+
%**************************
\doxysection{compute}{Compute}
@@ -992,55 +1009,116 @@ image. \\
level::compute() & compute an accumulator on the values of an image. \\
\end{tabular}
+\subsection{Accumulators}
An accumulator is a special object accumulating data while iterating all over
the image values or sites. Hereby follows a list of accumulators available in
Olena.
%----------------
-\subsection*{Accumulators on sites}
+\subsubsection*{Accumulators on sites}
\begin{tabular}{l|p{8cm}}
-Name | Description \\
+Name & Description \\
\hline
-bbox & \\
-count\_adjacent\_vertices & \\
-count & \\
+bbox & Bounding boxes\\
+count\_adjacent\_vertices & Count adjacent vertices\\
+count & Count the number of sites\\
height & \\
volume & \\
\end{tabular}
%----------------
-\subsection*{Accumulators on values}
+\subsubsection*{Accumulators on values}
\begin{tabular}{l|p{8cm}}
-Name | Description \\
+Name & Description \\
\hline
-histo & \\
-max & \\
-max\_h & \\
-mean & \\
-median\_alt & \\
-median\_h & \\
-min & \\
-min\_h & \\
-min\_max & \\
+histo & Histogram \\
+max & Max value \\
+max\_h & Max value (Hexa)\\
+mean & Mean value\\
+median\_alt & Median\\
+median\_h & Median (Hexa)\\
+min & Min value\\
+min\_h & Min value (Hexa)\\
+min\_max & Min and Max value\\
rank\_bool & \\
rank & \\
rank\_high\_quant & \\
-sum & \\
+sum & Sum the values\\
\end{tabular}
%----------------
-\subsection*{Accumulators on values}
+\subsubsection*{Special accumulators}
\begin{tabular}{l|p{8cm}}
-Name | Description \\
+Name & Description \\
\hline
-pair & \\
-p & \\
-tuple & \\
-v & \\
+pair & Pair of accumulators\\
+tuple & $n$-uplets of accumulators\\
\end{tabular}
-//FIXME: write it!
+Each accumulator can be used in *::compute().
+It exists two versions of each accumulator.
+\begin{itemize}
+ \item mln::accu::*, this version require the site or value type as parameter.
+ For instance, for the bbox accumulator, the type would be
+ accu::bbox<mln\_psite(I)>, where I is the type of the image on which it will be
+ computed.
+ \item mln::accu::meta::*, this is usually the easiest version to use. The type
+ of site or value do not need to be specified and will be deduced at compile
+ time. For the bbox accumulator, the accumulator type would be
+ accu::meta::bbox.
+\end{itemize}
+
+Note that when an accumulator is passed to *::compute, it must be instanciated.
+You cannot write:
+\doxycode{accu-wrong-instanciation}
+Instead, you must write:
+\doxycode{accu-right-instanciation}
+\subsection{Example with labeling::compute()}
+
+In this example we will try to retrieve the bounding box of each component in an
+image.
+
+Consider the following image:
+\doxycode{ima2d-decl-2}
+
+Then label this image thanks to labeling::blobs:
+\doxycode{ima2d-decl-2-blobs}
+Output:
+\doxycode{ima2d-decl-2-blobs-output}
+
+Then, use labeling::compute() with the bbox accumulator:
+\doxycode{labeling-compute-call}
+
+Labeling::compute() hold an accumulator for each component, which means it
+returns an array of accumulator results.
+In this case, it returns an array of box2d.
+
+\textbf{Important note:} since labeling::blobs() labels the component from 1 and
+set the background to 0, we will want to iterate from 1 to nlabels included.
+\doxycode{labeling-compute-result}
+Output:
+\doxycode{labeling-compute-result-output}
+
+\subsection{Routines based on accumulators and *::compute()}
+
+In order to make the code cleaner, small routines are available for the
+most used accumulators.
+
+Currently there are the following routines:\\
+
+\begin{tabular}{l|p{8cm}}
+Name & Description \\
+\hline
+nsites & Return the number of sites of an image or a site set.\\
+mean & Return the mean of the values of an image.\\
+min\_max & Return the min and max values of the values of an image.\\
+sum & Return the sum of the values of an image.
+\end{tabular}
+
+These routines can be found in mln/estim.
+For example, with estim::nsites() simply write:
+\doxycode{estim-sites}
%====================================
\doxysection{partima}{Working with parts of an image}
@@ -1140,9 +1218,9 @@ site set.
%====================================
\newpage
\clearpage
-\doxychapter{graphes}{Graphes and images}
+\doxychapter{graphandima}{Graphes and images}
-//FIXME: REWRITE
+FIXME: REWRITE
%**************************
\doxysection{graphdesc}{Description}
@@ -1301,4 +1379,18 @@ for_all(E)
//FIXME talk about p\_vertices and p\_edges.
+%====================================
+\newpage
+\clearpage
+\doxychapter{arithmops}{Arithmetical operators}
+
+FIXME write it
+
+%====================================
+\newpage
+\clearpage
+\doxychapter{mathtools}{Mathematical tools}
+
+FIXME write it
+
\end{document}
--
1.5.6.5
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-18 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Improve OCR preprocessing.
* garrigues/ocr/ocr.cc: Add resize + gaussian blur.
* garrigues/ocr/resize.hh: New. Enlarge an image.
---
ocr.cc | 34 ++++++++++++++++-----
resize.hh | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 121 insertions(+), 9 deletions(-)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/resize.hh
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/resize.hh (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/resize.hh (revision 2610)
@@ -0,0 +1,96 @@
+// Copyright (C) 2008 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.
+
+#ifndef MLN_GEOM_RESIZE_HH
+# define MLN_GEOM_RESIZE_HH
+
+# include <mln/win/rectangle2d.hh>
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+
+ /*!
+ * \brief Resize an image \p input_ with \p ratio.
+ *
+ * \param[in] input_ The image to resize.
+ * \param[in] ratio The ratio of the resize image.
+ *
+ * \pre \p input_ has to be initialized.
+ * \pre \p ratio >= 1.
+ *
+ * \return The resized image.
+ */
+ template <typename I>
+ mln_concrete(I)
+ resize(const Image<I>& input_, const unsigned ratio);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename I>
+ mln_concrete(I)
+ resize(const Image<I>& input_, const unsigned ratio)
+ {
+ trace::entering("mln::geom::resize");
+
+ typedef mln_concrete(I) O;
+
+ const I input = exact (input_);
+
+ std::size_t rows = input.domain().len(0);
+ std::size_t cols = input.domain().len(1);
+ std::size_t new_rows = ratio * rows;
+ std::size_t new_cols = ratio * cols;
+
+ O output(new_rows, new_cols);
+
+ mln_piter(O) p(output.domain());
+
+ for_all(p)
+ {
+ output(p) = input(point2d(p[0] / ratio, p[1] / ratio)) ? 255 : 0;
+ }
+
+ trace::exiting("mln::geom::resize");
+ return output;
+
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+
+#endif // ! MLN_GEOM_RESIZE_HH
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 2609)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 2610)
@@ -31,29 +31,45 @@
#include <mln/core/alias/window2d.hh>
#include <mln/core/alias/neighb2d.hh>
+#include <mln/core/image/cast_image.hh>
+
#include <mln/value/int_u8.hh>
-#include <mln/morpho/meyer_wst.hh>
+#include "resize.hh"
+#include <mln/linear/convolve.hh>
+#include <mln/linear/gaussian.hh>
-#include <mln/io/pgm/load.hh>
+#include <mln/trace/all.hh>
+#include <mln/io/pbm/load.hh>
#include <mln/io/pgm/save.hh>
+#include <mln/core/alias/w_window2d_float.hh>
int main(int argc, char** argv)
{
+ mln::trace::quiet = false;
+
using namespace mln;
using value::int_u8;
- image2d<int_u8> input;
+ image2d<bool> input;
+ image2d<int_u8> output;
+ image2d<int_u8> output2;
if (argc != 3)
return 1;
- io::pgm::load(input, argv[1]);
- typedef int_u8 wst_val;
- wst_val nbasins;
- image2d<int_u8> output = morpho::meyer_wst(input, c4(), nbasins);
- std::cout << "nbasins = " << nbasins << std::endl;
- io::pgm::save(output, argv[2]);
+
+ io::pbm::load(input, argv[1]);
+
+
+ // Step 1: Enlarge input.
+ output = geom::resize(cast_image<int_u8>(input), 4);
+
+ // Step 2: Blur.
+ initialize(output2, output);
+ linear::gaussian(output, 15, output2);
+
+ io::pgm::save(output2, argv[2]);
}
From: Jimmy Ma <jimmy.ma(a)lrde.epita.fr>
To: olena-patches(a)lrde.epita.fr
Subject: r2609: Create a ocr directory
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
ChangeLog:
2008-10-18 Jimmy Ma <jimmy.ma(a)lrde.epita.fr>
Create a ocr directory.
* garrigues/ocr/ocr.cc: New.
* garrigues/ocr: New.
---
ocr.cc | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
Index: branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc
===================================================================
--- branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 0)
+++ branches/cleanup-2008/milena/sandbox/garrigues/ocr/ocr.cc (revision 2609)
@@ -0,0 +1,59 @@
+// 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
+// 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/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/morpho/meyer_wst.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+
+int main(int argc, char** argv)
+{
+ using namespace mln;
+ using value::int_u8;
+
+ image2d<int_u8> input;
+
+ if (argc != 3)
+ return 1;
+
+ io::pgm::load(input, argv[1]);
+
+ typedef int_u8 wst_val;
+ wst_val nbasins;
+ image2d<int_u8> output = morpho::meyer_wst(input, c4(), nbasins);
+ std::cout << "nbasins = " << nbasins << std::endl;
+ io::pgm::save(output, argv[2]);
+}