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
September 2008
- 12 participants
- 359 discussions
URL: https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
ChangeLog:
2008-09-09 Guillaume Lazzara <z(a)lrde.epita.fr>
Remove useless '_' in class names.
* mln/core/alias/box3d.hh: remove underscore to box_.
* mln/core/alias/dpoint3d.hh: remove underscore to dpoint_.
* mln/core/alias/point3d.hh: remove underscore to point_.
---
box3d.hh | 2 +-
dpoint3d.hh | 2 +-
point3d.hh | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
Index: branches/cleanup-2008/milena/mln/core/alias/dpoint3d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/alias/dpoint3d.hh (revision 2206)
+++ branches/cleanup-2008/milena/mln/core/alias/dpoint3d.hh (revision 2207)
@@ -44,7 +44,7 @@
/*! \brief Type alias for a delta-point defined on the 3D square
* grid with integer coordinates.
*/
- typedef dpoint_<mln::grid::cube, int> dpoint3d;
+ typedef dpoint<mln::grid::cube, int> dpoint3d;
} // end of namespace mln
Index: branches/cleanup-2008/milena/mln/core/alias/box3d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/alias/box3d.hh (revision 2206)
+++ branches/cleanup-2008/milena/mln/core/alias/box3d.hh (revision 2207)
@@ -46,7 +46,7 @@
*
* \see mln::win::rectangle3d.
*/
- typedef box_<point3d> box3d;
+ typedef box<point3d> box3d;
} // end of namespace mln
Index: branches/cleanup-2008/milena/mln/core/alias/point3d.hh
===================================================================
--- branches/cleanup-2008/milena/mln/core/alias/point3d.hh (revision 2206)
+++ branches/cleanup-2008/milena/mln/core/alias/point3d.hh (revision 2207)
@@ -43,7 +43,7 @@
/*! \brief Type alias for a point defined on the 3D square grid with
* integer coordinates.
*/
- typedef point_<grid::cube, def::coord> point3d;
+ typedef point<grid::cube, def::coord> point3d;
} // end of namespace mln
1
0
URL: https://svn.lrde.epita.fr/svn/oln
Git branch: cleanup (HEAD: 89187b2)
ChangeLog:
2008-09-09 Guillaume Lazzara <z(a)lrde.epita.fr>
Improve tutorial.
* milena/doc/tutorial/tutorial.tex: improve explanations.
---
ChangeLog | 5 +
milena/doc/tutorial/tutorial.tex | 683 ++++++++++++++++++++++++++++++++++++++
2 files changed, 688 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 4df034a..d9cd0f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-09-09 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Improve tutorial.
+ * milena/doc/tutorial/tutorial.tex: improve explanations.
+
2008-09-05 Nicolas Ballas <ballas(a)lrde.epita.fr>
Update configure.ac.
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
new file mode 100644
index 0000000..a960006
--- /dev/null
+++ b/milena/doc/tutorial/tutorial.tex
@@ -0,0 +1,683 @@
+\documentclass{report}
+\usepackage{graphicx}
+\usepackage{listings}
+\usepackage{makeidx}
+\usepackage{xcolor}
+\usepackage{color}
+
+\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{}
+
+%%%LISTINGS SETTINGS
+\lstset{frameround=fttt}
+\lstloadlanguages{C++}
+\lstset{language=C++}
+\lstset{backgroundcolor=\color{black},
+basicstyle=\bfseries\color{white},
+identifierstyle=\color{green},
+stringstyle=\color{yellow},
+commentstyle=\color{red},
+showstringspaces=false,linewidth=14cm}
+
+
+\begin{document}
+
+\tableofcontents
+
+ajouter dans => milena/doc/tutorial |
+-------------------------------------------------
+
+\chapter{Foreword}
+
+The following tutorial talks about 2D images. We chose that kind of images
+because it is easier to understand and this is the
+most used. \\
+
+FIXME
+[dessin de grille 2d, colonnes/lignes numerotees + repere x/y]
+Intersection <=> point 2d <=> milieu d'un pixel \\
+
+Since examples are based on 2D images pixels are actually "points" however we
+will call them "sites" which is the most generic name.\\
+
+Here is also a list of common variable name conventions:
+\begin{figure}[ht!]
+ \begin{tabular}{|l|l|}
+ \hline
+ \textbf{Object} & \textbf{Variable name} \\ \hline
+ Site & p \\ \hline
+ Value & v \\ \hline
+ Neighboor & n \\ \hline
+ A site close to another site p & q \\ \hline
+ \end{tabular}
+\end{figure}
+
+Methods provided by the objects in the library are in constant time. If you need
+a specific method but you cannot find it, you may find an algorithm which can
+compute the information you need.
+
+Olena is organized in a namespace hierarchy. Everything is declared by Olena
+within the 'oln::' namespace, and possibly a sub-namespace such as
+'oln::arith::' (arithmetic operations on images), 'oln::morpho::' (morphological
+operations), etc. For the sake of simplicity, we will neglect the 'oln::'
+prefix in all the code examples.
+
+
+\chapter{Concepts}
+//FIXME lister \underline{TOUS} les concepts (core/concepts)
+
+\section{Site set}
+
+Site sets are used:
+\begin{enumerate}
+ \item To define an image definition domain.
+ \item As Site container.
+\end{enumerate}
+
+Here is a list of all the site set concepts which can be found in
+core/site\_set:
+
+\begin{tabular}{|l|p{8cm}|}
+\hline
+Site set & Description \\ \hline
+
+p\_key & \\ \hline
+p\_priority & \\ \hline
+p\_box & \\ \hline
+p\_bgraph & \\ \hline
+p\_double & \\ \hline
+p\_if & \\ \hline
+p\_line\_graph & \\ \hline
+p\_queue\_fast & \\ \hline
+p\_set & \\ \hline
+p\_faces & \\ \hline
+p\_queue & \\ \hline
+p\_set\_of & \\ \hline
+line2d & \\ \hline
+p\_complex & \\ \hline
+p\_graph & \\ \hline
+p\_image & \\ \hline
+p\_mutable\_array\_of & \\ \hline
+p\_run & \\ \hline
+p\_vaccess & \\ \hline
+\end{tabular}
+
+\subsection{Basic interface}
+Common basic interface:\\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Commor type automatically from the
+given container type
+passed as parameter. These macros can be used with any container like images or
+site sets.ents \\ \hline
+
+bool & is\_valid & - & X & Returns true if it has been initialized. The
+default constructor does not do it. \\ \hline
+
+bool & has & const P\& p & X & \\ \hline
+\end{tabular} \\
+
+
+\subsection{Optional interface}
+Site sets may have other methods depending on their type: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+size\_t & nsites & - & - & \\ \hline
+const Box\& & bbox & - & X & Bounding box. Available only on grid site sets.
+\\ \hline
+\end{tabular} \\
+
+The previous methods are available depending on the site set. A box
+will have the bbox() method since it can be retrived in constant time: a box
+is it's own bounding box (see \ref{fig:box_bbox}). A p\_array does not have this
+method since sites do not have to be adjacent. Maintaining such information, in
+order to keep getting the bbox in constant time, would be time and memory
+consuming. Instead of providing a method directly in p\_array, an algorithm is
+available if this information needed (see \ref{fig:parray_bbox}).
+P\_array and box both have a nsites method since the internal structure allow a
+constant time retrieval.
+
+\subsubsection*{Sample code}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ p_array<point2d> arr;
+
+ // The bbox is computed thanks to bbox() algorithm.
+ box2d box = geom::bbox(arr);
+ std::cout << box << std::endl;
+
+ // p_array provides nsites(),
+ // it can be retrieved in constant time.
+ std::cout << "nsites = " << arr.nsites() << std::endl;
+ \end{lstlisting}
+ \caption{How to retrieve information from a p\_array.\label{fig:parray_bbox}}
+\end{figure}
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d b(2,3);
+
+ // The bbox can be retrived in constant time.
+ std::cout << b.bbox() << std::endl;
+
+ // nsites can be retrieved in constant time.
+ std::cout << "nsites = " << b.nsites() << std::endl;
+ \end{lstlisting}
+ \caption{How to retrieve information from a box.\label{fig:box_bbox}}
+\end{figure}
+
+\clearpage
+\newpage
+\section{Image}
+
+An image is composed both of:
+\begin{itemize}
+\item A function $$
+f : \left\{
+ \begin{array}{lll}
+ Site &\rightarrow & Value \\
+ p & \mapsto & v
+ \end{array}
+\right.
+$$
+\item A site set, also called the "domain".
+\end{itemize}
+
+Every image type is defined on a specific site type. An image2d will always
+have a domain defined by a box2d.
+The Value set, which includes all the possible values a site can have, is also
+called "destination" set.
+
+An image has a virtual border which is defined thanks to its domain. The
+ border is virtual since the image can have an extended domain as well.
+That one is optional, it defines sites outside the virtual border which is
+useful in algorithms when working with sites being part of the domain but close
+to the borders. The virtual border can be defined thanks to a function, an
+image or a site set.
+
+//FIXME: remove this line
+ici, site <=> Point2d
+
+
+[sample code]
+
+In order to create a 2D image, you have two possibilites:
+\begin{lstlisting}[frame=single]
+ // which builds an empty image;
+ image2d<int> img1a;
+ // which builds an image with 6 sites
+ image2d<int> img1b(box2d(2, 3));
+\end{lstlisting}
+
+The empty image has no data and its definition domain is still unset. We do
+not know yet the number of sites it contains. However, it is really useful to
+have such an "empty image" because it is a placeholder for the result of some
+processing, or another image.
+
+Trying to access the site value from an empty image leads to an error at
+run-time.
+
+
+\begin{lstlisting}[frame=single]
+ box2d b(2,3);
+ image2d<int> ima(b); // Define the domain of the image.
+
+ cout << b << std::endl; // Display b
+
+ cout << ima.domain() << std::endl; // Display b too
+\end{lstlisting}
+
+\begin{lstlisting}[frame=single]
+ box2d b(2,3);
+ image2d<int> ima(b);
+ point2d p(1, 2);
+
+ ima.at(1,2) = 9; // The value is returned by reference
+ // and can be changed.
+ cout << ima(p) << std::endl; // prints 9
+
+ ima(p) = 2; // The value is returned by reference
+ // and can be changed.
+ cout << ima(p) << std::endl; // prints 2
+\end{lstlisting}
+
+
+To know if a point belongs to an image domain or not, we can run this short
+test:
+\begin{lstlisting}[frame=single]
+point2d p(9, 9);
+
+// which gives 'true'.
+std::cout << (imga.has(p) ? "true" : "false") << std::endl;
+\end{lstlisting}
+
+Since the notion of point is independent from the image it applies on, we can
+form expressions where p is used on several images:
+\begin{lstlisting}[frame=single]
+// At index (9, 9), both values change.
+imga(p) = 'M', imgb(p) = 'W';
+
+debug::println(imga);
+debug::println(imgb);
+\end{lstlisting}
+
+
+Images do not actually store the data in the class. This is a pointer
+to an allocated space which can be shared with other objects. Once an image is
+assigned to another one, the two images share the same data so they have the
+same ID and point to the same memory space.
+Therefore, assigning an image to another one is NOT a costly operation. The new
+variable behaves like some mathematical variable. Put differently it is just a
+name to designate an image:
+\begin{lstlisting}[frame=single]
+ image2d<int> ima1(box2d(2, 3));
+ image2d<int> ima2;
+ point2d p(1,2);
+
+ ima2 = ima1; // ima1.id() == ima2.id()
+ // and both point to the same memory area.
+
+ ima2(p) = 2; // ima1 is modified as well.
+
+ // prints "2 - 2"
+ std::cout << ima2(p) << " - " << ima1(p) << std::endl;
+ // prints "true"
+ std::cout << (ima2.id() == ima1.id()) << std::endl;
+\end{lstlisting}
+
+If a deep copy of the image is needed, a method clone() is available:
+\begin{lstlisting}[frame=single]
+ image2d<int> ima3 = ima1.clone(); // Makes a deep copy.
+
+ ima3(p) = 3;
+
+ // prints "3 - 2"
+ std::cout << ima3(p) << " - " << ima1(p) << std::endl;
+ // prints "false"
+ std::cout << (ima3.id() == ima1.id()) << std::endl;
+\end{lstlisting}
+
+[Illustration : grille + intersection + pmin() + pmax() + distance entre 2
+points en x et en y = 1]\\
+
+In the Olena library, all image types behave like image2d:
+\begin{itemize}
+\item An "empty" image actually is a mathematical variable.
+
+ $\rightarrow$ just think in a mathemetical way when dealing with images;
+
+\item No dynamic memory allocation/deallocation is required.
+ the user never has to use "new / delete" (the C++ equivalent for the C
+ "malloc / free") so she does not have to manipulate pointers or to directly
+ access memory.
+
+ $\rightarrow$ Olena prevents the user from making mistakes;
+
+\item Image data/values can be shared between several variables and the memory
+ used for image data is handled by the library.
+
+ $\rightarrow$ Memory management is automatic.
+\end{itemize}
+
+
+\subsection{Interface}
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+site\_set & domain & - & X - & \\ \hline
+const Value\& & operator() & const point\& p & X & Used for reading. \\ \hline
+Value\& & operator() & const point\& p & - & Used for writing. \\ \hline
+const P\& & at & unsigned x,
+ unsigned y & X & Used for reading. \\ \hline
+P\& & at & unsigned x,
+ unsigned y & - & Used for writing. \\ \hline
+bool & has & const Point\& p & X & \\ \hline
+bool & has\_data & - & X & Returns true if the domain is defined. \\ \hline
+site\_id & id & - & X & Return the Id of the underlying shared data. \\ \hline
+FIXME & destination & - & X & Value set of all the possible site values in this
+Image. \\ \hline
+site\_set & bbox & - & - & Returns the bounding box of the domain. \\ \hline
+site\_set & bbox\_large & - & - & Returns the bouding box of the domain and the
+extended domain. \\ \hline
+
+\end{tabular}
+
+
+\newpage
+\section{Neighborhood}
+
+
+
+\newpage
+\section{Window}
+
+
+
+\chapter{Iterators}
+
+Every objects
+Each container object in Olena like site sets or images have iterators.
+There are usually three kinds:
+\begin{itemize}
+\item \textbf{fwd\_iter}, depends on the container,
+\item \textbf{bkd\_iter}, iterates like forward but to the opposite way,
+\item \textbf{iter}, usually the same as fwd\_iter. It is guaranteed to
+iterate all over the elements.
+\end{itemize}
+
+The iterator type name depends on the data pointed by it: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Data type & Iterator Names \\ \hline
+Site & fwd\_piter, bkd\_piter, piter \\ \hline
+Value & fwd\_viter, bkd\_viter, viter \\ \hline
+\end{tabular} \\
+
+As you may have noticed, according to the data type, the word "iter" is prefixed
+by the usual name variable used for that data type. Sites variables are usually
+called 'p' so the proper iterator is "piter".\\
+
+
+An iterator has the following interface: \\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Return Type & Name & Arguments & Const & Comments \\ \hline
+
+void & start & - & - & \\ \hline
+void & next & - & - & \\ \hline
+bool & is\_valid & - & - & Return false if created with the default
+constructor and not associated to a proper container.\\ \hline
+\end{tabular} \\
+
+
+Example of different forward iterations:
+\begin{itemize}
+ \item box2d: from top to bottom then from left to right.
+ \item p\_array<point2d>: from left to right.
+\end{itemize}
+
+A for\_all() macro is available to iterate over all the sites
+(Fig. \ref{fig:for_all}). \\
+
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ box2d b(3, 2);
+ mln_piter(box2d) p(b);
+
+ for_all(p)
+ std::cout << p; //prints every site coordinates.
+ \end{lstlisting}
+ \caption{Use of the for\_all() macro.\label{fig:for_all}}
+\end{figure}
+
+Note that when you declare an iterator, prefer using the "mln\_*iter" macros.
+They resolve the iterator type automatically from the given container type
+passed as parameter. These macros can be used with any container like images or
+site sets.
+(\ref{fig:iter_allcontainers}).
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+ image2d<int> ima(box2d(2, 3));
+
+ mln_piter(box2d) p(ima.domain());
+ for_all(p)
+ std::cout << p << std::endl;
+
+ mln_viter(image2d<int>) v(ima.destination());
+ for_all(v)
+ std::cout << v << std::endl;
+ \end{lstlisting}
+ \caption{mln\_*iter macros can be used with any
+containers.\label{fig:iter_allcontainers}}
+\end{figure}
+
+
+\chapter{Basic operations}
+//FIXME : illustrer
+\begin{itemize}
+ \item level::clone(), creates a deep copy of an object. Any shared data is
+duplicated.
+ \item level::fill(), fill an object with a value (fig. \ref{fig:fill_impl}).
+ \item level::paste(), paste object data to another object (fig.
+\ref{fig:paste_impl})
+
+ \item labeling::blobs(), find and label the different components of an image.
+\end{itemize}
+
+First, create an image:
+\begin{lstlisting}[frame=single]
+ image2d<char> imga(0, 0, 20, 20);
+\end{lstlisting}
+
+Memory has been allocated so data can be stored but site values
+have not been initialized yet. So we fill img with the value 'a':
+\begin{lstlisting}[frame=single]
+ level::fill(inplace(imga), 'a');
+\end{lstlisting}
+
+The "fill" algorithm is located in the sub-namespace "level" since this
+algorithm deals with the "level" of site values.
+
+Note that the term "level" refers to the fact that an image can be considered as
+a landscape where the elevation at a particular location/site is given by
+the corresponding site value.
+
+The full name of this routine is "oln::level::fill". To access to a particular
+algorithm, the proper file shall be included. The file names of algorithms
+strictly map their C++ name; so oln::level::fill is defined in the file
+"oln/level/fill.hh".
+
+Most algorithms in Olena are constructed following the classical scheme: "output
+algo(input)", where the input image is only read. However some few algorithms
+take an input image in order to modify it. To enforce this particular feature,
+the user shall explicitly state that the image is provided so that its data is
+modified "inplace". The algorithm call shall be "level::fill(inplace(ima),
+val)". When forgetting the "inplace(..)" statement it does not compile.
+
+We then define below a second image to play with. As you can see this image has
+data for the sites (5, 5) to (14, 14) (so it has 100 sites). The definition
+domain of a 2D image can start from any sites, even a negative one.
+
+\begin{lstlisting}[frame=single]
+ image1d<char> imgb(5, 5, 14, 14);
+
+ // We initialize the image values.
+ level::fill(inplace(imgb), 'b');
+
+ // Last we now paste the contents of img3b in img3a...
+ level::paste(imgb, inplace(imga));
+
+ // ...and print the result.
+ debug::println(imga);
+\end{lstlisting}
+
+Before pasting, the couple of images looked like:
+
+//FIXME : ajouter des zolies zimages.
+
+so after pasting we get:
+
+//FIXME : ajouter des zolies zimages again.
+
+With this simple example we can see that images defined on different domains (or
+set of sites) can interoperate. The set of sites of an image is defined and
+can be accessed and printed. The following code:
+
+\begin{lstlisting}[frame=single]
+ std::cout << "imga.domain() = " << imga.domain()
+ << std::endl;
+ std::cout << "imgb.domain() = " << imgb.domain()
+ << std::endl;
+\end{lstlisting}
+
+Gives:
+\begin{lstlisting}[frame=single]
+ imga.domain() = { (0,0) .. (19,19) }
+ imgb.domain() = { (5,5) .. (14,14) }
+\end{lstlisting}
+
+The notion of site sets plays an important role in Olena. Many tests are
+performed at run-time to ensure that the program is correct.
+
+For instance, the algorithm level::paste tests that the set of sites of imgb
+(whose values are to be pasted) is a subset of the destination image.
+
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+template <typename I>
+void fill(I& ima, mln_value(I) v)
+{
+ mln_piter(I) p(ima.domain());
+ for_all(p)
+ ima(p) = v;
+}
+ \end{lstlisting}
+ \caption{Implementation of the fill routine.\label{fig:fill_impl}}
+\end{figure}
+
+
+\begin{figure}[ht!]
+ \begin{lstlisting}[frame=single]
+template <typename I, typename J>
+void paste(const I& data, J& dest)
+{
+ mln_piter(I) p(data.domain());
+ for_all(p)
+ dest(p) = data(p);
+}
+ \end{lstlisting}
+ \caption{Implementation of the paste routine.\label{fig:paste_impl}}
+\end{figure}
+
+
+\section{Working with parts of an image}
+
+Sometime it may be interesting to work only on some part of the image or to
+extract only a sub set of that image. Olena enables that thoughout out the
+operator '$|$'.
+
+Three kinds of that operator exist:\\
+
+\begin{tabular}{|l|l|l|l|p{4cm}|}
+\hline
+Prototype & Comments \\ \hline
+
+Image $|$ Sub Domain & Create a new image.\\ \hline
+Image $|$ Function\_p2b & Do not create a new image but create a morpher.\\
+\hline
+Function\_p2v $|$ Sub Domain & Do not create a new image but create a morpher.\\
+\hline
+\end{tabular} \\
+
+A Sub Domain can be a site set, an image or any value returned by this
+operator.
+For a given site, Function\_p2v returns a Value and Function\_p2b returns a
+boolean. These functions. are actually a sort of predicate. You can easily get
+of function of function\_p2v kind thanks to pw::value(Image). It returns the
+point to value function used in the given image. C functions can also be used as
+predicate by passing the function pointer.
+
+You can easily get a function\_p2b by comparing the value returned
+by a function\_p2v to another Value.
+The following sample code illustrates this feature.
+
+In this section, all along the examples, the image "ima" will refer to the
+following declaration:
+\begin{lstlisting}[frame=single]
+ 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}
+ };
+ image2d<bool> ima = make::image2d(vals);
+\end{lstlisting}
+
+A simple example is to fill only a part of an image with a specific value:
+\begin{lstlisting}[frame=single]
+p_array2d<bool> arr;
+
+// We add two points in the array.
+arr.append(point2d(0, 1));
+arr.append(point2d(4, 0));
+
+// We restrict the image to the sites
+// contained in arr and fill these ones
+// with 0.
+// We must call "inplace" here.
+fill(inplace(ima | arr), 0);
+
+
+mln_VAR(ima2, ima | arr);
+// We do not need to call "inplace" here.
+fill(ima2, 0);
+\end{lstlisting}
+
+The two next examples extract a specific component from an image and fill a new
+image with red only in the extracted component's domain.
+\begin{lstlisting}[frame=single]
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ // Find and label the different components.
+ int_u8 nlabels;
+ image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels);
+
+ // Store a boolean image. True if the site is part of
+ // component 2, false otherwise.
+ mln_VAR(lab_2b, lab | (pw::value(lab) == 2));
+
+ // Get the sub site set containing only the sites
+ // part of component 2.
+ mln_VAR(lab_2, lab_2b.domain(1));
+
+ // Fill the sites of component 2 with red.
+ fill(lab_2, color::red);
+\end{lstlisting}
+
+The previous example can be written more quickly:
+\begin{lstlisting}[frame=single]
+ using namespace mln;
+ using value::int_u8;
+ using value::rgb8;
+
+ // Find and label the different components.
+ int_u8 nlabels;
+ image2d<int_u8> lab = labeling::blobs(ima, c4(), nlabels);
+
+ // Fill the sites of component 2 with red.
+ fill(inplace(lab.domain(2)), color::red);
+\end{lstlisting}
+
+
+\chapter{Graphes and images}
+
+
+
+\end{document}
\ No newline at end of file
1
0
Re: [Olena-patches] [Olena] #133: Use consistent naming convention (w.r.t. underscores, abbreviations, etc.)
by Olena 09 Sep '08
by Olena 09 Sep '08
09 Sep '08
#133: Use consistent naming convention (w.r.t. underscores, abbreviations, etc.)
-----------------------+----------------------------------------------------
Reporter: levill_r | Owner: Olena Team
Type: defect | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Resolution: | Keywords: name coding style
-----------------------+----------------------------------------------------
Changes (by levill_r):
* reporter: nivault => levill_r
* summary: Naming convention on accumulators => Use consistent naming
convention (w.r.t. underscores, abbreviations,
etc.)
* milestone: Olena 1.1 => Olena 1.0
* keywords: accumulator naming conventions => name coding style
* type: task => defect
Old description:
> In the file source:/trunk/milena/mln/accu/median.hh the class does not
> have any underscore.
New description:
We should write down __rules__ about names. For the moment,
wiki:Olena/Release1.0beta#NamingconventionsforOlena1.0 seems to be a good
place to write them. We might want to push them into the (developer)
documentation later.
This ticket is a (relatively) unordered list of spotted issues. Decide,
reorder and fix. Don't close this ticket too soon, and use it a as memo.
= Types (underscores, names) =
We adopted many silent conventions while developing the project, and
inconsistencies arose. Here is a (non comprehensive) list of things to
fix:
* In source:trunk/mln/core/ `mln::window` vs `mln::neighb_` (full name vs
short name + no trailing underscore vs trailing underscore)
* Likewise, we have `mln::window` (without « `_` ») but `mln::point_`,
etc.
* In source:/trunk/milena/mln/accu/median.hh the class does not have any
trailing underscore, whereas other accumulators from
source:/trunk/milena/mln/accu/ have one.
* graph- and complex-related domain-iterators have trailing underscores,
whereas their vicinity counterparts does not.
= Traits macros =
* Should we use `mln_sum(V)` or `mln_trait_value_sum(V)` in the library
code? I (Roland) think so.
= Neighborhoods =
* The terms/prefixes `nbh`, `neighb` and `neighborhood` are used
inconsistently throughout the project. Here are the files that should be
checked (and possibly renamed), as of revision r1859:
* source:trunk/milena/mln/core/clock_neighb.hh
* source:trunk/milena/mln/core/clock_neighb2d.hh
* source:trunk/milena/mln/core/concept/doc/neighborhood.hh
* source:trunk/milena/mln/core/concept/neighborhood.hh
* source:trunk/milena/mln/core/graph_elt_neighborhood.hh
* source:trunk/milena/mln/core/graph_neighborhood_piter.hh
* source:trunk/milena/mln/core/line_graph_elt_neighborhood.hh
* source:trunk/milena/mln/core/line_graph_neighborhood_piter.hh
* source:trunk/milena/mln/core/neighb.hh
* source:trunk/milena/mln/core/neighb1d.hh
* source:trunk/milena/mln/core/neighb2d.hh
* source:trunk/milena/mln/core/neighb3d.hh
* source:trunk/milena/mln/metal/has_neighborhood.hh
* source:trunk/milena/mln/neighb/
* source:trunk/milena/mln/trait/neighborhood.hh
Comment:
Generalize this ticket.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/133#comment:1>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.
1
0
cleanup-2008 2205: Add the sign value type (subset of the int value type).
by Nicolas Ballas 09 Sep '08
by Nicolas Ballas 09 Sep '08
09 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
Add the sign value type (subset of the int value type).
* tests/core/image/flat_image.cc: Update the test.
* tests/value/sign.cc: New test.
* tests/value/Makefile.am: Add the new test in the Makefile.
* mln/value/sign.hh: New sign value type.
* mln/value/super_value.hh: Update the super_value trait.
* mln/make/box2d.hh: Fix a conversion warning.
mln/make/box2d.hh | 4
mln/value/sign.hh | 229 +++++++++++++++++++++++++++++++++++++++++
mln/value/super_value.hh | 16 ++
tests/core/image/flat_image.cc | 9 +
tests/value/Makefile.am | 2
tests/value/sign.cc | 51 +++++++++
6 files changed, 302 insertions(+), 9 deletions(-)
Index: tests/core/image/flat_image.cc
--- tests/core/image/flat_image.cc (revision 2204)
+++ tests/core/image/flat_image.cc (working copy)
@@ -32,18 +32,21 @@
#include <mln/core/image/flat_image.hh>
#include <mln/core/alias/box2d.hh>
+#include <mln/value/sign.hh>
int main()
{
- {
using namespace mln;
+ {
flat_image<short, box2d> test;
-
std::cout << test.values_eligible() << std::endl;
std::cout << test.values_space() << std::endl;
- // flat_image<short, box2d>::t_eligible_value_set::fwd_viter viter(test.values_eligible());
+ }
+ {
+ flat_image<value::sign, box2d> test;
+ std::cout << test.values_eligible() << std::endl;
}
}
Index: tests/value/sign.cc
--- tests/value/sign.cc (revision 0)
+++ tests/value/sign.cc (revision 0)
@@ -0,0 +1,51 @@
+// 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.
+
+/*! \file tests/value/sign.cc
+ *
+ * \brief Tests on mln::value::sign.
+ */
+
+#include <cassert>
+#include <mln/value/sign.hh>
+
+
+int main()
+{
+ using namespace mln;
+ using value::sign;
+
+ {
+ sign s;
+ s = -1;
+ s = 0;
+ s = 1;
+ assert(sign::zero == 0);
+ assert(sign::one == 1);
+ assert(s != 3);
+ }
+}
Index: tests/value/Makefile.am
--- tests/value/Makefile.am (revision 2204)
+++ tests/value/Makefile.am (working copy)
@@ -27,6 +27,7 @@
rgb8 \
scalar \
set \
+ sign \
stack
# FIXME: Enable when make check_full works.
@@ -51,6 +52,7 @@
rgb8_SOURCES = rgb8.cc
scalar_SOURCES = scalar.cc
set_SOURCES = set.cc
+sign_SOURCES = sign.cc
stack_SOURCES = stack.cc
# FIXME: Enable when make check_full works.
Index: mln/value/sign.hh
--- mln/value/sign.hh (revision 0)
+++ mln/value/sign.hh (revision 0)
@@ -0,0 +1,229 @@
+// 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_VALUE_SIGN_HH
+# define MLN_VALUE_SIGN_HH
+
+/*! \file mln/value/sign.hh
+ *
+ * \brief Definition of the mln::value::sign class.
+ */
+
+# include <mln/value/internal/integer.hh>
+# include <mln/trait/value_.hh>
+# include <mln/literal/zero.hh>
+# include <mln/literal/one.hh>
+# include <mln/debug/format.hh>
+
+namespace mln
+{
+ namespace value
+ {
+
+
+ /*!
+ ** \brief The sign class represents the value type
+ ** composed by the set (-1, 0, 1)
+ ** sign value type is a subset of the int value type.
+ */
+ class sign : public internal::Integer<sign>
+ {
+ public:
+ /// FIXME is these typedefs correct?
+
+ /// Define the encoding type
+ typedef int enc;
+
+ /// Define the equivalent type
+ typedef int equiv;
+
+
+ /// Constructor without argument.
+ sign();
+
+ /// Constructor from an integer.
+ sign(int i);
+
+ /// \{ Constructors/assignments with literals.
+ sign(const mln::literal::zero_t&);
+ sign& operator=(const mln::literal::zero_t&);
+ sign(const mln::literal::one_t&);
+ sign& operator=(const mln::literal::one_t&);
+ /// \}
+
+ /// Conversion to an integer.
+ operator int() const;
+
+ /// Return the value associated to the sign object
+ int val_() const;
+
+ /// Assignment from an integer.
+ sign& operator=(int i);
+
+
+
+ /// Zero value.
+ static const sign zero;
+
+ /// Unit value.
+ static const sign one;
+
+ protected:
+
+ /// The value
+ int v_;
+ };
+
+ /*! \brief Print an signed integer \p i into the output stream \p ostr.
+ *
+ * \param[in,out] ostr An output stream.
+ * \param[in] i An sign value
+ *
+ * \return The modified output stream \p ostr.
+ */
+ std::ostream& operator<<(std::ostream& ostr, const sign& i);
+
+ /// Comparaison operator
+ bool operator==(sign lhs, sign rhs);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ inline
+ sign::sign()
+ {
+ }
+
+ inline
+ sign::operator int() const
+ {
+ return this->v_;
+ }
+
+ inline
+ int
+ sign::val_() const
+ {
+ return this->v_;
+ }
+
+ inline
+ sign::sign(int i)
+ {
+ mln_precondition(i >= -1);
+ mln_precondition(i <= 1);
+ this->v_ = i;
+ }
+
+ inline
+ sign&
+ sign::operator=(int i)
+ {
+ mln_precondition(i >= -1);
+ mln_precondition(i <= 1);
+ this->v_ = i;
+ return *this;
+ }
+
+ inline
+ sign::sign(const mln::literal::zero_t&)
+ {
+ this->v_ = 0;
+ }
+
+ inline
+ sign&
+ sign::operator=(const mln::literal::zero_t&)
+ {
+ this->v_ = 0;
+ return *this;
+ }
+
+ inline
+ sign::sign(const mln::literal::one_t&)
+ {
+ this->v_ = 1;
+ }
+
+ inline
+ sign&
+ sign::operator=(const mln::literal::one_t&)
+ {
+ this->v_ = 1;
+ return *this;
+ }
+
+ const sign sign::zero = 0;
+
+ const sign sign::one = 1;
+
+ inline
+ std::ostream& operator<<(std::ostream& ostr, const sign& i)
+ {
+ return ostr << debug::format(i.val_());
+ }
+
+ inline
+ bool operator==(sign lhs, sign rhs)
+ {
+ return lhs.val_() == rhs.val_();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace value
+
+
+ namespace trait
+ {
+
+ template <>
+ struct value_<mln::value::sign>
+ {
+
+ enum {
+ nbits = 2,
+ card = 3
+ };
+
+ typedef trait::value::nature::integer nature;
+ typedef trait::value::kind::gray kind;
+ typedef trait::value::quant::low quant;
+
+ static mln::value::sign min() { return -1; }
+ static mln::value::sign max() { return 1; }
+ static mln::value::sign epsilon() { return 0; }
+
+ typedef int sum;
+ };
+
+ } // end of namespace trait
+
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_SIGN_HH
Index: mln/value/super_value.hh
--- mln/value/super_value.hh (revision 2204)
+++ mln/value/super_value.hh (working copy)
@@ -33,6 +33,8 @@
* \brief Definition of the mln::super_value trait.
*/
+# include <mln/value/sign.hh>
+
namespace mln
{
@@ -49,11 +51,17 @@
typedef T ret;
};
- /// Specialization
- ///
+ /// Specializations:
+
+ /// Sign type is a subset of the short value type.
+ template <>
+ struct super_value<sign>
+ {
+ typedef int ret;
+ };
- }
+ } // end of namespace value
-}
+} // end of namespace mln
#endif // !MLN_VALUE_SUPER_VALUE_HH
Index: mln/make/box2d.hh
--- mln/make/box2d.hh (revision 2204)
+++ mln/make/box2d.hh (working copy)
@@ -79,8 +79,8 @@
{
mln_precondition(nrows != 0 && ncols != 0);
mln::box2d tmp(make::point2d(0, 0),
- make::point2d(nrows - 1,
- ncols - 1));
+ make::point2d(def::coord (nrows - 1),
+ def::coord (ncols - 1)));
return tmp;
}
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Update fun::rotation.
* mln/fun/x2x/rotation.hh: Code 3d rotation about a vector x.
rotation.hh | 50 +++++++++++++++++++++++++++++++++++---------------
1 file changed, 35 insertions(+), 15 deletions(-)
Index: mln/fun/x2x/rotation.hh
--- mln/fun/x2x/rotation.hh (revision 2203)
+++ mln/fun/x2x/rotation.hh (working copy)
@@ -66,7 +66,7 @@
/// Constructor without argument.
rotation();
/// Constructor with grade alpha and a facultative direction (rotation axis).
- rotation(float alpha, unsigned dir = 2);
+ rotation(float alpha, algebra::vec<n,float>& axis);
using super_::operator();
/// Perform the rotation of the given vector.
@@ -81,7 +81,7 @@
void update();
float alpha_;
- unsigned dir_;
+ algebra::vec <n,float> axis_;
};
@@ -95,9 +95,9 @@
template <unsigned n, typename C>
inline
- rotation<n,C>::rotation(float alpha, unsigned dir)
+ rotation<n,C>::rotation(float alpha, algebra::vec<n,float>& axis)
:alpha_(alpha),
- dir_(dir)
+ axis_(axis)
{
mln_precondition(dir == 2 || n == 3);
this->m_ = algebra::h_mat<n,C>::Id;
@@ -128,7 +128,7 @@
rotation<n,C>
rotation<n,C>::inv() const
{
- typename rotation::invert res(-alpha_, dir_);
+ typename rotation::invert res(-alpha_, axis_);
return res;
}
@@ -151,24 +151,44 @@
update();
}
+ // Homogenous matrix for a rotation of a point (x,y,z)
+ // about the vector (u,v,w) by the angle alpha
template <unsigned n, typename C>
inline
void
rotation<n,C>::update()
{
+ assert(n == 3); // debug
const float cos_a = cos(alpha_);
const float sin_a = sin(alpha_);
- const algebra::vec<4,float> vec = make::vec(cos_a, -sin_a, sin_a, cos_a);
+ const float u = axis_[0];
+ const float v = axis_[1];
+ const float w = axis_[2];
+ const float u2 = u * u;
+ const float v2 = v * v;
+ const float w2 = w * w;
+ const float uvw2 = u2 + v2 + w2;
+
+ this->m_(0,0) = (u2 + (v2 + w2) * cos_a) / uvw2;
+ this->m_(0,1) = (u*v * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(0,2) = (u*w * (1 - cos_a) + v * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(0,3) = 0;
+
+ this->m_(1,0) = (u*v * (1 - cos_a) + w * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(1,1) = (v2 + (u2 + w2) * cos_a) / uvw2;
+ this->m_(1,2) = (v*w * (1 - cos_a) - u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(1,3) = 0;
+
+ this->m_(2,0) = (u*w * (1 - cos_a) - v * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(2,1) = (v*w * (1 - cos_a) + u * math::sqrt(uvw2) * sin_a) / uvw2;
+ this->m_(2,1) = (u2 + (u2 + v2) * cos_a) / uvw2;
+ this->m_(2,3) = 0;
+
+ this->m_(2,0) = 0;
+ this->m_(2,1) = 0;
+ this->m_(2,1) = 0;
+ this->m_(2,3) = 1;
- unsigned k = 0;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < n; ++j)
- {
- if (j != this->dir_ && i != this->dir_)
- this->m_(i, j) = vec[k++];
- else
- this->m_(i, j) = (i == j);
- }
}
# endif // ! MLN_INCLUDE_ONLY
1
0
09 Sep '08
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Upgrade image1d + minor fixes ( _ removing ).
* mln/core/dpoints_piter.hh: Remove underscore to site_iterator_base_.
* mln/core/image/image1d.hh: Upgrade following image2d.
* mln/core/macros.hh: Temporarily uncomment mln_(d)point.
* mln/core/w_window.hh: Include dpoints_piter.hh.
* mln/core/line_piter.hh: Remove underscore to site_iterator_base_.
* mln/core/alias/dpoint1d.hh: Remove underscore to dpoint_.
* mln/core/alias/box1d.hh: Remove underscore to box_.
* mln/core/alias/point1d.hh: Cosmetic change.
alias/box1d.hh | 2 -
alias/dpoint1d.hh | 2 -
alias/point1d.hh | 2 -
dpoints_piter.hh | 4 +-
image/image1d.hh | 82 ++++++++++++++++++++++++++++++++----------------------
line_piter.hh | 4 +-
macros.hh | 20 ++++++-------
w_window.hh | 2 -
8 files changed, 67 insertions(+), 51 deletions(-)
Index: mln/core/dpoints_piter.hh
--- mln/core/dpoints_piter.hh (revision 2202)
+++ mln/core/dpoints_piter.hh (working copy)
@@ -48,7 +48,7 @@
* The parameter \c D is the type of delta-points.
*/
template <typename D>
- class dpoints_fwd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_fwd_piter<D> >
+ class dpoints_fwd_piter : public internal::site_iterator_base< mln_point(D), dpoints_fwd_piter<D> >
{
public:
@@ -106,7 +106,7 @@
* The parameter \c D is the type of delta-points.
*/
template <typename D>
- class dpoints_bkd_piter : public internal::site_iterator_base_< mln_point(D), dpoints_bkd_piter<D> >
+ class dpoints_bkd_piter : public internal::site_iterator_base< mln_point(D), dpoints_bkd_piter<D> >
{
public:
Index: mln/core/image/image1d.hh
--- mln/core/image/image1d.hh (revision 2202)
+++ mln/core/image/image1d.hh (working copy)
@@ -88,17 +88,25 @@
template <typename T>
struct image_< image1d<T> > : default_image_< T, image1d<T> >
{
+ // misc
typedef trait::image::category::primary category;
-
- typedef trait::image::access::random access;
- typedef trait::image::space::one_d space;
+ typedef trait::image::speed::fastest speed;
typedef trait::image::size::regular size;
- typedef trait::image::support::aligned support;
- typedef trait::image::border::stored border;
- typedef trait::image::data::raw data;
- typedef trait::image::io::read_write io;
- typedef trait::image::speed::fastest speed;
+ // value
+ typedef trait::image::value_access::direct value_access;
+ typedef trait::image::value_storage::one_block value_storage;
+ typedef trait::image::value_browsing::site_wise_only value_browsing;
+ typedef trait::image::value_io::read_write value_io;
+
+ // site / domain
+ typedef trait::image::localization::basic_grid localization;
+ typedef trait::image::dimension::one_d dimension;
+
+ // extended domain
+ typedef trait::image::ext_domain::extendable ext_domain;
+ typedef trait::image::ext_value::multiple ext_value;
+ typedef trait::image::ext_io::read_write ext_io;
};
} // end of namespace mln::trait
@@ -115,16 +123,10 @@
struct image1d :
public internal::image_primary< T, box1d, image1d<T> >
{
- // Warning: just to make effective types appear in Doxygen:
- typedef box1d pset;
- typedef point1d psite;
- typedef point1d point;
- typedef dpoint1d dpoint;
- typedef mln_fwd_piter(box1d) fwd_piter;
- typedef mln_bkd_piter(box1d) bkd_piter;
- typedef line_piter_<point> line_piter;
- // End of warning.
+ typedef internal::image_primary< T, mln::box1d, image1d<T> > super_;
+ /// Coordinate associated type.
+ typedef int coord;
/// Value associated type.
typedef T value;
@@ -161,6 +163,9 @@
/// Give the definition domain.
const box1d& domain() const;
+ /// Give the bounding box domain.
+ const box1d& bbox() const;
+
/// Give the border thickness.
unsigned border() const;
@@ -188,6 +193,9 @@
/// Fast Image method
+ // Give the index of a point.
+ using super_::index_of_point;
+
/// Give the offset corresponding to the delta-point \p dp.
int offset(const dpoint1d& dp) const;
@@ -201,7 +209,6 @@
T* buffer();
-
/// Resize image border with new_border.
void resize_(unsigned new_border);
@@ -351,7 +358,16 @@
image1d<T>::domain() const
{
mln_precondition(this->has_data());
- return this->data_->b_;
+ return this->data->b_;
+ }
+
+ template <typename T>
+ inline
+ const box1d&
+ image1d<T>::bbox() const
+ {
+ mln_precondition(this->has_data());
+ return this->data->b_;
}
template <typename T>
@@ -360,7 +376,7 @@
image1d<T>::border() const
{
mln_precondition(this->has_data());
- return this->data_->bdr_;
+ return this->data->bdr_;
}
template <typename T>
@@ -369,7 +385,7 @@
image1d<T>::ncells() const
{
mln_precondition(this->has_data());
- return this->data_->vb_.npoints();
+ return this->data->vb_.npoints();
}
template <typename T>
@@ -378,7 +394,7 @@
image1d<T>::has(const point1d& p) const
{
mln_precondition(this->has_data());
- return this->data_->vb_.has(p);
+ return this->data->vb_.has(p);
}
template <typename T>
@@ -387,7 +403,7 @@
image1d<T>::operator()(const point1d& p) const
{
mln_precondition(this->has(p));
- return this->data_->array_[p.ind()];
+ return this->data->array_[p.ind()];
}
template <typename T>
@@ -396,7 +412,7 @@
image1d<T>::operator()(const point1d& p)
{
mln_precondition(this->has(p));
- return this->data_->array_[p.ind()];
+ return this->data->array_[p.ind()];
}
template <typename T>
@@ -405,7 +421,7 @@
image1d<T>::operator[](unsigned o) const
{
mln_precondition(o < ncells());
- return *(this->data_->buffer_ + o);
+ return *(this->data->buffer_ + o);
}
template <typename T>
@@ -414,7 +430,7 @@
image1d<T>::operator[](unsigned o)
{
mln_precondition(o < ncells());
- return *(this->data_->buffer_ + o);
+ return *(this->data->buffer_ + o);
}
template <typename T>
@@ -423,7 +439,7 @@
image1d<T>::at(int ind) const
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data_->array_[ind];
+ return this->data->array_[ind];
}
template <typename T>
@@ -432,7 +448,7 @@
image1d<T>::at(int ind)
{
mln_precondition(this->has(make::point1d(ind)));
- return this->data_->array_[ind];
+ return this->data->array_[ind];
}
template <typename T>
@@ -441,7 +457,7 @@
image1d<T>::buffer() const
{
mln_precondition(this->has_data());
- return this->data_->buffer_;
+ return this->data->buffer_;
}
template <typename T>
@@ -450,7 +466,7 @@
image1d<T>::buffer()
{
mln_precondition(this->has_data());
- return this->data_->buffer_;
+ return this->data->buffer_;
}
template <typename T>
@@ -469,8 +485,8 @@
image1d<T>::point_at_offset(unsigned o) const
{
mln_precondition(o < ncells());
- point1d p = make::point1d(o + this->data_->vb_.min_ind());
- mln_postcondition(& this->operator()(p) == this->data_->buffer_ + o);
+ point1d p = make::point1d(o + this->data->vb_.min_ind());
+ mln_postcondition(& this->operator()(p) == this->data->buffer_ + o);
return p;
}
@@ -479,7 +495,7 @@
void
image1d<T>::resize_(unsigned new_border)
{
- this->data_->reallocate_(new_border);
+ this->data->reallocate_(new_border);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2202)
+++ mln/core/macros.hh (working copy)
@@ -104,11 +104,11 @@
# define mln_delta_(T) T::delta
/// \}
-// /// Shortcuts to access the dpoint type associated to T.
-// /// \{
-// # define mln_dpoint(T) typename T::dpoint
-// # define mln_dpoint_(T) T::dpoint
-// /// \}
+/// Shortcuts to access the dpoint type associated to T.
+/// \{
+# define mln_dpoint(T) typename T::dpoint
+# define mln_dpoint_(T) T::dpoint
+/// \}
/// Shortcuts to access the dpsite type associated to T.
/// \{
@@ -253,11 +253,11 @@
# define mln_psite_(T) T::psite
/// \}
-// /// Shortcuts to access the point type associated to T.
-// /// \{
-// # define mln_point(T) typename T::point
-// # define mln_point_(T) T::point
-// /// \}
+/// Shortcuts to access the point type associated to T.
+/// \{
+# define mln_point(T) typename T::point
+# define mln_point_(T) T::point
+/// \}
// q
Index: mln/core/w_window.hh
--- mln/core/w_window.hh (revision 2202)
+++ mln/core/w_window.hh (working copy)
@@ -37,7 +37,7 @@
# include <mln/core/window.hh>
# include <mln/core/concept/weighted_window.hh>
-
+# include <mln/core/dpoints_piter.hh>
namespace mln
{
Index: mln/core/line_piter.hh
--- mln/core/line_piter.hh (revision 2202)
+++ mln/core/line_piter.hh (working copy)
@@ -47,10 +47,10 @@
*/
template <typename P>
class line_piter_ :
- public internal::site_iterator_base_< P, line_piter_<P> >
+ public internal::site_iterator_base< P, line_piter_<P> >
{
typedef line_piter_<P> self_;
- typedef internal::site_iterator_base_< P, self_ > super_;
+ typedef internal::site_iterator_base< P, self_ > super_;
public:
// Make definitions from super class available.
Index: mln/core/alias/dpoint1d.hh
--- mln/core/alias/dpoint1d.hh (revision 2202)
+++ mln/core/alias/dpoint1d.hh (working copy)
@@ -44,7 +44,7 @@
/*! \brief Type alias for a delta-point defined on the 1D square
* grid with integer coordinates.
*/
- typedef dpoint_<mln::grid::tick, int> dpoint1d;
+ typedef dpoint<mln::grid::tick, int> dpoint1d;
} // end of namespace mln
Index: mln/core/alias/box1d.hh
--- mln/core/alias/box1d.hh (revision 2202)
+++ mln/core/alias/box1d.hh (working copy)
@@ -46,7 +46,7 @@
*
* \see mln::win::rectangle1d.
*/
- typedef box_<point1d> box1d;
+ typedef box<point1d> box1d;
} // end of namespace mln
Index: mln/core/alias/point1d.hh
--- mln/core/alias/point1d.hh (revision 2202)
+++ mln/core/alias/point1d.hh (working copy)
@@ -43,7 +43,7 @@
/*! \brief Type alias for a point defined on the 1D square grid with
* integer coordinates.
*/
- typedef point<mln::grid::tick, def::coord> point1d;
+ typedef point<grid::tick, def::coord> point1d;
} // end of namespace mln
1
0
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena/sandbox
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Sandbox: Sync access.hh/.cc with trunk.
* jardonnet/virtual/access.hh: Sync with trunk.
* jardonnet/virtual/access.cc: Sync with trunk.
access.cc | 4 +--
access.hh | 66 +++++++++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 48 insertions(+), 22 deletions(-)
Index: jardonnet/virtual/access.hh
--- jardonnet/virtual/access.hh (revision 2201)
+++ jardonnet/virtual/access.hh (working copy)
@@ -1,10 +1,12 @@
#ifndef _ACCESS_HH
# define _ACCESS_HH
-# include <mln/core/image1d.hh>
-# include <mln/core/image2d.hh>
+# include <mln/core/image/image1d.hh>
+# include <mln/core/image/image2d.hh>
# include <mln/metal/is.hh>
# include <mln/core/concept/function.hh>
+# include <mln/fun/internal/selector.hh>
+# include <mln/convert/to.hh>
namespace mln
{
@@ -14,37 +16,48 @@
template < typename I >
struct nearest_neighbor
- : public Function_x2x< nearest_neighbor<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), nearest_neighbor<I> >::ret
{
typedef mln_value(I) result;
- template < typename V >
+ nearest_neighbor(const I& ima) : ima(ima) {}
+
+ template < unsigned n, typename T >
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& x) const
{
- mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ mln_psite(I) p = convert::to<mln_psite(I)>(x);
return img(p);
}
+ const I& ima;
};
template < typename I >
struct linear
- : public Function_x2x< linear<I> >
+ : public fun::internal::selector_<const algebra::vec<1,float>,
+ // float is a dummy parameter (real is C)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
+ linear(const I& ima) : ima(ima) {}
+
template <typename C>
mln_value(I)
operator()(const I& img,
const algebra::vec<1,C>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// looking for img(x);
double x = v[0];
// p1
double xa = mln_point(I)::coord(v[0]);
- double ya = img(point1d(xa));
+ vsum ya = img(point1d(xa));
// x makes sens in img
if (x == xa)
@@ -52,23 +65,32 @@
// p2
double xb = mln_point(I)::coord(v[0] + 1);
- double yb = img(point1d(xb));
+ vsum yb = img(point1d(xb));
// Taylor-young
- return ya + (x - xa) * (yb - ya) / (xb - xa);
+ return convert::to<mln_value(I)>
+ (ya + (x - xa) * (yb - ya) / (xb - xa));
}
+
+ const I& ima;
};
template < typename I >
struct bilinear
- : public Function_x2x< bilinear<I> >
+ : public fun::internal::selector_<const algebra::vec<3,float>,
+ // 3,float is a dummy parameter (real is n,T)
+ mln_value(I), linear<I> >::ret
{
typedef mln_value(I) result;
- template <typename V>
+ bilinear(const I& ima) : ima(ima) {}
+
+ template <unsigned n, typename T>
mln_value(I)
- operator()(const I& img, const V& v) const
+ operator()(const I& img, const algebra::vec<n,T>& v) const
{
+ typedef mln_sum(mln_value(I)) vsum;
+
// q12----r2----q22
// | | |
// | x |
@@ -90,17 +112,20 @@
point2d q22 = point2d(x2, y2);
// linear interpolation #1
- mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ vsum img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
img(q21) * (x - x1) / (x2 - x1);
// linear interpolation #2
- mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ vsum img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
img(q22) * (x - x1) / (x2 - x1);
// interpolating in y direction
- return img_r1 * (y2 - y) / (y2 -y1)
- + img_r2 * (y - y1) /(y2 - y1);
+ return convert::to<mln_value(I)>
+ (img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1));
}
+
+ const I& ima;
};
}
@@ -109,11 +134,12 @@
template <typename I, typename T, typename F>
mln_value(I)
- access(const I& img, const mln_point(I)& p,
+ access(const I& img, const point2d& p,
const T& trans, const F& interp)
{
- mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
- mlc_is(F, Function_x2x<F>)::check();
+ mlc_is(typename T::invert,
+ Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function<F>)::check();
return interp(img, (trans.inv())(p));
}
Index: jardonnet/virtual/access.cc
--- jardonnet/virtual/access.cc (revision 2201)
+++ jardonnet/virtual/access.cc (working copy)
@@ -1,7 +1,7 @@
#include <iostream>
#include "access.hh"
-#include <mln/core/image2d.hh>
+#include <mln/core/image/image2d.hh>
#include <mln/fun/x2x/all.hh>
#include <mln/debug/iota.hh>
#include <mln/algebra/vec.hh>
@@ -13,7 +13,7 @@
point2d p(5,5);
algebra::vec<2,float> v = make::vec(3,4);
fun::x2x::translation<2,float> t(v);
- interpolation::nearest_neighbor< image2d<int> > nn;
+ interpolation::nearest_neighbor< image2d<int> > nn(img);
debug::iota(img);
1
0
Un dessin vaut mieux que mille mots. :-)
Tant qu'on dépend de Subversion, il faut qu'on essaie de maintenir ce
fichier. Il aurait été encore mieux d'aller renseigner les méta-
données SVN des différentes révisions (peut-être n'est-il d'ailleurs
pas trop tard, mais je n'en sais rien) pour en déduire ce schéma, mais
bon, le mieux est l'ennemi du bien.
Dans tous les cas, je pense qu'il faut qu'on se parle avant de décidé
d'un merge (dans un sens ou dans l'autre). Et une fois que branche
cleanup-2008 aura été complètement réintégrée dans trunk, je pense
qu'il faudra la détruire, puis utiliser des branches Git dans les
dépôt perso, qui offrent moins de risques.
Index: README.branches
===================================================================
--- README.branches (revision 2200)
+++ README.branches (revision 2201)
@@ -7,8 +7,40 @@
Should be merged back, then closed, as soon as all cleanup changes
have been applied.
** History
-Forked from the trunk (r1939) by revision 1940 on 2008-05-09.
+- Forked from the trunk (r1939) by revision 1940 on 2008-05-09.
+- Sync'd (merge) trunk (r1940:2162) into cleanup-2008 by revision 2163
+ on 2008-09-02.
+- Sync'd (merge) trunk (r2163:2188) into cleanup-2008 by revision 2189
+ on 2008-09-05.
+rev. branches
+
+ |
+1939 o.
+ | \
+1940 . `o create branches/cleanup-2008
+ . |
+ ... . .
+ | .
+2162 o. .
+ | \ |
+2163 . `o merge trunk (r1940:2162) -> branches/cleanup-2008
+ . |
+ ... . .
+ | .
+2188 o. .
+ | \ |
+2189 | `o merge trunk (r2163:2188) -> branches/cleanup-2008
+ | |
+ ... | |
+ | |
+ v |
+ trunk |
+ |
+ v
+ branches/cleanup-2008
+
+
* olena-ng
** Status: OPEN
** Object: Olena NG (Next Generation), based on the SCOOP 2 paradigm
1
0
Re: [Olena-patches] cleanup-2008 6fd64da: Merge last changes from trunk to cleanup
by Guillaume Lazzara 09 Sep '08
by Guillaume Lazzara 09 Sep '08
09 Sep '08
Roland Levillain wrote:
> Oh by the way, did you use a specific tool to format and send this patch
> to olena-patches (svn-wrapper maybe)?
>
Yes, I used svn-wrapper. It has git support.
--
Guillaume Lazzara
1
0
09 Sep '08
URL: https://svn.lrde.epita.fr/svn/oln
Git branch: cleanup (HEAD: 9517158)
ChangeLog:
2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
Merge last changes from trunk to cleanup.
* milena/ChangeLog: .
* milena/mln/fun/x2x/rotation.hh: .
* milena/mln/fun/x2x/translation.hh: .
* milena/mln/metal/all.hh: .
* milena/mln/metal/array.hh: New.
* milena/mln/metal/array1d.hh: New.
* milena/mln/metal/array2d.hh: New.
* milena/mln/metal/array3d.hh: New.
* milena/sandbox/ChangeLog: .
* milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
* milena/sandbox/jardonnet/array/Makefile: New.
* milena/sandbox/jardonnet/array/array.cc: .
* milena/sandbox/jardonnet/array/array.hh: .
* milena/sandbox/jardonnet/array/old/1d.hh: .
* milena/sandbox/jardonnet/registration/tools.hh: .
* milena/sandbox/jardonnet/test/icp.cc: .
* milena/sandbox/jardonnet/virtual/Makefile: New.
* milena/sandbox/jardonnet/virtual/access.cc: New.
* milena/sandbox/jardonnet/virtual/access.hh: New.
* milena/sandbox/nivault/plugin-gimp/autogen.sh: .
* milena/sandbox/nivault/plugin-gimp/configure.ac: .
* milena/sandbox/nivault/plugin-gimp/src/main.cc: .
---
ChangeLog | 26 ++
milena/ChangeLog | 18 ++
milena/mln/fun/x2x/rotation.hh | 2 +-
milena/mln/fun/x2x/translation.hh | 6 +-
milena/mln/metal/all.hh | 5 +
milena/mln/metal/array.hh | 117 +++++++++
milena/mln/metal/array1d.hh | 298 ++++++++++++++++++++++
milena/mln/metal/array2d.hh | 309 ++++++++++++++++++++++
milena/mln/metal/array3d.hh | 310 +++++++++++++++++++++++
milena/sandbox/ChangeLog | 41 +++
milena/sandbox/geraud/fllt/fllt.svg.7.hh | 96 ++++++-
milena/sandbox/jardonnet/array/Makefile | 2 +
milena/sandbox/jardonnet/array/array.cc | 12 +-
milena/sandbox/jardonnet/array/array.hh | 121 +++++++++-
milena/sandbox/jardonnet/array/old/1d.hh | 4 +-
milena/sandbox/jardonnet/registration/tools.hh | 54 +---
milena/sandbox/jardonnet/test/icp.cc | 1 +
milena/sandbox/jardonnet/virtual/Makefile | 2 +
milena/sandbox/jardonnet/virtual/access.cc | 36 +++
milena/sandbox/jardonnet/virtual/access.hh | 126 +++++++++
milena/sandbox/nivault/plugin-gimp/autogen.sh | 2 +-
milena/sandbox/nivault/plugin-gimp/configure.ac | 3 +-
milena/sandbox/nivault/plugin-gimp/src/main.cc | 2 +-
23 files changed, 1529 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 335521e..c39c773 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,29 @@
+2008-09-05 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Merge last changes from trunk to cleanup.
+ * milena/ChangeLog: .
+ * milena/mln/fun/x2x/rotation.hh: .
+ * milena/mln/fun/x2x/translation.hh: .
+ * milena/mln/metal/all.hh: .
+ * milena/mln/metal/array.hh: New.
+ * milena/mln/metal/array1d.hh: New.
+ * milena/mln/metal/array2d.hh: New.
+ * milena/mln/metal/array3d.hh: New.
+ * milena/sandbox/ChangeLog: .
+ * milena/sandbox/geraud/fllt/fllt.svg.7.hh: .
+ * milena/sandbox/jardonnet/array/Makefile: New.
+ * milena/sandbox/jardonnet/array/array.cc: .
+ * milena/sandbox/jardonnet/array/array.hh: .
+ * milena/sandbox/jardonnet/array/old/1d.hh: .
+ * milena/sandbox/jardonnet/registration/tools.hh: .
+ * milena/sandbox/jardonnet/test/icp.cc: .
+ * milena/sandbox/jardonnet/virtual/Makefile: New.
+ * milena/sandbox/jardonnet/virtual/access.cc: New.
+ * milena/sandbox/jardonnet/virtual/access.hh: New.
+ * milena/sandbox/nivault/plugin-gimp/autogen.sh: .
+ * milena/sandbox/nivault/plugin-gimp/configure.ac: .
+ * milena/sandbox/nivault/plugin-gimp/src/main.cc: .
+
2008-09-05 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment tutorial example for Z.
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 10983ef..479dea2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,21 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Minor fix : Translation Rotation.
+
+ * mln/fun/x2x/translation.hh,
+ * mln/fun/x2x/rotation.hh: Fix wrong namespaces.
+ * sandbox/jardonnet/virtual/access.hh: Fix concept check.
+
+2008-09-03 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Add metal::array (1d,2d,3d).
+
+ * mln/metal/all.hh: Update.
+ * mln/metal/array.hh: Generic.
+ * mln/metal/array1d.hh: Container 1d.
+ * mln/metal/array2d.hh: Container 2d.
+ * mln/metal/array3d.hh: Container 3d.
+
2008-09-04 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add a tutorial example for Z.
diff --git a/milena/mln/fun/x2x/rotation.hh b/milena/mln/fun/x2x/rotation.hh
index 3fb3ef5..af1a0ca 100644
--- a/milena/mln/fun/x2x/rotation.hh
+++ b/milena/mln/fun/x2x/rotation.hh
@@ -53,7 +53,7 @@ namespace mln
*/
template <unsigned n, typename C>
struct rotation
- : internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> >
, public Bijection_x2x< rotation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, rotation<n,C> > super_;
diff --git a/milena/mln/fun/x2x/translation.hh b/milena/mln/fun/x2x/translation.hh
index 86713bf..f2075e0 100644
--- a/milena/mln/fun/x2x/translation.hh
+++ b/milena/mln/fun/x2x/translation.hh
@@ -53,10 +53,8 @@ namespace mln
*/
template <unsigned n, typename C>
struct translation
-
- : internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
- ,
- public Bijection_x2x< translation<n,C> >
+ : fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> >
+ , public Bijection_x2x< translation<n,C> >
{
typedef fun::internal::x2x_linear_impl_< algebra::vec<n,C>, translation<n,C> > super_;
diff --git a/milena/mln/metal/all.hh b/milena/mln/metal/all.hh
index 511083f..e006e45 100644
--- a/milena/mln/metal/all.hh
+++ b/milena/mln/metal/all.hh
@@ -80,6 +80,11 @@ namespace mln
# include <mln/metal/math/all.hh>
+# include <mln/metal/array.hh>
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
# include <mln/metal/same_point.hh>
diff --git a/milena/mln/metal/array.hh b/milena/mln/metal/array.hh
new file mode 100644
index 0000000..1e2bb60
--- /dev/null
+++ b/milena/mln/metal/array.hh
@@ -0,0 +1,117 @@
+// 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_METAL_ARRAY_HH
+# define MLN_METAL_ARRAY_HH
+
+# include <mln/metal/array1d.hh>
+# include <mln/metal/array2d.hh>
+# include <mln/metal/array3d.hh>
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // a1
+
+ template<unsigned i, class T, unsigned n> inline
+ T get_at(const array1d<T, n>& arr)
+ {
+ return arr.template get_at_<i>();
+ }
+
+ template<unsigned i, class T, unsigned n> inline
+ T get(const array1d<T, n>& arr)
+ {
+ return arr.template get_<i>();
+ }
+
+ // a2
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get_at(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_at_<row, col>();
+ }
+
+ template<unsigned row, unsigned col, class T,
+ unsigned r, unsigned c> inline
+ T get(const array2d<T, r, c>& arr)
+ {
+ return arr.template get_<row, col>();
+ }
+
+ // a3
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_at(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_at_<sli, row, col>();
+ }
+
+ template<unsigned sli, unsigned row, unsigned col,
+ class T, unsigned s, unsigned r, unsigned c> inline
+ T get_(const array3d<T, s, r, c>& arr)
+ {
+ return arr.template get_<sli, row, col>();
+ }
+
+ // print
+
+ template<typename T, unsigned n>
+ std::ostream& operator<<(std::ostream& ostr, const array1d<T, n>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ ostr << rhs[i] << " ";
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ template<typename T, unsigned r, unsigned c>
+ std::ostream& operator<<(std::ostream& ostr, const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r; ++i)
+ {
+ for (unsigned j = 0; j < c; ++j)
+ ostr << rhs(i,j) << '\t';
+ ostr << '\n';
+ }
+ ostr << std::endl;
+
+ return ostr;
+ }
+
+ }
+
+}
+
+#endif /* MLN_METAL_ARRAY_HH */
diff --git a/milena/mln/metal/array1d.hh b/milena/mln/metal/array1d.hh
new file mode 100644
index 0000000..7f441d8
--- /dev/null
+++ b/milena/mln/metal/array1d.hh
@@ -0,0 +1,298 @@
+// 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_METAL_ARRAY1D_HH
+# define MLN_METAL_ARRAY1D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned Size>
+ struct array1d : public Object< array1d<T,Size> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array1d();
+ array1d(T* ptr);
+
+ // Copy
+
+ array1d(const array1d<T, Size>& rhs);
+ array1d<T, Size>& operator=(const array1d<T, Size>& rhs);
+
+ // Operators
+
+ template <class U>
+ array1d<T, Size> operator*(U w);
+
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ operator/(U w);
+
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ operator+(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>& operator+=(const array1d<T, Size>& rhs);
+
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ operator-(const array1d<U, Size>& rhs) const;
+ array1d<T, Size>&
+ operator-=(const array1d<T, Size>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return buffer_[i];
+ }
+ template<unsigned i>
+ T& get() {
+ return buffer_[i];
+ }
+
+ enum { length = Size };
+ protected:
+
+ T buffer_[Size];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d()
+ {
+ }
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(T* ptr)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned Size>
+ array1d<T,Size>::array1d(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<T, Size>
+ array1d<T,Size>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <class U>
+ array1d<mln_trait_op_div(T,U), Size>
+ array1d<T,Size>::operator/(U w)
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_plus(T,U), Size>
+ array1d<T,Size>::operator+(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator+=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned Size>
+ template <typename U>
+ array1d<mln_trait_op_minus(T,U), Size>
+ array1d<T,Size>::operator-(const array1d<U, Size>& rhs) const
+ {
+ array1d<T, Size> tmp;
+ for (unsigned i = 0; i < Size; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned Size>
+ array1d<T, Size>&
+ array1d<T,Size>::operator-=(const array1d<T, Size>& rhs)
+ {
+ for (unsigned i = 0; i < Size; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY1D_HH */
+
diff --git a/milena/mln/metal/array2d.hh b/milena/mln/metal/array2d.hh
new file mode 100644
index 0000000..4f3992a
--- /dev/null
+++ b/milena/mln/metal/array2d.hh
@@ -0,0 +1,309 @@
+// 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_METAL_ARRAY2D_HH
+# define MLN_METAL_ARRAY2D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned r, unsigned c> struct array2d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct value_< mln::metal::array2d<T, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = r * c * mln_nbits(T),
+ card = r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array2d<mln_sum(T),r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned r, unsigned c>
+ struct array2d : public Object< array2d<T, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array2d();
+ array2d(T* ptr);
+
+ // Copy
+
+ array2d(const array2d<T, r, c>& rhs);
+
+ array2d<T, r, c>& operator=(const array2d<T, r, c>& rhs);
+
+ // Operators
+
+ template <class U>
+ array2d<T, r, c> operator*(U w);
+
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ operator/(U w);
+
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ operator+(const array2d<U, r, c>& rhs) const;
+ array2d<T, r, c>& operator+=(const array2d<T, r, c>& rhs);
+
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ operator-(const array2d<U, r, c>& rhs) const;
+ array2d<T, r, c>&
+ operator-=(const array2d<T, r, c>& rhs);
+
+ // dynamic accessors:
+
+ T operator()(unsigned row, unsigned col) const {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+ T& operator()(unsigned row, unsigned col) {
+ mln_precondition(row < r * c);
+ return buffer_[col * r + row];
+ }
+
+ // static accessor
+
+ template<unsigned row, unsigned col>
+ T get() const {
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get() {
+ return buffer_[col * r + row];
+ }
+
+ template<unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+ template<unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(col * r + row < r *c);
+ return buffer_[col * r + row];
+ }
+
+ enum { length = r * c };
+ protected:
+
+ T buffer_[r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array2d<T, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array2d<T, r, c>, metal::array2d<U, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array2d<T, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<V, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array2d<T, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array2d<T, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d()
+ {
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(T* ptr)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>::array2d(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<T, r, c>
+ array2d<T, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <class U>
+ array2d<mln_trait_op_div(T,U), r, c>
+ array2d<T,r, c>::operator/(U w)
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_plus(T,U), r, c>
+ array2d<T,r, c>::operator+(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator+=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned r, unsigned c>
+ template <typename U>
+ array2d<mln_trait_op_minus(T,U), r, c>
+ array2d<T,r, c>::operator-(const array2d<U, r, c>& rhs) const
+ {
+ array2d<T, r, c> tmp;
+ for (unsigned i = 0; i < r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned r, unsigned c>
+ array2d<T, r, c>&
+ array2d<T, r, c>::operator-=(const array2d<T, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY2D_HH */
+
diff --git a/milena/mln/metal/array3d.hh b/milena/mln/metal/array3d.hh
new file mode 100644
index 0000000..574d2a6
--- /dev/null
+++ b/milena/mln/metal/array3d.hh
@@ -0,0 +1,310 @@
+// 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_METAL_ARRAY3D_HH
+# define MLN_METAL_ARRAY3D_HH
+
+# include <mln/core/concept/object.hh>
+
+# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned s, unsigned r, unsigned c> struct array3d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct value_< mln::metal::array3d<T,s, r, c> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = s * r * c * mln_nbits(T),
+ card = s * r * c * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array3d<mln_sum(T), s, r, c> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ struct array3d : public Object< array3d<T, s, r, c> >
+ {
+
+ //
+ // Constructors
+ //
+
+ array3d();
+ array3d(T* ptr);
+
+ // Copy
+
+ array3d(const array3d<T, s, r, c>& rhs);
+ array3d<T, s, r, c>& operator=(const array3d<T, s, r, c>& rhs);
+
+ // Operators
+
+ template <class U>
+ array3d<T, s, r, c> operator*(U w);
+
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ operator/(U w);
+
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ operator+(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>& operator+=(const array3d<T, s, r, c>& rhs);
+
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ operator-(const array3d<U, s, r, c>& rhs) const;
+ array3d<T, s, r, c>&
+ operator-=(const array3d<T, s, r, c>& rhs);
+
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i) {
+ mln_precondition(i < s * r * c);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get() const {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get() {
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+
+ template <unsigned sli, unsigned row, unsigned col>
+ T get_at() const {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+ template <unsigned sli, unsigned row, unsigned col>
+ T& get_at() {
+ mln_precondition(sli * (row * col) + col * r + row < s * r * c );
+ return buffer_[sli * (row * col) + col * r + row];
+ }
+
+ enum { length = s * r * c };
+ protected:
+
+ T buffer_[s * r * c];
+ };
+
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T >
+ struct set_precise_unary_< Name, metal::array3d<T, s, r, c> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < unsigned s, unsigned r, unsigned c, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array3d<T, s, r, c>, metal::array3d<U, s, r, c> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array3d<T, s, r, c>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<V, s, r, c> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned s, unsigned r, unsigned c, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array3d<T, s, r, c>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array3d<T, s, r, c> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
+ //
+ // Constructors
+ //
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d()
+ {
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(T* ptr)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = *ptr++;
+ }
+
+ // Copy
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T,s, r, c>::array3d(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ buffer_[i] = rhs[i];
+ return *this;
+ }
+
+ // Operators
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<T, s, r, c>
+ array3d<T,s, r, c>::operator*(U w)
+ {
+ //fixme mln_trait_op_mult<int,U>
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] * w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <class U>
+ array3d<mln_trait_op_div(T,U), s, r, c>
+ array3d<T,s, r, c>::operator/(U w)
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] / w;
+ return tmp;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_plus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator+(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] + rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator+=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] += rhs.buffer_[i];
+ return *this;
+ }
+
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ template <typename U>
+ array3d<mln_trait_op_minus(T,U), s, r, c>
+ array3d<T,s, r, c>::operator-(const array3d<U, s, r, c>& rhs) const
+ {
+ array3d<T, s, r, c> tmp;
+ for (unsigned i = 0; i < s * r * c; ++i)
+ tmp[i] = this->buffer_[i] - rhs.buffer_[i];
+ return tmp;
+ }
+ template <typename T, unsigned s, unsigned r, unsigned c>
+ array3d<T, s, r, c>&
+ array3d<T,s, r, c>::operator-=(const array3d<T, s, r, c>& rhs)
+ {
+ for (unsigned i = 0; i < s * r * c; ++i)
+ this->buffer_[i] -= rhs.buffer_[i];
+ return *this;
+ }
+
+ } // end of namespace metal
+
+} // end of namespace mln
+
+#endif /* MLN_METAL_ARRAY3D_HH */
+
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 64366fc..9043427 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -1,3 +1,44 @@
+2008-09-05 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: virtual transform, Add concept check.
+
+ * jardonnet/virtual/access.hh: Add concept check.
+ * jardonnet/virtual/access.cc: Update in consequence.
+
+2008-09-05 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ Fixes to install the gimp plugin.
+ * nivault/plugin-gimp/autogen.sh: s/main.c/main.cc
+ * nivault/plugin-gimp/configure.ac: move install dir to home to
+ install it without administrator rights (dirty)
+ * nivault/plugin-gimp/src/main.cc: Change place in the gimp menu.
+
+2008-09-04 Ugo Jardonnet <jardonnet(a)lrde.epita.fr>
+
+ Start working on image virtual transformation.
+
+ * jardonnet/virtual: New.
+ * jardonnet/virtual/access.hh (access): Virtual access to image.
+ It also contains image interpolation routines.
+ * jardonnet/virtual/access.cc: Test file.
+ * jardonnet/virtual/Makefile: New.
+
+2008-09-02 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
+
+ * geraud/fllt/fllt.svg.7.hh: Add comments to the working version of
+ FLLT.
+
+2008-09-01 Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
+
+ Sandbox: Update metal::array.
+
+ * jardonnet/array/array.cc: Update Test.
+ * jardonnet/array/array.hh: Add stc/dyn getters.
+ * jardonnet/array/Makefile: New.
+
+ * jardonnet/test/icp.cc: .
+ * jardonnet/registration/tools.hh: .
+
2008-06-19 Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add kruskal algorithm in a sample morphological chain.
diff --git a/milena/sandbox/geraud/fllt/fllt.svg.7.hh b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
index c2a2df3..105e4e6 100644
--- a/milena/sandbox/geraud/fllt/fllt.svg.7.hh
+++ b/milena/sandbox/geraud/fllt/fllt.svg.7.hh
@@ -331,9 +331,6 @@ namespace mln
++label;
- // if (holes.size() == 2)
- // std::cout << holes[0] << holes[1] << std::endl;
- // std::cout << " <<<<<<<exiting blob." << std::endl;
}
template <typename P, typename V>
@@ -393,7 +390,8 @@ namespace mln
}
}
- // LOWER LEVEL SET : region = c4, border = c8
+ // LOWER LEVEL SET information to compute the max tree.
+ // -> region = c4, border = c8
template <typename V>
struct lower
{
@@ -421,7 +419,8 @@ namespace mln
};
- // UPPER LEVEL SET : region = c8, border = c4
+ // UPPER LEVEL SET information to compute the max tree.
+ // -> region = c8, border = c4
template <typename V>
struct upper
{
@@ -445,6 +444,14 @@ namespace mln
static const neighb2d& reg_nbh() { return c8(); }
};
+ /*! Fast computation of a min/max tree.
+ *
+ * \param[in] input_ An input image.
+ * \param[out] smallest_shapes We stock in this image, for each point, a pointer
+ * to the smallest shape containing it.
+ * \return The min/max tree built.
+ *
+ */
template <typename I, typename Set>
fllt_tree(mln_point(I), mln_value(I))&
level_set(const Image<I>& input_,
@@ -560,7 +567,7 @@ namespace mln
deja_vu(x) = in_N;
}
}
- // gN = min u(x) for all x in N
+ // gN <- min u(x) for all x in N
update_gN(N, gN, Set());
// FIXME: update the number of CC of the border of R
@@ -609,7 +616,6 @@ namespace mln
// c)
else
{
- // FIXME: IDEA: this change might be performed while R is constructed(?)
n_step_4c++;
mln_piter(I) r(N_box);
for_all(r)
@@ -627,6 +633,15 @@ namespace mln
return *new tree_type(current_cc);
}
+ /*! Get the hole of a shape which contains a given point.
+ *
+ * \param[in] node a shape.
+ * \param[in] p a point.
+ * \param[in] other_reg The map which associate a point with its smallest shape
+ * of the oposite tree.
+ * \return true if A is included in B.
+ *
+ */
// F is the set in which we get the node.
template <typename P, typename V, typename F>
fllt_node(P, V)*
@@ -636,6 +651,7 @@ namespace mln
{
fllt_node(P, V)* s = other_reg(p);
mln_assertion(s);
+ // Go up the tree.
while (s->parent() && F::compare(s->parent()->elt().value, node.elt().value))
{
mln_assertion(s);
@@ -649,6 +665,14 @@ namespace mln
return s;
}
+ /*! Test the inclusion of two shapes of the same tree
+ *
+ * \param[in] A a shape.
+ * \param[in] B a shape.
+ * \return true if A is included in B.
+ *
+ * \pre The shapes have to come from the same tree.
+ */
template <typename P, typename V>
bool shape_is_included(fllt_node(P, V)* A,
fllt_node(P, V)* B)
@@ -656,6 +680,17 @@ namespace mln
return A->parent() == B || A == B;
}
+ /*! Associated the points of the holes of the min/max tree's shapes.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename P, typename V>
void find_all_holes(fllt_tree(P, V)& lower_tree,
fllt_tree(P, V)& upper_tree,
@@ -665,6 +700,7 @@ namespace mln
typedef p_array<P> arr_t;
typedef fllt_node(P, V) node_type;
+ // Get the holes of the min tree
{
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
for_all(node_)
@@ -676,6 +712,7 @@ namespace mln
}
}
+ // Get the holes of the max tree
{
fllt_branch_iter_ind(P, V) node_(upper_tree.main_branch());
for_all(node_)
@@ -688,6 +725,17 @@ namespace mln
}
}
+ /*! Merge the Min and the max tree.
+ *
+ * \param[in] lower_tree The min tree.
+ * \param[in] upper_tree The max tree.
+ * \param[in] low_reg The map which associate a point with its smallest shape
+ * of the min tree.
+ * \param[in] upp_reg The map which associate a point with its smallest shape
+ * of the max tree.
+ * \return The merged tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
merge_trees(fllt_tree(mln_point(I), mln_value(I))& lower_tree,
@@ -706,17 +754,24 @@ namespace mln
typedef p_array<P> arr_t;
+ // Here, a hole of a shape of the max or min tree is represented
+ // by a point belonging to this hole. We need to associate each of
+ // these points with its shape in the oposite tree.
find_all_holes(lower_tree, upper_tree, low_reg, upp_reg);
std::vector<node_type*> to_fill;
fllt_branch_iter_ind(P, V) node_(lower_tree.main_branch());
+ // Browse the shapes of the min_tree, in order to put as child of
+ // min tree's shapes the shapes of the max tree corresponding to
+ // their holes.
for_all(node_)
{
node_type& node = *node_;
+ // If the node was not in the min tree at the begining, we ignore it.
if (node.elt().set_id != lower<V>::id)
continue;
- // std::cout << "Fill " << &node << std::endl;
+ // Browse the holes of the shape.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -724,6 +779,7 @@ namespace mln
{
fllt_node(P, V)* hole = *hole_;
+ // Check if hole_ is contained by a hole of the children of node.
bool child_has_bigger_hole = false;
typename fllt_node(P, V)::children_t::iterator it;
for (it = node.children().begin(); it != node.children().end() && !child_has_bigger_hole; it++)
@@ -735,8 +791,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- // std::cout << "hole : " << hole << " " << hole->elt().points << " " << std::endl;
- // std::cout << "child hole : " << child_hole << " " << child_hole->elt().points << std::endl;
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -744,6 +798,9 @@ namespace mln
}
} // end of browsing child's holes.
} // end of browsing childs.
+
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
{
// // std::cout << "move " << hole << " as child of " << &node << std::endl;
@@ -754,6 +811,12 @@ namespace mln
node.elt().holes.clear();
} // end of browsing lower_tree.
+ // At this step, we have filled all the holes of the min
+ // tree. But, by filling these holes, we introduced somes holes of
+ // the max tree in the result tree. We need to fill them.
+
+ // Thus, we browse the shapes of the max tree previously merged in
+ // the min tree, in order to check their holes.
for(typename std::vector<node_type*>::iterator node_ = to_fill.begin();
node_ != to_fill.end();
node_++)
@@ -767,6 +830,7 @@ namespace mln
if (node.elt().set_id != upper<V>::id)
continue;
+ // Check if hole_ is contained by a hole of the children of node.
typename std::vector<fllt_node(P, V)*>::iterator hole_;
for (hole_ = node.elt().hole_shapes.begin();
hole_ != node.elt().hole_shapes.end();
@@ -785,7 +849,6 @@ namespace mln
child_hole_++)
{
fllt_node(P, V)* child_hole = *child_hole_;
- //if (hole->elt().points <= child_hole->elt().points)
if (shape_is_included(hole, child_hole))
{
child_has_bigger_hole = true;
@@ -794,6 +857,8 @@ namespace mln
} // end of browsing child's holes.
} // end of browsing childs.
+ // If no, move the shape of the max tree previously associated to this hole.
+ // as child of node.
if (!child_has_bigger_hole)
node.add_child(hole);
@@ -806,6 +871,12 @@ namespace mln
return lower_tree;
}
+ /*! This function compute the fllt tree of an image.
+ *
+ * \param[in] input_ An input image.
+ * \return The computed tree.
+ *
+ */
template <typename I>
fllt_tree(mln_point(I), mln_value(I))
fllt(const Image<I>& input_)
@@ -820,12 +891,15 @@ namespace mln
image2d<fllt_node(P, V)*> low_reg(input.domain());
image2d<fllt_node(P, V)*> upp_reg(input.domain());
+ // Compute the Min tree.
std::cout << "1/ Compute the lower level set.----------------------------------------" << std::endl;
lower_tree = level_set<I, lower<V> >(input, low_reg);
+ // Compute the Max tree.
std::cout << "2/ Compute the upper level set.----------------------------------------" << std::endl;
upper_tree = level_set<I, upper<V> >(input, upp_reg);
+ // Merge the two trees.
std::cout << "3/ Merge.---------------------------------------------------------------" << std::endl;
fllt_tree(P, V) result_tree = merge_trees(lower_tree, upper_tree, low_reg, upp_reg, input);
diff --git a/milena/sandbox/jardonnet/array/Makefile b/milena/sandbox/jardonnet/array/Makefile
new file mode 100644
index 0000000..07c5494
--- /dev/null
+++ b/milena/sandbox/jardonnet/array/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ array.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/array/array.cc b/milena/sandbox/jardonnet/array/array.cc
index 1eb1447..d01897a 100644
--- a/milena/sandbox/jardonnet/array/array.cc
+++ b/milena/sandbox/jardonnet/array/array.cc
@@ -1,6 +1,6 @@
#include <iostream>
-#include <mln/metal/array.hh>
+#include "array.hh"
int main(int, char **)
{
@@ -9,4 +9,14 @@ int main(int, char **)
mln::metal::array1d<int, 5> c;
c = a + b;
+
+ a.get<0>() = 0;
+ a.get<1>() = 1;
+ a.get<2>() = 2;
+ a.get<3>() = 3;
+
+ for (int i = 0 ; i < a.length; i++)
+ std::cout << a[i] << " ";
+
+ std::cout << std::endl;
}
diff --git a/milena/sandbox/jardonnet/array/array.hh b/milena/sandbox/jardonnet/array/array.hh
index 57b798d..0934856 100644
--- a/milena/sandbox/jardonnet/array/array.hh
+++ b/milena/sandbox/jardonnet/array/array.hh
@@ -28,16 +28,47 @@
#ifndef MLN_METAL_ARRAY1D_HH
# define MLN_METAL_ARRAY1D_HH
+# include <mln/core/concept/object.hh>
+
# include <mln/trait/all.hh>
+# include <mln/trait/value_.hh>
+
+# include <mln/value/ops.hh>
namespace mln
{
+ // Fwd decls.
+ namespace metal {
+ template <typename T, unsigned Size> struct array1d;
+ }
+
+ namespace trait
+ {
+
+ template <typename T, unsigned Size>
+ struct value_< mln::metal::array1d<T,Size> >
+ {
+ typedef trait::value::nature::vectorial nature;
+ typedef trait::value::kind::data kind;
+
+ enum {
+ nbits = Size * mln_nbits(T),
+ card = Size * mln_card(T)
+ };
+ typedef mln_value_quant_from_(card) quant;
+
+ typedef metal::array1d<mln_sum(T),Size> sum;
+ };
+
+ } // end of namespace mln::trait
+
+
namespace metal
{
template <typename T, unsigned Size>
- struct array1d
+ struct array1d : public Object< array1d<T,Size> >
{
//
@@ -72,11 +103,99 @@ namespace mln
array1d<T, Size>&
operator-=(const array1d<T, Size>& rhs);
+
+ // dynamic accessors:
+
+ T operator[](unsigned i) const
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+ T& operator[](unsigned i)
+ {
+ mln_precondition(i < Size);
+ return buffer_[i];
+ }
+
+ // static accessor
+
+ template<unsigned i>
+ T get() const {
+ return *(buffer_ + i);
+ }
+ template<unsigned i>
+ T& get() {
+ return *(buffer_ + i);
+ }
+
+ enum { length = Size };
protected:
T buffer_[Size];
};
+ }
+
+ namespace trait
+ {
+
+ // For unary traits.
+
+ template < template <class> class Name,
+ unsigned n, typename T >
+ struct set_precise_unary_< Name, metal::array1d<T, n> >
+ {
+ typedef mln_trait_unary(Name, T) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ // For binary traits.
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_trait_binary(Name, T, U) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < unsigned n, typename T,
+ typename U >
+ struct set_precise_binary_< op::times,
+ metal::array1d<T, n>, metal::array1d<U, n> >
+ {
+ typedef mln_sum_x(T,U) ret;
+ };
+
+ template < template <class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_precise_binary_< Name,
+ metal::array1d<T, n>, mln::value::scalar_<S> >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<V, n> ret;
+ };
+
+ template < template<class, class> class Name,
+ unsigned n, typename T,
+ typename S >
+ struct set_binary_< Name,
+ mln::Object, metal::array1d<T, n>,
+ mln::value::Scalar, S >
+ {
+ typedef mln_trait_binary(Name, T, S) V;
+ typedef metal::array1d<T, n> ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace metal
+ {
+
//
// Constructors
//
diff --git a/milena/sandbox/jardonnet/array/old/1d.hh b/milena/sandbox/jardonnet/array/old/1d.hh
index c161e79..0da9f1a 100644
--- a/milena/sandbox/jardonnet/array/old/1d.hh
+++ b/milena/sandbox/jardonnet/array/old/1d.hh
@@ -236,9 +236,7 @@ namespace mlc
template<int i>
T get_() const {
- lesseq<-Info_::center, i>::ensure();
- lesseq<i, Info_::card - Info_::center - 1>::ensure();
- return *(buffer_ + Info_::center + i);
+ return *(buffer_ + i);
}
protected:
diff --git a/milena/sandbox/jardonnet/registration/tools.hh b/milena/sandbox/jardonnet/registration/tools.hh
index 99ee7de..624af17 100644
--- a/milena/sandbox/jardonnet/registration/tools.hh
+++ b/milena/sandbox/jardonnet/registration/tools.hh
@@ -193,23 +193,23 @@ namespace mln
namespace convert
{
- // to_p_array
- template <typename I>
- inline
- p_array<mln_psite(I)>
- to_p_array(const Image<I>& img_)
- {
- const I& img = exact(img_);
+// // to_p_array
+// template <typename I>
+// inline
+// p_array<mln_psite(I)>
+// to_p_array(const Image<I>& img_)
+// {
+// const I& img = exact(img_);
- p_array<mln_psite(I)> a;
+// p_array<mln_psite(I)> a;
- mln_piter(I) p(img.domain());
- for_all(p)
- if (img(p))
- a.append(p);
+// mln_piter(I) p(img.domain());
+// for_all(p)
+// if (img(p))
+// a.append(p);
- return a;
- }
+// return a;
+// }
template < typename P >
@@ -316,32 +316,6 @@ namespace mln
} // end of namespace convert
- namespace algebra
- {
-
- // transpose
- template<unsigned n, unsigned m, typename T>
- mat<m,n,T>
- trans(const mat<n,m,T>& matrice)
- {
- mat<m,n,T> tmp;
- for (unsigned i = 0; i < n; ++i)
- for (unsigned j = 0; j < m; ++j)
- tmp(j,i) = matrice(i,j);
- return tmp;
- }
-
- // trace
- template<unsigned n, typename T> inline
- float tr(const mat<n,n,T>& m)
- {
- float f = 0.f;
- for (unsigned i = 0; i < n; ++i)
- f += m(i,i);
- return f;
- }
-
- } // end of namespace algebra
} // end of namespace mln
diff --git a/milena/sandbox/jardonnet/test/icp.cc b/milena/sandbox/jardonnet/test/icp.cc
index bf7eebc..70b4f88 100644
--- a/milena/sandbox/jardonnet/test/icp.cc
+++ b/milena/sandbox/jardonnet/test/icp.cc
@@ -3,6 +3,7 @@
#include <mln/io/pbm/load.hh>
#include <mln/io/pbm/save.hh>
#include <mln/io/ppm/save.hh>
+#include <mln/convert/to_p_array.hh>
#include <mln/norm/l2.hh>
#include <sandbox/jardonnet/registration/icp.hh>
diff --git a/milena/sandbox/jardonnet/virtual/Makefile b/milena/sandbox/jardonnet/virtual/Makefile
new file mode 100644
index 0000000..f2fd44f
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/Makefile
@@ -0,0 +1,2 @@
+all:
+ g++ access.cc -I../../..
\ No newline at end of file
diff --git a/milena/sandbox/jardonnet/virtual/access.cc b/milena/sandbox/jardonnet/virtual/access.cc
new file mode 100644
index 0000000..620ab74
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.cc
@@ -0,0 +1,36 @@
+
+#include <iostream>
+#include "access.hh"
+#include <mln/core/image2d.hh>
+#include <mln/fun/x2x/all.hh>
+#include <mln/debug/iota.hh>
+#include <mln/algebra/vec.hh>
+
+int main()
+{
+ using namespace mln;
+ image2d<int> img(50,50);
+ point2d p(5,5);
+ algebra::vec<2,float> v = make::vec(3,4);
+ fun::x2x::translation<2,float> t(v);
+ interpolation::nearest_neighbor< image2d<int> > nn;
+
+ debug::iota(img);
+
+ for (int i = 0; i < 50; i++)
+ {
+ for (int j = 0; j < 50; j++)
+ std::cout << img(point2d(i,j));
+ std::cout << std::endl;
+ }
+
+ std::cout << std::endl;
+
+ for (int i = 3; i < 53; i++)
+ {
+ for (int j = 4; j < 54; j++)
+ std::cout <<
+ mln::access::access(img, point2d(i,j), t, nn);
+ std::cout << std::endl;
+ }
+}
diff --git a/milena/sandbox/jardonnet/virtual/access.hh b/milena/sandbox/jardonnet/virtual/access.hh
new file mode 100644
index 0000000..d5684e7
--- /dev/null
+++ b/milena/sandbox/jardonnet/virtual/access.hh
@@ -0,0 +1,126 @@
+#ifndef _ACCESS_HH
+# define _ACCESS_HH
+
+# include <mln/core/image1d.hh>
+# include <mln/core/image2d.hh>
+# include <mln/metal/is.hh>
+# include <mln/core/concept/function.hh>
+
+namespace mln
+{
+
+ namespace interpolation
+ {
+
+ template < typename I >
+ struct nearest_neighbor
+ : public Function_x2x< nearest_neighbor<I> >
+ {
+ typedef mln_value(I) result;
+
+ template < typename V >
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ mln_point(I) p = algebra::to_point<mln_point(I)>(v);
+ return img(p);
+ }
+
+ };
+
+ template < typename I >
+ struct linear
+ : public Function_x2x< linear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename C>
+ mln_value(I)
+ operator()(const I& img,
+ const algebra::vec<1,C>& v) const
+ {
+ // looking for img(x);
+ double x = v[0];
+
+ // p1
+ double xa = mln_point(I)::coord(v[0]);
+ double ya = img(point1d(xa));
+
+ // x makes sens in img
+ if (x == xa)
+ return img(xa);
+
+ // p2
+ double xb = mln_point(I)::coord(v[0] + 1);
+ double yb = img(point1d(xb));
+
+ // Taylor-young
+ return ya + (x - xa) * (yb - ya) / (xb - xa);
+ }
+ };
+
+ template < typename I >
+ struct bilinear
+ : public Function_x2x< bilinear<I> >
+ {
+ typedef mln_value(I) result;
+
+ template <typename V>
+ mln_value(I)
+ operator()(const I& img, const V& v) const
+ {
+ // q12----r2----q22
+ // | | |
+ // | x |
+ // | | |
+ // q11----r1----q21
+
+ // looking for img(P(x,y))
+ double x = v[0];
+ double y = v[1];
+
+ double x1 = mln_point(I)::coord(v[0]);
+ double x2 = mln_point(I)::coord(v[0]+ 1);
+ double y1 = mln_point(I)::coord(v[1]);
+ double y2 = mln_point(I)::coord(v[1]+ 1);
+
+ point2d q11 = point2d(x1, y1);
+ point2d q12 = point2d(x1, y2);
+ point2d q21 = point2d(x2, y1);
+ point2d q22 = point2d(x2, y2);
+
+ // linear interpolation #1
+ mln_value(I) img_r1 = img(q11) * (x2 - x) / (x2 - x1) +
+ img(q21) * (x - x1) / (x2 - x1);
+
+ // linear interpolation #2
+ mln_value(I) img_r2 = img(q12) * (x2 - x) / (x2 - x1) +
+ img(q22) * (x - x1) / (x2 - x1);
+
+ // interpolating in y direction
+ return img_r1 * (y2 - y) / (y2 -y1)
+ + img_r2 * (y - y1) /(y2 - y1);
+ }
+ };
+ }
+
+ namespace access
+ {
+
+ template <typename I, typename T, typename F>
+ mln_value(I)
+ access(const I& img, const mln_point(I)& p,
+ const T& trans, const F& interp)
+ {
+ mlc_is(typename T::invert, Bijection_x2x<typename T::invert>)::check();
+ mlc_is(F, Function_x2x<F>)::check();
+
+ return interp(img, (trans.inv())(p));
+ }
+
+ }
+
+}
+
+#endif /* _ACCESS_HH */
+
diff --git a/milena/sandbox/nivault/plugin-gimp/autogen.sh b/milena/sandbox/nivault/plugin-gimp/autogen.sh
index 67c0744..2a28f72 100755
--- a/milena/sandbox/nivault/plugin-gimp/autogen.sh
+++ b/milena/sandbox/nivault/plugin-gimp/autogen.sh
@@ -10,7 +10,7 @@
PROJECT="GIMP Plug-In Template"
TEST_TYPE=-f
-FILE=src/main.c
+FILE=src/main.cc
AUTOCONF_REQUIRED_VERSION=2.54
AUTOMAKE_REQUIRED_VERSION=1.6
diff --git a/milena/sandbox/nivault/plugin-gimp/configure.ac b/milena/sandbox/nivault/plugin-gimp/configure.ac
index a91ecdf..85a24d2 100644
--- a/milena/sandbox/nivault/plugin-gimp/configure.ac
+++ b/milena/sandbox/nivault/plugin-gimp/configure.ac
@@ -59,7 +59,8 @@ PKG_CHECK_MODULES(GIMP,
AC_SUBST(GIMP_CFLAGS)
AC_SUBST(GIMP_LIBS)
-GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+#GIMP_LIBDIR=`$PKG_CONFIG --variable=gimplibdir gimp-2.0`
+GIMP_LIBDIR=`echo ~/.gimp-2.4`
AC_SUBST(GIMP_LIBDIR)
diff --git a/milena/sandbox/nivault/plugin-gimp/src/main.cc b/milena/sandbox/nivault/plugin-gimp/src/main.cc
index d9f38ea..aa49d7f 100644
--- a/milena/sandbox/nivault/plugin-gimp/src/main.cc
+++ b/milena/sandbox/nivault/plugin-gimp/src/main.cc
@@ -84,7 +84,7 @@ query (void)
G_N_ELEMENTS (args), 0,
args, NULL);
- gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Tools/");
+ gimp_plugin_menu_register (PROCEDURE_NAME, "<Image>/Filters/Milena");
}
static void
2
2