URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-27 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Fix a bug in p(g|p)m load.
* mln/io/pnm/load.hh: (load(image&, filename)) now work on rgb images.
* mln/io/pnm/max_component.hh: Define a function which give the max of
the component of a value type.
* tests/io/pgm/pgm16.cc: Now test the other way to load an image
(load(image&, filename)).
* tests/io/ppm/ppm16.cc: likewise.
* img/lena_16.ppm: New, lena, ppm 16 bits.
---
mln/io/pnm/load.hh | 12 ++++--
mln/io/pnm/max_component.hh | 77 ++++++++++++++++++++++++++++++++++++++++++++
tests/io/pgm/pgm16.cc | 12 ++++++
tests/io/ppm/ppm16.cc | 12 ++++++
4 files changed, 107 insertions(+), 6 deletions(-)
Index: trunk/milena/tests/io/pgm/pgm16.cc
===================================================================
--- trunk/milena/tests/io/pgm/pgm16.cc (revision 1547)
+++ trunk/milena/tests/io/pgm/pgm16.cc (revision 1548)
@@ -72,6 +72,7 @@
using value::int_u8;
using value::int_u16;
+ {
win::rectangle2d rect(51, 51);
border::thickness = 52;
@@ -90,6 +91,17 @@
level::transform(lena2, to8bits(), out2);
io::pgm::save(out2, "out8.pgm");
+ }
+ {
+ // Abort
+// image2d< value::int_u<8> > a;
+// io::pgm::load(a, "out16.pgm");
+
+ image2d< value::int_u<16> > b;
+ io::pgm::load(b, "out16.pgm");
+
+ }
+
}
Index: trunk/milena/tests/io/ppm/ppm16.cc
===================================================================
--- trunk/milena/tests/io/ppm/ppm16.cc (revision 1547)
+++ trunk/milena/tests/io/ppm/ppm16.cc (revision 1548)
@@ -78,7 +78,7 @@
typedef image2d<rgb8> I;
-
+ {
// load a 8bits image A
image2d<rgb8>
a = io::ppm::load<rgb8>("../../../img/lena.ppm");
@@ -106,5 +106,15 @@
// D should equals A
mln_assertion(d == a);
+ }
+
+ {
+ // Abort
+// image2d<rgb8> a;
+// io::ppm::load(a, "../../../img/lena_16.ppm");
+ image2d< value::rgb<16> > b;
+ io::ppm::load(b, "../../../img/lena_16.ppm");
+
+ }
}
Index: trunk/milena/mln/io/pnm/max_component.hh
===================================================================
--- trunk/milena/mln/io/pnm/max_component.hh (revision 0)
+++ trunk/milena/mln/io/pnm/max_component.hh (revision 1548)
@@ -0,0 +1,77 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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_IO_PNM_MAX_COMPONENT_HH
+# define MLN_IO_PNM_MAX_COMPONENT_HH
+
+/*!
+ * \file mln/io/pnm/max_component.hh
+ *
+ * \brief Define a function which give the max of the component of a
+ * value type.
+ */
+
+namespace mln
+{
+
+ namespace io
+ {
+
+ namespace pnm
+ {
+ template <typename V>
+ unsigned int max_component();
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ unsigned int max_component(const V&)
+ {
+ return mln_max(V);
+ }
+
+# ifdef MLN_VALUE_RGB_HH
+
+ template <unsigned n>
+ unsigned int max_component(const mln::value::rgb<n>&)
+ {
+ return mln_max( mln::value::int_u<n> );
+ }
+
+# endif
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::io::pnm
+
+ } // end of namespace mln::io
+
+} // end of namespace mln
+
+
+#endif // ! MLN_IO_PNM_LOAD_HH
Index: trunk/milena/mln/io/pnm/load.hh
===================================================================
--- trunk/milena/mln/io/pnm/load.hh (revision 1547)
+++ trunk/milena/mln/io/pnm/load.hh (revision 1548)
@@ -46,6 +46,7 @@
# include <mln/value/rgb.hh>
# include <mln/io/pnm/load_header.hh>
+# include <mln/io/pnm/max_component.hh>
# include <mln/io/pnm/macros.hh>
namespace mln
@@ -189,15 +190,16 @@
read_header(type_ - 3, type_, file, type,
nrows, ncols, maxval);
- if (mln_max(mln_value(I)) != maxval)
+ if (max_component(mln_value(I)()) != maxval)
{
- std::cerr << "max ref : " << mln_max(mln_value(I))
- << "max image : " << maxval
- << std::endl;
-
std::cerr << "error: file '" << filename
<< "' cannot be loaded into this type of image"
<< std::endl;
+
+ std::cerr << "input image have " << maxval
+ << " as maximum value while the destination's one is "
+ << max_component(mln_value(I)()) << "."
+ << std::endl;
abort();
}
Index: trunk/milena/img/lena_16.ppm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: trunk/milena/img/lena_16.ppm
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
URL: https://svn.lrde.epita.fr/svn/oln/trunk
OK to apply?
(Use Reply-All, I'm not subscribed to this ML, thanks)
ChangeLog:
2007-11-27 Benoit Sigoure <tsuna(a)lrde.epita.fr>
Fix typos in the tutorial.
* milena/doc/tutorial/slides.tex: Various typos everywhere.
---
slides.tex | 47 ++++++++++++++++++++++++-----------------------
1 files changed, 24 insertions(+), 23 deletions(-)
Index: milena/doc/tutorial/slides.tex
===================================================================
--- milena/doc/tutorial/slides.tex (revision 1543)
+++ milena/doc/tutorial/slides.tex (working copy)
@@ -243,7 +243,7 @@
\item Many libraries exist that can fulfill one's needs.
\item If you're happy with your favorite tool, we cannot force you
to change for \mln...
- \item Though, you might have a look at \mln and being seduced!
+ \item Though, you might have a look at \mln and be seduced!
\end{itemize}
\end{block}
@@ -253,7 +253,7 @@
\begin{block}{No!}
\begin{itemize}
\item \mln is rather different than available libraries.
- \item A lot of convenient data structures that \emph{really} helps
+ \item A lot of convenient data structures that \emph{really} help
you in developing IP solutions.
\end{itemize}
\end{block}
@@ -310,7 +310,8 @@
\smallskip
\begin{lstlisting}[basicstyle={\tiny\sffamily}]
template <typename I, typename H>
-void transform_inplace(Image<I>& f_, const Function_v2v<H>& h_)
+void transform_inplace(Image<I>& f_,
+ const Function_v2v<H>& h_)
{
I& f = exact(f);
const H& h = exact(h_);
@@ -361,7 +362,7 @@
%........................................................................
\begin{frame}%[<+->]
- \frametitle{What's In a Library}
+ \frametitle{What's In The Library}
\begin{itemize}
\item algorithms:\\
@@ -389,7 +390,7 @@
\begin{itemize}
\item Generic...
\item Efficient so that one can process large images.
- \item Quite as easy to use as a C or Java library.
+ \item Almost as easy to use as a C or Java library.
\item Many tools to help writing readable algorithms in a concise way.
\end{itemize}
@@ -552,7 +553,7 @@
\texttt{arith} & arithmetical operators \\
\texttt{border} & routines about virtual border &
\texttt{canvas} & canvases \\
-\texttt{convert} & conversions routines &
+\texttt{convert} & conversion routines &
\texttt{core} & the library core \\
\texttt{debug} & debugging tools &
\texttt{display} & display tools \\
@@ -605,7 +606,7 @@
not on implementation details about how to do it
\smallskip
%
- \item you do not have found yet a library to easily process your
+ \item you have not yet found a library to easily process your
particular types of data
\end{itemize}
@@ -824,9 +825,9 @@
\begin{frame}[fragile]
\frametitle{Modifying the State of an Object (2/2)}
- accessing and modifying through method calls allow some control:
+ accessing and modifying through method calls allows for some control:
\begin{itemize}
- \item one cannot do everything with an object
+ \item one cannot do anything with an object
\item especially putting it in an invalid state
\end{itemize}
@@ -888,7 +889,7 @@
\begin{itemize}
\item no need to take the address (with \&) of an object
\item no pointer arithmetics
- \item no $->$ in use
+ \item no $->$ to access members
\end{itemize}
\item it \emph{always} designates the same object
\begin{itemize}
@@ -995,7 +996,7 @@
accessible from the user
\begin{itemize}
\item thanks to the keyword \kw{private}
- \item writing \code{p.row\_} outside this class is not allowed (do
+ \item writing \code{p.row\_} outside this class is not allowed (does
not compile)
\end{itemize}
\smallskip
@@ -1003,7 +1004,7 @@
\item the method \code{row()} is accessible (keyword \kw{public})
\begin{itemize}
\item in the method body we have some room to add code
- \item a simple access to data can performs some clever stuff that
+ \item a simple access to data can perform some clever stuff that
you do not really have to know (neither want to)!
\end{itemize}
\end{itemize}
@@ -1121,7 +1122,7 @@
\end{lstlisting}
\begin{itemize}
-\item the variable \code{r} represents an object which type is
+\item the variable \code{r} represents an object the type of which is
precisely \code{rabbit}
\begin{center}
we say that it is the \emph{exact} type behind this variable
@@ -1165,7 +1166,7 @@
\item In that case
\begin{itemize}
\item at compile-time: there are many possible types of objects represented
- \item at run-time: there is one object represented so just type.
+ \item at run-time: there is one object represented so just one type.
\end{itemize}
\end{itemize}
@@ -1184,7 +1185,7 @@
About ``classical'' object-orientation:
\begin{itemize}
- \item abstractions (like \code{animal}) leads to poor
+ \item abstractions (like \code{animal}) lead to poor
performance at run-time when involved in intensive scientific code.
%
\item it is due to the fact that the exact type is lost\\
@@ -1340,7 +1341,7 @@
\begin{frame}[fragile]
\frametitle{A rationale for Genericity}
-Suppose that you want a routine that computes twice the input:
+Suppose that you want a routine that computes twice its input:
\begin{lstlisting}
int twice(int i) { return 2 * i; }
\end{lstlisting}
@@ -1434,7 +1435,7 @@
one of the procedure argument ``\code{(T t)}''
%
\item the nature of \code{t} is \code{T}, the nature of \code{T} is
- \code{typename} (so designates a type)
+ \code{typename} (so it designates a type)
%
\item the \cpp keyword introducing a generic piece of code is
\kw{template}
@@ -1476,7 +1477,7 @@
\item \code{int twice(int t) { return 2 * t; }} and
\item \code{float twice(float t) { return 2 * t; }}
\end{itemize}
-\item so it is not so different than with overloading
+\item so it is not so different than overloading
\end{itemize}
except that:
@@ -1762,7 +1763,7 @@
}
\end{lstlisting}
-How can we ensure that the delta-point type \code{D} really correspond
+How can we ensure that the delta-point type \code{D} really corresponds
to \code{P}? {\scriptsize (we really do not want \code{P} and
\code{D} resp. being \code{point3d} and \code{dpoint2d}!)}
@@ -1803,7 +1804,7 @@
}
\end{lstlisting}
-What is the problem? (Hint: read both signatures in natural language)
+What is the problem? (Hint: read both signatures out loud)
\end{frame}
@@ -1829,7 +1830,7 @@
\end{lstlisting}
which is clearly not ambiguous (but slow at run-time...)
-where \code{Dpoint} and \code{Image} are abstract class.
+where \code{Dpoint} and \code{Image} are abstract classes.
\end{frame}
@@ -2140,11 +2141,11 @@
\scriptsize{it works for any delta-point type}
\smallskip
%
-\item is fast
+\item is fast,
\scriptsize{you cannot get more efficient code}
\smallskip
%
-\item is user-friendly
+\item is user-friendly,
\scriptsize{just write ``\code{dp1 + dp2}'' to add a couple of delta-points}
\end{itemize}
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-26 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Moves the io's tests.
* tests/Makefile.am: Makefile update due to test moves.
* tests/io/Makefile.am: Likewise.
* tests/io/fits/Makefile.am: Likewise.
* tests/io/pbm/Makefile.am: Likewise.
* tests/io/pgm/Makefile.am: Likewise.
* tests/io/ppm/Makefile.am: Likewise.
* sandbox/garrigues/io_fits.cc: Remove.
* tests/io/fits/io_fits.cc: New.
* tests/io_pbm.cc: Rename as...
* tests/io/pbm/pbm.cc: ...this.
* tests/io_pgm.cc: Rename as...
* tests/io/pgm/pgm.cc: ...this.
* tests/io_pgm16.cc: Rename as...
* tests/io/pgm/pgm16.cc: ...this.
* tests/io_pgm19.cc: Rename as...
* tests/io/pgm/pgm19.cc: ...this.
* tests/io_pgm27.cc: Rename as...
* tests/io/pgm/pgm27.cc: ...this.
* tests/io_ppm.cc: Rename as...
* tests/io/ppm/ppm.cc: ...this.
* tests/io_ppm16.cc: Rename as...
* tests/io/ppm/ppm16.cc: ...this.
* tests/io_ppm23.cc: Rename as...
* tests/io/ppm/ppm23.cc: ...this.
* tests/new_io_pgm.cc: Remove, now into tests/io/pgm/pgm.cc.
Fix style and doc.
* mln/accu/compute.hh,
* mln/io/ppm/load.hh: Fix.
---
trunk/milena/mln/accu/compute.hh | 3
trunk/milena/tests/Makefile.am | 17 -----
trunk/milena/tests/io/Makefile.am | 8 ++
trunk/milena/tests/io/fits/Makefile.am | 7 ++
trunk/milena/tests/io/fits/io_fits.cc | 77 +++++++++++++++++++++++
trunk/milena/tests/io/pbm/Makefile.am | 7 ++
trunk/milena/tests/io/pbm/pbm.cc | 55 ++++++++++++++++
trunk/milena/tests/io/pgm/Makefile.am | 12 +++
trunk/milena/tests/io/pgm/pgm.cc | 62 ++++++++++++++++++
trunk/milena/tests/io/pgm/pgm16.cc | 95 ++++++++++++++++++++++++++++
trunk/milena/tests/io/pgm/pgm19.cc | 95 ++++++++++++++++++++++++++++
trunk/milena/tests/io/pgm/pgm27.cc | 95 ++++++++++++++++++++++++++++
trunk/milena/tests/io/ppm/Makefile.am | 12 +++
trunk/milena/tests/io/ppm/ppm.cc | 49 ++++++++++++++
trunk/milena/tests/io/ppm/ppm16.cc | 110 +++++++++++++++++++++++++++++++++
trunk/milena/tests/io/ppm/ppm23.cc | 110 +++++++++++++++++++++++++++++++++
16 files changed, 796 insertions(+), 18 deletions(-)
Index: trunk/milena/tests/io_pgm.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_pgm19.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_ppm23.cc (deleted)
===================================================================
Index: trunk/milena/tests/new_io_pgm.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_pbm.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_ppm.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_ppm16.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_pgm27.cc (deleted)
===================================================================
Index: trunk/milena/tests/io_pgm16.cc (deleted)
===================================================================
Index: trunk/milena/tests/Makefile.am
===================================================================
--- trunk/milena/tests/Makefile.am (revision 1536)
+++ trunk/milena/tests/Makefile.am (revision 1537)
@@ -68,13 +68,6 @@
image_if_value \
interpolated \
io_pbm \
- io_pgm16 \
- io_pgm19 \
- io_pgm27 \
- io_pgm \
- io_ppm16 \
- io_ppm23 \
- io_ppm \
\
labeling_algo \
labeling_estimate \
@@ -109,7 +102,6 @@
morpho_opening_area \
morpho_thinning \
\
- new_io_pgm \
norm_l2 \
\
pixel \
@@ -215,14 +207,6 @@
image_if_interval_SOURCES = image_if_interval.cc
image_if_value_SOURCES = image_if_value.cc
interpolated_SOURCES = interpolated.cc
-io_pbm_SOURCES = io_pbm.cc
-io_pgm16_SOURCES = io_pgm16.cc
-io_pgm19_SOURCES = io_pgm19.cc
-io_pgm27_SOURCES = io_pgm27.cc
-io_pgm_SOURCES = io_pgm.cc
-io_ppm16_SOURCES = io_ppm16.cc
-io_ppm23_SOURCES = io_ppm23.cc
-io_ppm_SOURCES = io_ppm.cc
labeling_algo_SOURCES = labeling_algo.cc
labeling_estimate_SOURCES = labeling_estimate.cc
@@ -257,7 +241,6 @@
morpho_opening_area_SOURCES = morpho_opening_area.cc
morpho_thinning_SOURCES = morpho_thinning.cc
-new_io_pgm_SOURCES = new_io_pgm.cc
norm_l2_SOURCES = norm_l2.cc
pixel_SOURCES = pixel.cc
Index: trunk/milena/tests/io/pgm/pgm27.cc
===================================================================
--- trunk/milena/tests/io/pgm/pgm27.cc (revision 0)
+++ trunk/milena/tests/io/pgm/pgm27.cc (revision 1537)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_pgm27.cc
+ *
+ * \brief Test on mln::io::pgm::load and mln::io::pgm::save.
+ */
+
+
+#include <mln/core/image2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/level/compare.hh>
+
+
+ using namespace mln;
+
+struct to27bits : mln::Function_v2v<to27bits>
+{
+
+ typedef value::int_u<27> result;
+ result operator()(value::int_u8 v) const
+ {
+ result ret(v * 524288);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::int_u8 result;
+ result operator()(value::int_u<27> v) const
+ {
+ result ret(v / 524288);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u;
+ typedef value::int_u<27> int_u27;
+
+ image2d<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+ image2d<int_u27> out(lena.domain());
+
+ level::transform(lena, to27bits(), out);
+
+ io::pgm::save(out, "out27.pgm");
+
+ image2d<int_u27> lena2;
+ io::pgm::load(lena2, "out27.pgm");
+
+ image2d<int_u8> out2(lena.domain());
+
+ level::transform(lena2, to8bits(), out2);
+
+ io::pgm::save(out2, "out8.pgm");
+
+ assert(out2 == lena);
+
+}
Index: trunk/milena/tests/io/pgm/pgm19.cc
===================================================================
--- trunk/milena/tests/io/pgm/pgm19.cc (revision 0)
+++ trunk/milena/tests/io/pgm/pgm19.cc (revision 1537)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_pgm19.cc
+ *
+ * \brief Test on mln::io::pgm::load and mln::io::pgm::save.
+ */
+
+#include <mln/core/image2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/transform.hh>
+#include <mln/level/compare.hh>
+
+
+ using namespace mln;
+
+struct to19bits : mln::Function_v2v<to19bits>
+{
+
+ typedef value::int_u<19> result;
+ result operator()(value::int_u8 v) const
+ {
+ result ret(v * 524288);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::int_u8 result;
+ result operator()(value::int_u<19> v) const
+ {
+ result ret(v / 524288);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u;
+ typedef value::int_u<19> int_u19;
+
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+ image2d<int_u19> out(lena.domain());
+
+ level::transform(lena, to19bits(), out);
+
+ io::pgm::save(out, "out19.pgm");
+
+ image2d<int_u19>
+ lena2 = io::pgm::load<int_u19>("out19.pgm");
+ image2d<int_u8> out2(lena.domain());
+
+ level::transform(lena2, to8bits(), out2);
+
+ io::pgm::save(out2, "out8.pgm");
+
+ assert(out2 == lena);
+
+}
Index: trunk/milena/tests/io/pgm/pgm.cc
===================================================================
--- trunk/milena/tests/io/pgm/pgm.cc (revision 0)
+++ trunk/milena/tests/io/pgm/pgm.cc (revision 1537)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_pgm.cc
+ *
+ * \brief Test on mln::io::pgm::load and mln::io::pgm::save.
+ */
+
+
+#include <mln/core/image2d.hh>
+
+#include <mln/value/int_u8.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+
+ {
+ image2d<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+
+ io::pgm::save(lena, "out.pgm");
+ }
+
+
+ {
+ image2d< value::int_u<8> >
+ lena;
+ io::pgm::load(lena, "../img/lena.pgm");
+
+ io::pgm::save(lena, "out.pgm");
+ }
+
+}
Index: trunk/milena/tests/io/pgm/Makefile.am
===================================================================
--- trunk/milena/tests/io/pgm/Makefile.am (revision 1536)
+++ trunk/milena/tests/io/pgm/Makefile.am (revision 1537)
@@ -1,3 +1,15 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ pgm16 \
+ pgm19 \
+ pgm27 \
+ pgm
+
+pgm16_SOURCES = pgm16.cc
+pgm19_SOURCES = pgm19.cc
+pgm27_SOURCES = pgm27.cc
+pgm_SOURCES = pgm.cc
+
Index: trunk/milena/tests/io/pgm/pgm16.cc
===================================================================
--- trunk/milena/tests/io/pgm/pgm16.cc (revision 0)
+++ trunk/milena/tests/io/pgm/pgm16.cc (revision 1537)
@@ -0,0 +1,95 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_pgm16.cc
+ *
+ * \brief Test on mln::io::pgm::load and mln::io::pgm::save.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/value/int_u8.hh>
+#include <mln/value/int_u16.hh>
+
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/level/transform.hh>
+
+
+ using namespace mln;
+
+struct to16bits : mln::Function_v2v<to16bits>
+{
+
+ typedef value::int_u16 result;
+ result operator()(value::int_u8 v) const
+ {
+ result ret(v * 256);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::int_u8 result;
+ result operator()(value::int_u16 v) const
+ {
+ result ret(v / 256);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::int_u8;
+ using value::int_u16;
+
+ win::rectangle2d rect(51, 51);
+ border::thickness = 52;
+
+ image2d<int_u8>
+ lena = io::pgm::load<int_u8>("../img/lena.pgm");
+ image2d<int_u16> out(lena.domain());
+
+ level::transform(lena, to16bits(), out);
+
+ io::pgm::save(out, "out16.pgm");
+
+ image2d<int_u16>
+ lena2 = io::pgm::load<int_u16>("out16.pgm");
+ image2d<int_u8> out2(lena.domain());
+
+ level::transform(lena2, to8bits(), out2);
+
+ io::pgm::save(out2, "out8.pgm");
+
+
+}
Index: trunk/milena/tests/io/fits/io_fits.cc
===================================================================
--- trunk/milena/tests/io/fits/io_fits.cc (revision 0)
+++ trunk/milena/tests/io/fits/io_fits.cc (revision 1537)
@@ -0,0 +1,77 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/fits_load.cc
+ *
+ * \brief Test on mln::io::fits::load.
+ */
+
+#include <mln/core/image2d_b.hh>
+
+#include <mln/level/compare.hh>
+#include <mln/debug/println.hh>
+
+#include <mln/io/fits/load.hh>
+#include <mln/io/pfm/save.hh>
+#include <mln/io/pfm/load.hh>
+
+int main()
+{
+ using namespace mln;
+ {
+ image2d_b<float>
+ fits_in = io::fits::load("../../img/test.fits");
+
+ debug::println(fits_in);
+
+ io::pfm::save(fits_in, "out.pfm");
+
+ image2d_b<float>
+ pfm = io::pfm::load("out.pfm");
+
+ io::pfm::save(fits_in, "out2.pfm");
+
+ image2d_b<float>
+ pfm2 = io::pfm::load("out2.pfm");
+
+ image2d_b<float>::fwd_piter p(fits_in.domain());
+ for_all(p)
+ if (fits_in(p) != pfm(p))
+ std::cout << "at " << p
+ << " ref :" << fits_in(p)
+ << " pfm2 : " << pfm(p) << std::endl;
+
+ mln_assertion(fits_in == pfm2);
+
+ // }
+ // {
+ // image2d_b<int_u8>
+ // lena = io::fits::load<int_u8>("../img/lena.fits");
+
+ // io::fits::save(lena, "out.fits");
+ }
+}
Index: trunk/milena/tests/io/fits/Makefile.am
===================================================================
--- trunk/milena/tests/io/fits/Makefile.am (revision 1536)
+++ trunk/milena/tests/io/fits/Makefile.am (revision 1537)
@@ -1,3 +1,10 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ fits \
+
+fits_SOURCES = fits.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/io/Makefile.am
===================================================================
--- trunk/milena/tests/io/Makefile.am (revision 1536)
+++ trunk/milena/tests/io/Makefile.am (revision 1537)
@@ -1,3 +1,11 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+SUBDIRS = \
+ fits \
+ pbm \
+ pfm \
+ pgm \
+ pnm \
+ ppm
Index: trunk/milena/tests/io/ppm/ppm.cc
===================================================================
--- trunk/milena/tests/io/ppm/ppm.cc (revision 0)
+++ trunk/milena/tests/io/ppm/ppm.cc (revision 1537)
@@ -0,0 +1,49 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_ppm.cc
+ *
+ * \brief Test on mln::io::ppm::load and mln::io::ppm::save.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+
+
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+
+ image2d<rgb8> lena = io::ppm::load("../img/lena.ppm");
+ io::ppm::save(lena, "out.ppm");
+}
Index: trunk/milena/tests/io/ppm/ppm23.cc
===================================================================
--- trunk/milena/tests/io/ppm/ppm23.cc (revision 0)
+++ trunk/milena/tests/io/ppm/ppm23.cc (revision 1537)
@@ -0,0 +1,110 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_ppm23.cc
+ *
+ * \brief Test on mln::io::ppm::load and mln::io::ppm::save.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/value/rgb8.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/level/compare.hh>
+
+
+using namespace mln;
+
+typedef value::rgb<23> rgb23;
+
+struct to23bits : mln::Function_v2v<to23bits>
+{
+
+ typedef rgb23 result;
+ result operator()(value::rgb8 v) const
+ {
+ result ret(v.red().to_enc() * 256,
+ v.green().to_enc() * 256,
+ v.blue().to_enc() * 256);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::rgb8 result;
+ result operator()(rgb23 v) const
+ {
+ result ret(v.red().to_enc() / 256,
+ v.green().to_enc() / 256,
+ v.blue().to_enc() / 256);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+
+ typedef image2d<rgb8> I;
+
+
+ // load a 8bits image A
+ image2d<rgb8>
+ a = io::ppm::load<rgb8>("../img/lena.ppm");
+ image2d<rgb23> b(a.domain());
+
+ image2d<rgb8>::fwd_piter p(b.domain());
+
+ // save it as a 23bits ppm image B
+ to23bits f;
+ for_all(p)
+ b(p) = f(a(p));
+ io::ppm::save(b, "out23.ppm");
+
+ // reload B into C
+ image2d<rgb23>
+ c = io::ppm::load<rgb23>("out23.ppm");
+ image2d<rgb8> d(a.domain());
+
+
+ // save C as a 8bits ppm image D
+ to8bits g;
+ for_all(p)
+ d(p) = g(c(p));
+ io::ppm::save(d, "out8.ppm");
+
+ // D should equals A
+ mln_assertion(d == a);
+
+}
Index: trunk/milena/tests/io/ppm/ppm16.cc
===================================================================
--- trunk/milena/tests/io/ppm/ppm16.cc (revision 0)
+++ trunk/milena/tests/io/ppm/ppm16.cc (revision 1537)
@@ -0,0 +1,110 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_ppm16.cc
+ *
+ * \brief Test on mln::io::ppm::load and mln::io::ppm::save.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/win/rectangle2d.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb16.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/level/compare.hh>
+
+
+using namespace mln;
+
+struct to16bits : mln::Function_v2v<to16bits>
+{
+
+ typedef value::rgb16 result;
+ result operator()(value::rgb8 v) const
+ {
+ result ret(v.red().to_enc() * 256,
+ v.green().to_enc() * 256,
+ v.blue().to_enc() * 256);
+ return ret;
+ }
+};
+
+struct to8bits : mln::Function_v2v<to8bits>
+{
+
+ typedef value::rgb8 result;
+ result operator()(value::rgb16 v) const
+ {
+ result ret(v.red().to_enc() / 256,
+ v.green().to_enc() / 256,
+ v.blue().to_enc() / 256);
+ return ret;
+ }
+};
+
+int main()
+{
+ using namespace mln;
+ using value::rgb8;
+ using value::rgb16;
+
+ typedef image2d<rgb8> I;
+
+
+ // load a 8bits image A
+ image2d<rgb8>
+ a = io::ppm::load<rgb8>("../img/lena.ppm");
+ image2d<rgb16> b(a.domain());
+
+ image2d<rgb8>::fwd_piter p(b.domain());
+
+ // save it as a 16bits ppm image B
+ to16bits f;
+ for_all(p)
+ b(p) = f(a(p));
+ io::ppm::save(b, "out16.ppm");
+
+ // reload B into C
+ image2d<rgb16>
+ c = io::ppm::load<rgb16>("out16.ppm");
+ image2d<rgb8> d(a.domain());
+
+
+ // save C as a 8bits ppm image D
+ to8bits g;
+ for_all(p)
+ d(p) = g(c(p));
+ io::ppm::save(d, "out8.ppm");
+
+ // D should equals A
+ mln_assertion(d == a);
+
+}
Index: trunk/milena/tests/io/ppm/Makefile.am
===================================================================
--- trunk/milena/tests/io/ppm/Makefile.am (revision 1536)
+++ trunk/milena/tests/io/ppm/Makefile.am (revision 1537)
@@ -1,3 +1,15 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ ppm16 \
+ ppm23 \
+ ppm
+
+ppm16_SOURCES = ppm16.cc
+ppm23_SOURCES = ppm23.cc
+ppm_SOURCES = ppm.cc
+
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/tests/io/pbm/pbm.cc
===================================================================
--- trunk/milena/tests/io/pbm/pbm.cc (revision 0)
+++ trunk/milena/tests/io/pbm/pbm.cc (revision 1537)
@@ -0,0 +1,55 @@
+// Copyright (C) 2007 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.
+
+/*! \file tests/io_pbm.cc
+ *
+ * \brief Test on mln::io::pbm::.
+ */
+
+#include <mln/core/image2d.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+
+
+int main()
+{
+ using namespace mln;
+
+ image2d<bool> pic = io::pbm::load("../img/picasso.pbm");
+ io::pbm::save(pic, "pic.pbm");
+}
+
+
+// sample binary image to test with xv, imview, and display
+// to bring into the fore the binary image bug with raw pbm.
+
+// | | | | -
+// | | - - -
+// | - - - -
+// - - - - -
+// - - - - -
+// - - - - -
Index: trunk/milena/tests/io/pbm/Makefile.am
===================================================================
--- trunk/milena/tests/io/pbm/Makefile.am (revision 1536)
+++ trunk/milena/tests/io/pbm/Makefile.am (revision 1537)
@@ -1,3 +1,10 @@
## Process this file through Automake to create Makefile.in -*- Makefile -*-
include $(top_srcdir)/milena/tests/tests.mk
+
+check_PROGRAMS = \
+ pbm
+
+pbm_SOURCES = pbm.cc
+
+TESTS = $(check_PROGRAMS)
Index: trunk/milena/mln/accu/compute.hh
===================================================================
--- trunk/milena/mln/accu/compute.hh (revision 1536)
+++ trunk/milena/mln/accu/compute.hh (revision 1537)
@@ -51,7 +51,8 @@
* \param[in] input The input image.
*
* This routine runs: \n
- * FIXME
+ * a.take(make::pix(input, p));
+ * on all pixels on the images.
*
* \warning This routine does not perform a.init().
*/
Index: trunk/milena/mln/io/ppm/load.hh
===================================================================
Index: trunk/milena/sandbox/garrigues/io_fits.cc (deleted)
===================================================================