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
- 9625 discussions
Re: [Olena-patches] 4454: Write down 3d currently used formulaes.
by Alexandre Duret-Lutz 10 Sep '09
by Alexandre Duret-Lutz 10 Sep '09
10 Sep '09
Coucou Yann,
Quelques typos
>>> "YJ" == Yann Jacquelet <jacquelet(a)lrde.epita.fr> writes:
YJ> +
YJ> +%% \df
YJ> +%% input : the set which the dim we are intering in
the set whose dimension we are interested in?
YJ> +\begin{itemize}
YJ> + \item Use lowercase and normal font for the scalar variables.
YJ> + \item Use lowercase and bold font for the vector variables.
YJ> + \item Use uppercase and normal font for the matrix variables.
YJ> + \item Use uppercase and double font for the set variables.
YJ> +\end {itemize}
s/the//
YJ> +
YJ> +%=================================================================
YJ> +\subsection{Sets}
YJ> +
YJ> +There is three particular sets that we use every time:
s/is/are/
YJ> +\begin{itemize}
YJ> + \item The color space $\fm{C}$ in which the pixels take their value.
YJ> + \item The dataset $\fm{P}$ which contains every pixel we take care.
we care about.
YJ> + \item The group set $\fm{G}$ that define any splitting of the dataset.
defines
YJ> +We use the euclidian distance.
*E*uclidian
YJ> +$$
Use the backslash/bracket pair ("\[ ...\]") instead of a double
dollar construct ("$$ ... $$") for single line displays.
The double dollar sign as a begin/end marker for displayed math
material is a relic from plain TeX, but has been officially
deprecated in LaTeX. In fact, many LaTeX books don't even
mention it, since it is not supposed to be used. While it works
just fine in most situations, and many authors use it with
impunity, there are a few situations where it causes problems,
and it may not work under future versions of TeX. If you come
from a plain TeX/Amstex background and are in the habit of
typing $$'s, try to gradually switch over to using the
backslash/bracket pair. If you are new to Tex/LaTeX, learn it
right from the start (i.e., use the backslash/bracket method).
http://www.math.uiuc.edu/~hildebr/tex/tips-mathdisplays.html
YJ> +%=================================================================
YJ> +\subsection{The group}
YJ> +
YJ> +We can define the group set $\fm{G}$ in thow context:
in this context?
YJ> +When we study some mixed population, the total variance can be splitted in the
YJ> +the variance between the groups and in the variance whithin each group.
s/splitted/split/
s/in the the/in the/
s/whithin/within/
YJ> +
YJ> +%=================================================================
YJ> +\subsection{Decomposing the variance}
YJ> +When we study some mixed population, the total variance can be splitted in the
YJ> +the variance between the groups and in the variance whithin each group.
s/splitted/split/
s/in the the/in the/
s/whithin/within/
YJ> +%%=================================================================
YJ> +\subsection{Eigenvalues and eigenvectors}
YJ> +
YJ> +We assume that we work on variance/covariance matrix which is real and symetric.
s/on/on a/
s/symetric/symmetric/
YJ> +In this case, all the three eigen values are real.
s/eigen values/eigenvalues/
YJ> +\subsection{MCO for eigenvalues}
YJ> +
YJ> +In 3d, it's difficult to extract the cubic roots from the characteristic
YJ> +polynomia. The difficulties disappear when we find one of the three roots.
YJ> +A planar regression allows us to reach the equation of the plane. From the
YJ> +equation, we can determine its normal vector $\bm{w}$. It satisfies the
YJ> +following equation $A\bm{w} = \lambda_3\bm{w}$. Thus we know $\lambda_3$.
YJ> +By the way, as far as $trace(A) = \lambda_1 + \lambda_2 + \lambda_3$ and
YJ> +$det(A) = \lambda_1 \lambda_2 \lambda_3$, then we can access to the value of
Je ne comprends pas le "as far as". N'est-ce pas toujours vrai ?
s/access to the value of/determine/
YJ> +the two others eigenvalues (just solve $\lambda^2 - (trace(A) - \lambda_3)
YJ> +\lambda + \frac{det(A)}{\lambda_3} = 0$). The knowledge of $\lambda_1$ and
YJ> +$\lambda_2$ let us find $\bm{u}$ and $\bm{v}$ by the equations $A\bm{u} =
YJ> +\lambda_1\bm{u}$ and $A\bm{v} = \lambda_2\bm{v}$.
YJ> +
YJ> +Let's center the points by susbtracting their center of
YJ> mass. Now, we have
s/susbtracting/subtracting/
--
Alexandre Duret-Lutz
1
0
10 Sep '09
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-09-10 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Fix luminance value computation for RGB to HSL.
* mln/fun/v2v/rgb_to_hsl.hh: Fix luminance value computation
to fit in [0,1].
* mln/io/magick/load.hh: Minor update.
* mln/io/magick/save.hh: Minor update.
---
fun/v2v/rgb_to_hsl.hh | 4 ++--
io/magick/load.hh | 31 +++++++++++++++++++++++++++----
io/magick/save.hh | 21 +++++++++++++++++++++
3 files changed, 50 insertions(+), 6 deletions(-)
Index: trunk/milena/mln/fun/v2v/rgb_to_hsl.hh
===================================================================
--- trunk/milena/mln/fun/v2v/rgb_to_hsl.hh (revision 4456)
+++ trunk/milena/mln/fun/v2v/rgb_to_hsl.hh (revision 4457)
@@ -103,14 +103,14 @@
else
hsl.hue() = (60. * (rgb.red() - rgb.green()) / (rmax - rmin)) + 240;
- hsl.lum() = ((double) rmax + (double) rmin) / 2;
-
// We want min and max between 0 and 1
rmax -= mln_min(typename T_rgb::red_t);
rmin -= mln_min(typename T_rgb::red_t);
double nmax = (double) rmax / (mln_max(typename T_rgb::red_t) - mln_min(typename T_rgb::red_t));
double nmin = (double) rmin / (mln_max(typename T_rgb::red_t) - mln_min(typename T_rgb::red_t));
+ hsl.lum() = ((double) nmax + (double) nmin) / 2;
+
if (rmin == rmax)
hsl.sat() = 0;
else
Index: trunk/milena/mln/io/magick/save.hh
===================================================================
--- trunk/milena/mln/io/magick/save.hh (revision 4456)
+++ trunk/milena/mln/io/magick/save.hh (revision 4457)
@@ -58,6 +58,15 @@
void save(const Image<I>& ima,
const std::string& filename);
+ /*! Save a Milena tiled image in a magick image.
+ *
+ * \param[out] ima A reference to the image to save.
+ * \param[in] filename The output.
+ */
+ template <typename T>
+ void save(Image< tiled2d<T> >& ima,
+ const std::string& filename);
+
# ifndef MLN_INCLUDE_ONLY
@@ -117,6 +126,18 @@
trace::exiting("mln::io::magick::save");
}
+ template <typename T>
+ void save(Image< tiled2d<T> >& ima_, const std::string& filename)
+ {
+ trace::entering("mln::io::magick::save");
+
+ tiled2d<T>& ima = exact(ima_);
+
+ ima.buffer().write(filename);
+
+ trace::exiting("mln::io::magick::save");
+ }
+
# endif // ! MLN_INCLUDE_ONLY
Index: trunk/milena/mln/io/magick/load.hh
===================================================================
--- trunk/milena/mln/io/magick/load.hh (revision 4456)
+++ trunk/milena/mln/io/magick/load.hh (revision 4457)
@@ -53,8 +53,16 @@
* \param[in] filename The source.
*/
template <typename I>
- void load(Image<I>& ima,
- const std::string& filename);
+ void load(Image<I>& ima, const std::string& filename);
+
+ /*! Load a magick image in a tiled image.
+ *
+ * \param[out] ima A reference to the image which will receive
+ * data.
+ * \param[in] filename The source.
+ */
+ template <typename T>
+ void load(Image<tiled2d<T> >& ima, const std::string& filename);
# ifndef MLN_INCLUDE_ONLY
@@ -102,8 +110,7 @@
template <typename I>
inline
- void load(Image<I>& ima_,
- const std::string& filename)
+ void load(Image<I>& ima_, const std::string& filename)
{
trace::entering("mln::io::magick::load");
@@ -156,6 +163,22 @@
}
+ template<typename T>
+ inline
+ void load(Image<tiled2d<T> >& ima_, const std::string& filename)
+ {
+ trace::entering("mln::io::magick::load");
+
+ tiled2d<T>& ima = exact(ima_);
+
+ tiled2d<T> result(filename);
+
+ ima = result;
+ trace::exiting("mln::io::magick::load");
+ }
+
+
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::io::magick
1
0
* apps/graph-morpho/complex1d.cc: Improve documentation.
(dilation_vertex, erosion_vertex, dilation_edge, erosion_edge)
(combine, dilation_graph, erosion_graph):
New functions.
(main): Exercise some of them.
---
milena/ChangeLog | 10 ++++
milena/apps/graph-morpho/complex1d.cc | 93 +++++++++++++++++++++++++++++++--
2 files changed, 98 insertions(+), 5 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index f716134..f1eb252 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,13 @@
+2009-09-09 Roland Levillain <roland(a)lrde.epita.fr>
+
+ More morphological operators on graphs.
+
+ * apps/graph-morpho/complex1d.cc: Improve documentation.
+ (dilation_vertex, erosion_vertex, dilation_edge, erosion_edge)
+ (combine, dilation_graph, erosion_graph):
+ New functions.
+ (main): Exercise some of them.
+
2009-09-09 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add mask-based max tree computation based on union-find algorithm.
diff --git a/milena/apps/graph-morpho/complex1d.cc b/milena/apps/graph-morpho/complex1d.cc
index 8587040..93eab21 100644
--- a/milena/apps/graph-morpho/complex1d.cc
+++ b/milena/apps/graph-morpho/complex1d.cc
@@ -204,7 +204,7 @@ println(const complex_image<dim, geom_t, T>& ima, const box2d& support)
(resp. erosion), or even use Milena's standard morpho::dilation
(resp. morpho::erosion). */
-/// Dilation from edges to vertices (delta^dot).
+/// Dilation from edges to vertices (\f$\delta^\bullet\f$).
template <typename I>
mln_concrete(I)
dilation_e2v(const Image<I>& input_)
@@ -227,7 +227,7 @@ dilation_e2v(const Image<I>& input_)
return output;
}
-/// Erosion from vertices to edges (erosion^cross).
+/// Erosion from vertices to edges (\f$\epsilon^\times\f$).
template <typename I>
mln_concrete(I)
erosion_v2e(const Image<I>& input_)
@@ -250,7 +250,7 @@ erosion_v2e(const Image<I>& input_)
return output;
}
-/// Erosion from edges to vertices (erosion^dot).
+/// Erosion from edges to vertices (\f$\epsilon^\bullet\f$).
template <typename I>
mln_concrete(I)
erosion_e2v(const Image<I>& input_)
@@ -273,7 +273,7 @@ erosion_e2v(const Image<I>& input_)
return output;
}
-/// Dilation from vertices to edges (dilation^cross).
+/// Dilation from vertices to edges (\f$\delta^\times\f$).
template <typename I>
mln_concrete(I)
dilation_v2e(const Image<I>& input_)
@@ -297,6 +297,80 @@ dilation_v2e(const Image<I>& input_)
}
+/// Vertex dilation (\f$delta\f$).
+template <typename I>
+mln_concrete(I)
+dilation_vertex(const Image<I>& input)
+{
+ return dilation_e2v(dilation_v2e(input));
+}
+
+/// Vertex erosion (\f$epsilon\f$).
+template <typename I>
+mln_concrete(I)
+erosion_vertex(const Image<I>& input)
+{
+ return erosion_e2v(erosion_v2e(input));
+}
+
+
+/// Edge dilation (\f$Delta\f$).
+template <typename I>
+mln_concrete(I)
+dilation_edge(const Image<I>& input)
+{
+ return dilation_v2e(dilation_e2v(input));
+}
+
+/// Edge erosion (\f$Epsilon\f$).
+template <typename I>
+mln_concrete(I)
+erosion_edge(const Image<I>& input)
+{
+ return erosion_v2e(erosion_e2v(input));
+}
+
+
+/// Combine the vertices and the edges of two images to create a new
+/// graph image.
+template <typename I>
+mln_concrete(I)
+combine(const Image<I>& vertices_, const Image<I>& edges_)
+{
+ const I vertices = exact(vertices_);
+ const I edges = exact(edges_);
+ mln_precondition(vertices.domain() == edges.domain());
+
+ mln_concrete(I) output;
+ initialize(output, vertices);
+ p_n_faces_fwd_piter<dim, geom_t> v(output.domain(), 0);
+ for_all(v)
+ output(v) = vertices(v);
+ p_n_faces_fwd_piter<dim, geom_t> e(output.domain(), 1);
+ for_all(e)
+ output(e) = edges(e);
+ return output;
+}
+
+
+/// Graph dilation (\f$delta \ovee Delta\f$).
+template <typename I>
+mln_concrete(I)
+dilation_graph(const Image<I>& input)
+{
+ return combine(dilation_vertex(input), dilation_edge(input));
+}
+
+/// Graph erosion (\f$epsilon \ovee Epsilon\f$).
+template <typename I>
+mln_concrete(I)
+erosion_graph(const Image<I>& input)
+{
+ return combine(erosion_vertex(input), erosion_edge(input));
+}
+
+
+
int main()
{
/*--------------.
@@ -309,7 +383,7 @@ int main()
box2d b(9, 6);
ima_t ima = build_regular_complex1d_image(b);
- /* Set the values so that IMA corresponds to the graph G of the ISMM
+ /* Set the values so that IMA corresponds to the graph X of the ISMM
2009 paper from Jean Cousty et al. */
// The set of vertices of the graph.
@@ -387,4 +461,13 @@ int main()
ima_t dil_v2e_ima = dilation_v2e(ima);
std::cout << "dil_v2e_ima:" << std::endl;
println(dil_v2e_ima, b);
+
+
+ ima_t dil_ima = dilation_graph(ima);
+ std::cout << "dil_ima:" << std::endl;
+ println(dil_ima, b);
+
+ ima_t ero_ima = erosion_graph(ima);
+ std::cout << "ero_ima:" << std::endl;
+ println(ero_ima, b);
}
--
1.6.3.1
1
0
10 Sep '09
* green/doc/quick_tour : New specific directory.
* green/doc/quick_tour/quick_tour.tex : New documentation work.
---
trunk/milena/sandbox/ChangeLog | 7 ++
.../sandbox/green/doc/quick_tour/quick_tour.tex | 115 ++++++++++++++++++++
2 files changed, 122 insertions(+), 0 deletions(-)
create mode 100644 trunk/milena/sandbox/green/doc/quick_tour/quick_tour.tex
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index b50e807..8b4d62c 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,5 +1,12 @@
2009-09-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Write down the basis of the quick tour summary documentation.
+
+ * green/doc/quick_tour : New specific directory.
+ * green/doc/quick_tour/quick_tour.tex : New documentation work.
+
+2009-09-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Write down 3d currently used formulaes.
* green/doc : New documentation directory.
diff --git a/trunk/milena/sandbox/green/doc/quick_tour/quick_tour.tex b/trunk/milena/sandbox/green/doc/quick_tour/quick_tour.tex
new file mode 100644
index 0000000..c35ec31
--- /dev/null
+++ b/trunk/milena/sandbox/green/doc/quick_tour/quick_tour.tex
@@ -0,0 +1,115 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+%%
+%% This file is part of Olena.
+%%
+%% Olena is free software: you can redistribute it and/or modify it under
+%% the terms of the GNU General Public License as published by the Free
+%% Software Foundation, version 2 of the License.
+%%
+%% Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+
+\documentclass{article}
+
+%\usepackage{hevea}
+
+\usepackage{html}
+\usepackage{hyperref}
+\usepackage{graphicx}
+\usepackage{makeidx}
+\usepackage{xcolor}
+\usepackage{color}
+\usepackage{amsfonts}
+\usepackage{amsmath}
+\usepackage{amsthm}
+\usepackage{amssymb}
+
+\title{Olena summary}
+\author{LRDE}
+\date{}
+\makeindex
+
+\begin{document}
+
+\maketitle
+
+%#################################################################
+\section{Summary}
+
+Write down some evidence about olena library.
+
+%=================================================================
+\subsection{Image formats}
+
+Concerning the mln/io directory.
+We must exactly know which kind of image we can import or export.
+So we must decide the kind of value (float,grayscale,rgb) and its
+quantification (8 bits, 16 bits, 24 bits, 32 bits ...), the kind of image
+1d, 2d, 3d, if there is some compression or not and every thing like this.
+
+\begin{itemize}
+ \item cloud (load/save)
+ \item plot (load/save)
+ \item dump (load/save)
+ \item off (load/save)
+ \item magick (load/save)
+ \item pbm (load/save)
+ \item pgm (load/save)
+ \item ppm (load/save)
+ \item pfm (load/save)
+ \item pnm (load/save)
+ \item txt (save)
+ \item pbms (load)
+ \item pgms (load)
+ \item ppms (load)
+ \item pnms (load)
+ \item fits (load)
+ \item tiff (load) [color deph ?/grayscale deph ?] [1d/2d/3d ??]
+ \item dicom (load)
+\end{itemize}
+
+%=================================================================
+\subsection{Image type}
+
+\begin{itemize}
+ \item image1d
+ \item image2d
+ \item image3d
+ \item flat\_image
+ \item interpolated
+ \item tr\_image
+ \item graph
+ \item interpixel image
+\end{itemize}
+
+%=================================================================
+\subsection{Image value}
+
+\begin{itemize}
+ \item graylevel (gl8, gl16, glf)
+ \item unsigned integer (int\_u8, int\_u12, int\_u16, int\_u32, int\_u<n>, int\_u\_sat)
+ \item signed integer (int\_s8, int\_s16, int\_s32, int\_s<n>)
+ \item color (rgb8, rgb16, rgb<n>, hsi, hsl)
+ \item label (label<n>, label8, label16)
+ \item float (float01\_8, float01\_16, float01\_f)
+\end{itemize}
+
+
+
+%=================================================================
+\subsection{Image standard operations}
+
+\begin{itemize}
+ \item lut ??
+ \item histogram
+ \item stats/accu
+ \item addition/soustraction/ ...
+ \item classical image processing
+\end{itemize}
+
+\end{document}
--
1.5.6.5
1
0
* green/doc : New documentation directory.
* green/doc/formulae : New specific directory.
* green/doc/formulae/formulae.tex : New recipe of 3d formulae.
---
trunk/milena/sandbox/ChangeLog | 8 +
.../milena/sandbox/green/doc/formulae/formulae.tex | 1157 ++++++++++++++++++++
2 files changed, 1165 insertions(+), 0 deletions(-)
create mode 100644 trunk/milena/sandbox/green/doc/formulae/formulae.tex
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index 5a96357..b50e807 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-10 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Write down 3d currently used formulaes.
+
+ * green/doc : New documentation directory.
+ * green/doc/formulae : New specific directory.
+ * green/doc/formulae/formulae.tex : New recipe of 3d formulae.
+
2009-09-09 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Fix bugs an compilation problem on histo3d_rgb source code.
diff --git a/trunk/milena/sandbox/green/doc/formulae/formulae.tex b/trunk/milena/sandbox/green/doc/formulae/formulae.tex
new file mode 100644
index 0000000..52af7a7
--- /dev/null
+++ b/trunk/milena/sandbox/green/doc/formulae/formulae.tex
@@ -0,0 +1,1157 @@
+%% Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+%%
+%% This file is part of Olena.
+%%
+%% Olena is free software: you can redistribute it and/or modify it under
+%% the terms of the GNU General Public License as published by the Free
+%% Software Foundation, version 2 of the License.
+%%
+%% Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+
+\documentclass{article}
+
+%\usepackage{hevea}
+
+\usepackage{html}
+\usepackage{hyperref}
+\usepackage{graphicx}
+\usepackage{makeidx}
+\usepackage{xcolor}
+\usepackage{color}
+\usepackage{amsfonts}
+\usepackage{amsmath}
+\usepackage{amsthm}
+\usepackage{amssymb}
+
+
+%% \bm
+%% input : the mathematical text to put in bold
+%%
+\newcommand{\bm}[1]{\mbox{\boldmath$#1$}}
+
+%% \fm
+%% input : the mathematical text to put in mathematic font set
+%%
+\newcommand{\fm}[1]{\mathbb{#1}}
+
+%% \df
+%% input : the set which the dim we are intering in
+%%
+\newcommand{\df}[1]{|{\mathbb{#1}}|}
+
+\title{Recipe in statistics and linear algebra\\
+ \large{A few formulas in $\fm{R}^3$ space} }
+\author{LRDE}
+\date{}
+\makeindex
+
+\begin{document}
+
+\maketitle
+
+%#################################################################
+\section{Introduction}
+The goal of this document is to keep in mind some statictic formulas which are
+not so evident to represent. They help us to keep some background mathematics
+in the development.
+
+%#################################################################
+\section{Notations}
+
+\begin{itemize}
+ \item Use lowercase and normal font for the scalar variables.
+ \item Use lowercase and bold font for the vector variables.
+ \item Use uppercase and normal font for the matrix variables.
+ \item Use uppercase and double font for the set variables.
+\end {itemize}
+
+%=================================================================
+\subsection{Sets}
+
+There is three particular sets that we use every time:
+\begin{itemize}
+ \item The color space $\fm{C}$ in which the pixels take their value.
+ \item The dataset $\fm{P}$ which contains every pixel we take care.
+ \item The group set $\fm{G}$ that define any splitting of the dataset.
+\end{itemize}
+
+\begin{tabular}{|c|l|l|c|c|}
+ \hline
+ Sets & Contents & (in sample) &
+ Dimension & (in sample) \\
+ \hline
+ $\fm{C}$ & $\fm{R}^q$ & $\fm{R}^3$ &
+ $\df{C} = q$ & $q = 3$ \\
+ $\fm{P}$ & $\{\bm{p_i}\}$ &$\{\bm{a},\bm{b},\bm{c},\bm{d}\}$ &
+ $\df{P} = r$ & $r = 4$ \\
+ $\fm{G}$ & $\{\fm{G}_i\}$ &$\{\fm{F}, \fm{H}\}$ &
+ $\df{G} = k$ & $k = 2$ \\
+ \hline
+\end{tabular}
+
+%=================================================================
+\subsection{Color space}
+
+We use the euclidian distance.
+
+$$
+d(a,b) =
+\sqrt{\sum_{i=0}^q (a_i - b_i)^2} =
+\sqrt{(a_x - b_x)^2 + (a_y - b_y)^2 + (a_z - b_z)^2}
+$$
+
+$$
+d(a,b)^2 =
+\left[\begin{array}{ccc}
+ a_x - b_x & a_y - b_y & a_z - b_z
+\end{array}\right]
+\times
+\left[\begin{array}{c}
+ a_x - b_x \\
+ a_y - b_y \\
+ a_y - b_z
+\end{array}\right]
+$$
+
+%=================================================================
+\subsection{Data points in $\mathbb{R}^3$}
+We present the four points of the dataset with their vector representation.
+
+$$
+\bm{a} =
+\left[\begin{array}{c}
+ a_x \\
+ a_y \\
+ a_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{1x} \\
+ p_{1y} \\
+ p_{1z}
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{11} \\
+ p_{12} \\
+ p_{13}
+\end{array}\right]
+= \bm{p}_1
+$$
+
+$$
+\bm{b} =
+\left[\begin{array}{c}
+ b_x \\
+ b_y \\
+ b_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{2x} \\
+ p_{2y} \\
+ p_{2z}
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{21} \\
+ p_{22} \\
+ p_{23}
+\end{array}\right]
+= \bm{p}_2
+$$
+
+$$
+\bm{c} =
+\left[\begin{array}{c}
+ c_x \\
+ c_y \\
+ c_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{3x} \\
+ p_{3y} \\
+ p_{3z}
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{31} \\
+ p_{32} \\
+ p_{33}
+\end{array}\right]
+= \bm{p}_3
+$$
+
+$$
+\mbox{\boldmath$d$} =
+\left[\begin{array}{c}
+ d_x \\
+ d_y \\
+ d_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{4x} \\
+ p_{4y} \\
+ p_{4z}
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{41} \\
+ p_{42} \\
+ p_{43}
+\end{array}\right]
+= \bm{p}_4
+$$
+
+One may group the four points in one matrix P :
+
+$$
+P =
+\left[\begin{array}{c}
+ \bm{a}^t \\
+ \bm{b}^t \\
+ \bm{c}^t \\
+ \bm{d}^t
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ a_x & a_y & a_z \\
+ b_x & b_y & b_z \\
+ c_x & c_y & c_z \\
+ d_x & d_y & d_z
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ p_{1x} & p_{1y} & p_{1z} \\
+ p_{2x} & p_{2y} & p_{2z} \\
+ p_{3x} & p_{3y} & p_{3z} \\
+ p_{4x} & p_{4y} & p_{4z}
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ p_{11} & p_{22} & p_{13} \\
+ p_{21} & p_{22} & p_{23} \\
+ p_{31} & p_{32} & p_{33} \\
+ p_{41} & p_{42} & p_{43}
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ \bm{p}_1^t \\
+ \bm{p}_2^t \\
+ \bm{p}_3^t \\
+ \bm{p}_4^t
+\end{array}\right]
+$$
+
+%=================================================================
+\subsection{The group}
+
+We can define the group set $\fm{G}$ in thow context:
+\begin{itemize}
+ \item First, the group set is a partition.
+ \item Second, the group set if a fuzzy set.
+\end{itemize}
+
+$\df{P} = \sum_{i=1}^{k} |\fm{G}_i| = \df{F} + \df{H} = 4$
+
+$\dim F = \dim H = \df{P} = 4$
+
+$
+\bm{f} =
+\left[\begin{array}{c}
+ f_a \\
+ f_b \\
+ f_c \\
+ f_d
+\end{array}\right]
+=
+\frac{1}{2}
+\left[\begin{array}{c}
+ 1 \\
+ 1 \\
+ 0 \\
+ 0
+\end{array}\right]
+$
+
+$\sum_{i=1}^{k} f_i = 1$
+
+$
+\bm{h} =
+\left[\begin{array}{c}
+ h_a \\
+ h_b \\
+ h_c \\
+ h_d
+\end{array}\right]
+=
+\frac{1}{2}
+\left[\begin{array}{c}
+ 0 \\
+ 0 \\
+ 1 \\
+ 1
+\end{array}\right]
+$
+
+$\sum_{i=1}^{k} h_i = 1$
+
+The appartenance degree of $\bm{a}$ to the group $\fm{H}$ is $h_a$ such that:
+
+$ h_a \in
+\begin{cases}
+ \{0,1\} \text{if $\fm{G}$ is a partition.} \\
+ [0,1] \text{if $\fm{G}$ is a fuzzy set.}
+\end{cases}
+$
+
+%#################################################################
+\section{Momentum}
+
+Let's have a look to the first three moments.
+
+%=================================================================
+\subsection{The mean}
+
+$$
+ \mbox{\boldmath$m$} =
+\left[\begin{array}{c}
+ m_x \\
+ m_y \\
+ m_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ m_1 \\
+ m_2 \\
+ m_3
+\end{array}\right]
+=
+\frac{1}{4}
+\left[\begin{array}{c}
+ a_x + b_x + c_x + d_x \\
+ a_y + b_y + c_y + d_y \\
+ a_z + b_z + c_z + d_z
+\end{array}\right]
+=
+\frac{1}{4}
+\left[\begin{array}{c}
+ \sum_{i=1}^{4}p_{ix} \\
+ \sum_{i=1}^{4}p_{iy} \\
+ \sum_{i=1}^{4}p_{iz}
+\end{array}\right]
+=
+\frac{1}{4}(\mbox{\boldmath$a$} + \mbox{\boldmath$b$} + \mbox{\boldmath$c$} +
+ \mbox{\boldmath$d$})
+=
+\frac{1}{4}\sum_{i=1}^{4}\mbox{\boldmath$p$}_i
+$$
+$$
+ \mbox{\boldmath$m$} =
+\frac{1}{4}
+\left[\begin{array}{cccc}
+ a_x & b_x & c_x & d_x \\
+ a_y & b_y & c_y & d_y \\
+ a_z & b_z & c_z & d_z
+\end{array}\right]
+\left[\begin{array}{c}
+ 1 \\
+ 1 \\
+ 1 \\
+ 1
+\end{array}\right]
+=
+\frac{1}{4}
+\left[\begin{array}{cccc}
+ \mbox{\boldmath$p$}_1^t & \mbox{\boldmath$p$}_2^t &
+ \mbox{\boldmath$p$}_3^t & \mbox{\boldmath$p$}_4^t
+\end{array}\right]
+\left[\begin{array}{c}
+ 1 \\
+ 1 \\
+ 1 \\
+ 1
+\end{array}\right]
+=
+\frac{1}{4} P^t \mbox{\boldmath$ 1$}
+$$
+The mean matrix:
+
+$$
+M =
+\left[\begin{array}{c}
+ \mbox{\boldmath$m$}^t \\
+ \mbox{\boldmath$m$}^t \\
+ \mbox{\boldmath$m$}^t \\
+ \mbox{\boldmath$m$}^t
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ m_1 & m_2 & m_3 \\
+ m_1 & m_2 & m_3 \\
+ m_1 & m_2 & m_3 \\
+ m_1 & m_2 & m_3
+\end{array}\right]
+$$
+
+We define the difference between a point $\mbox{\boldmath$p$}_i$ and the mean:
+$$
+(\mbox{\boldmath$p$}_i - \mbox{\boldmath$m$}) =
+\left[\begin{array}{c}
+ p_{ix} - m_x \\
+ p_{iy} - m_y \\
+ p_{iz} - m_z
+\end{array}\right]
+=
+\left[\begin{array}{c}
+ p_{i1} - m_1 \\
+ p_{i2} - m_2 \\
+ p_{i3} - m_3
+\end{array}\right]
+$$
+
+And for all the dataset:
+
+$$
+(P - M) =
+\left[\begin{array}{ccc}
+ a_x & a_y & a_z \\
+ b_x & b_y & b_z \\
+ c_x & c_y & c_z \\
+ d_x & d_y & d_z
+\end{array}\right]
+-
+\left[\begin{array}{ccc}
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z \\
+ m_x & m_y & m_z
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ a_x - m_x & a_y - m_y & a_z - m_z \\
+ b_x - m_x & b_y - m_y & b_z - m_z \\
+ c_x - m_x & c_y - m_y & c_z - m_z \\
+ d_x - m_x & d_y - m_y & d_z - m_z
+\end{array}\right]
+$$
+
+%=================================================================
+\subsection{The variance}
+
+$$
+\begin{array}{lcl}
+V & = &
+\left[\begin{array}{ccc}
+ v_{xx} & v_{xy} & v_{xz} \\
+ v_{yx} & v_{yy} & v_{yz} \\
+ v_{zx} & v_{zy} & v_{zz}
+\end{array}\right]
+=
+\left[\begin{array}{ccc}
+ v_{11} & v_{12} & v_{13} \\
+ v_{21} & v_{22} & v_{23} \\
+ v_{31} & v_{32} & v_{33}
+\end{array}\right]
+\\
+V & = &
+\frac{1}{4}
+\left[\begin{array}{ccc}
+ \sum_{i=1}^4 (p_{ix} - m_x)(p_{ix} - m_x) &
+ \sum_{i=1}^4 (p_{ix} - m_x)(p_{iy} - m_y) &
+ \sum_{i=1}^4 (p_{ix} - m_x)(p_{iz} - m_z) \\
+ \sum_{i=1}^4 (p_{iy} - m_y)(p_{ix} - m_x) &
+ \sum_{i=1}^4 (p_{iy} - m_y)(p_{iy} - m_y) &
+ \sum_{i=1}^4 (p_{iy} - m_y)(p_{iz} - m_z) \\
+ \sum_{i=1}^4 (p_{iz} - m_z)(p_{ix} - m_x) &
+ \sum_{i=1}^4 (p_{iz} - m_z)(p_{iy} - m_y) &
+ \sum_{i=1}^4 (p_{iz} - m_z)(p_{iz} - m_z)
+\end{array}\right]
+\\
+V & = &
+\frac{1}{4}
+\left[\begin{array}{cccc}
+ a_x - m_x & b_x - m_x & c_x - m_x & d_x - m_x \\
+ a_y - m_y & b_y - m_y & c_y - m_y & d_y - m_y \\
+ a_z - m_z & b_z - m_z & c_z - m_z & d_z - m_z
+\end{array}\right]
+\left[\begin{array}{ccc}
+ a_x - m_x & a_y - m_y & a_z - m_z \\
+ b_x - m_x & b_y - m_y & b_z - m_z \\
+ c_x - m_x & c_y - m_y & c_z - m_z \\
+ d_x - m_x & d_y - m_y & d_z - m_z
+\end{array}\right]
+\\
+V & = &
+\frac{1}{4}
+(P - M)^t (P - M)
+\end{array}
+$$
+
+%#################################################################
+\section{Splitting into groups}
+When we study some mixed population, the total variance can be splitted in the
+the variance between the groups and in the variance whithin each group.
+
+We define two groups in the population. Each group owns its moments of the
+second order.
+
+%=================================================================
+\subsection{Decomposing the count}
+
+$$
+\begin{array}{lcl}
+n_t & = & n_1 + n_2 \\
+ & = & \sum_{i=1}^{2} n_i
+\end{array}
+$$
+
+
+%=================================================================
+\subsection{Decomposing the mean}
+
+$$
+\begin{array}{lcl}
+\mbox{\boldmath$m_t$} & = &
+ \frac{1}{n_t}(n_1 \mbox{\boldmath$m_1$} + n_2 \mbox{\boldmath$m_2$}) \\
+ & = &
+ \frac{1}{n_t}\sum_{i=1}^{2} n_i \mbox{\boldmath$m_i$}
+\end{array}
+$$
+
+
+%=================================================================
+\subsection{Decomposing the variance}
+When we study some mixed population, the total variance can be splitted in the
+the variance between the groups and in the variance whithin each group.
+
+$$
+V_t = V_i + V_b
+$$
+
+$$
+\begin{array}{lcl}
+V_i & = & \frac{1}{n_t}(n_1 V_1 + n_2 V_2) \\
+ & = & \frac{1}{n_t}\sum_{i=1}^2 n_i V_i
+\end{array}
+$$
+
+$$
+\begin{array}{lcl}
+V_b & = & \frac{1}{n_t}(n_1 (\mbox{\boldmath$m_1$} - \mbox{\boldmath$m_t$})^2 +
+ n_2 (\mbox{\boldmath$m_2$} - \mbox{\boldmath$m_t$})^2 \\
+ & = & \frac{1}{n_t} \sum_{i=1}^2 n_i
+ (\mbox{\boldmath$m_i$} - \mbox{\boldmath$m_t$})^2
+\end{array}
+$$
+
+%#################################################################
+\section{Basis}
+
+%%=================================================================
+\subsection{Determinant of a square matrix 3x3}
+
+$$
+\det{V} =
+\left|\begin{array}{ccc}
+ v_{11} & v_{12} & v_{13} \\
+ v_{21} & v_{22} & v_{23} \\
+ v_{31} & v_{32} & v_{33}
+\end{array}\right|
+=
+v_{11}(v_{22}v_{33} - v_{32}v_{23})
+- v_{12}(v_{21}v_{33} - v_{31}v_{23})
++ v_{13}(v_{21}v_{32} - v_{31}v_{22})
+$$
+
+%%=================================================================
+\subsection{Transpose}
+
+$
+V^t =
+\left[\begin{array}{ccc}
+ v_{11} & v_{12} & v_{13} \\
+ v_{21} & v_{22} & v_{23} \\
+ v_{31} & v_{32} & v_{33}
+\end{array}\right]^t
+=
+\left[\begin{array}{ccc}
+ v_{11} & v_{21} & v_{31} \\
+ v_{12} & v_{22} & v_{32} \\
+ v_{13} & v_{23} & v_{33}
+\end{array}\right]
+$
+
+%%=================================================================
+\subsection{Inverse of a square matrix 3x3}
+
+\begin{tabular}{c c}
+$
+minor(v_{11})
+=
+\left|\begin{array}{cc}
+ v_{22} & v_{23} \\
+ v_{32} & v_{33}
+\end{array}\right|
+=
+v_{22}v_{33} - v_{32}v_{23}
+$
+&
+$
+minor(v_{21})
+=
+\left|\begin{array}{cc}
+ v_{12} & v_{13} \\
+ v_{31} & v_{33}
+\end{array}\right|
+=
+v_{12}v_{33} - v_{31}v_{31}
+$
+\\
+\\
+$
+minor(v_{31})
+=
+\left|\begin{array}{cc}
+ v_{12} & v_{13} \\
+ v_{22} & v_{23}
+\end{array}\right|
+=
+v_{12}v_{23} - v_{22}v_{13}
+$
+&
+$
+minor(v_{12})
+=
+\left|\begin{array}{cc}
+ v_{21} & v_{23} \\
+ v_{31} & v_{33}
+\end{array}\right|
+=
+v_{21}v_{33} - v_{31}v_{23}
+$
+\\
+\\
+$
+minor(v_{22})
+=
+\left|\begin{array}{cc}
+ v_{11} & v_{13} \\
+ v_{31} & v_{33}
+\end{array}\right|
+=
+v_{11}v_{33} - v_{31}v_{13}
+$
+&
+$
+minor(v_{32})
+=
+\left|\begin{array}{cc}
+ v_{11} & v_{13} \\
+ v_{21} & v_{23}
+\end{array}\right|
+=
+v_{11}v_{23} - v_{21}v_{13}
+$
+\\
+\\
+$
+minor(v_{13})
+=
+\left|\begin{array}{cc}
+ v_{21} & v_{22} \\
+ v_{31} & v_{32}
+\end{array}\right|
+=
+v_{21}v_{32} - v_{31}v_{22}
+$
+&
+$
+minor(v_{23})
+=
+\left|\begin{array}{cc}
+ v_{11} & v_{12} \\
+ v_{31} & v_{32}
+\end{array}\right|
+=
+v_{11}v_{32} - v_{31}v_{12}
+$
+\\
+\\
+$
+minor(v_{33})
+=
+\left|\begin{array}{cc}
+ v_{11} & v_{12} \\
+ v_{21} & v_{22}
+\end{array}\right|
+=
+v_{11}v_{22} - v_{21}v_{12}
+$
+\end{tabular}
+
+
+$$
+minor(V) =
+minor(
+\left[\begin{array}{ccc}
+ v_{11} & v_{12} & v_{13} \\
+ v_{21} & v_{22} & v_{23} \\
+ v_{31} & v_{32} & v_{33}
+\end{array}\right])
+=
+\left[\begin{array}{ccc}
+ minor(v_{11}) & minor(v_{12}) & minor(v_{13}) \\
+ minor(v_{21}) & minor(v_{22}) & minor(v_{23}) \\
+ minor(v_{31}) & minor(v_{32}) & minor(v_{33})
+\end{array}\right]
+$$
+
+$$
+cofactor(V)
+=
+\left[\begin{array}{ccc}
+ (+)minor(v_{11}) & (-)minor(v_{12}) & (+)minor(v_{13}) \\
+ (-)minor(v_{21}) & (+)minor(v_{22}) & (-)minor(v_{23}) \\
+ (+)minor(v_{31}) & (-)minor(v_{32}) & (+)minor(v_{33})
+\end{array}\right]
+$$
+
+
+$$
+adj(V) = cofactor(V)^t
+=
+\left[\begin{array}{ccc}
+ v_{22}v_{33} - v_{32}v_{23} &
+ v_{31}v_{13} - v_{12}v_{33} &
+ v_{12}v_{23} - v_{22}v_{13} \\
+ v_{31}v_{23} - v_{21}v_{33} &
+ v_{11}v_{33} - v_{31}v_{13} &
+ v_{21}v_{13} - v_{11}v_{23} \\
+ v_{21}v_{32} - v_{31}v_{22} &
+ v_{21}v_{13} - v_{11}v_{23} &
+ v_{11}v_{22} - v_{21}v_{12}
+\end{array}\right]
+$$
+
+$$
+V^{-1}
+=
+\frac{adj(V)}{\det V}
+$$
+
+
+%%=================================================================
+\subsection{Eigenvalues and eigenvectors}
+
+We assume that we work on variance/covariance matrix which is real and symetric.
+In this case, all the three eigen values are real.
+
+$$
+V \bm{x} = \lambda \bm{x}
+$$
+
+$$
+\det V - \lambda I = 0
+$$
+
+\begin{tabular}{lcl}
+$\det V - \lambda I$ &
+$=$ &
+$\left|\begin{array}{ccc}
+ v_{11} - \lambda & v_{21} & v_{31} \\
+ v_{12} & v_{22} - \lambda & v_{32} \\
+ v_{13} & v_{23} & v_{33} - \lambda
+\end{array}\right|$
+\\
+\\
+&
+$=$ &
+$(v_{11} - \lambda)((v_{22} - \lambda)(v_{33} - \lambda) - v_{32}v_{23})$
+\\
+&
+&
+$- v_{12}(v_{21}(v_{33} - \lambda) - v_{31}v_{23})$
+\\
+&
+&
+$- v_{13}(v_{21}v_{32} - v_{31}(v_{22} - \lambda))$
+\\
+\\
+&
+= &
+$- \lambda^3 + (v_{11} + v_{22} + v_{33})\lambda^2$
+\\
+&
+&
+$ -(v_{12}v_{21} + v_{13}v_{31} + v_{23}v_{32}
+ - v_{11}v_{22} - v_{11}v_{33} - v_{22}v_{33})\lambda$
+\\
+&
+&
+$+ v_{11}(v_{22}v_{33} - v_{32}v_{23}) -
+v_{12}(v_{21}v_{33} - v_{31}v_{23}) -
+v_{13}(v_{21}v_{32} - v_{31}v_{22})$
+\\
+\\
+& $=$ &
+$-\lambda^3 + tr(V) \lambda^2 + \frac{1}{2}[tr(A^2) - tr(A)^2]\lambda + \det A$
+\\
+\\
+\end{tabular}
+
+
+\begin{tabular}{ccccccc}
+\\
+$A$
+& $=$ &
+$
+\left[\begin{array}{ccc}
+ a & d & e \\
+ d & b & f \\
+ e & f & c
+\end{array}\right]
+$
+\\
+\\
+& $=$ &
+$P$ & $\times$ & $D$ & $\times$ & $P^t$
+\\
+\\
+& $=$ &
+$
+\left[\begin{array}{ccc}
+ u_1 & v_1 & w_1 \\
+ u_2 & v_2 & w_2 \\
+ u_3 & v_3 & w_3
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ \lambda_1 & 0 & 0 \\
+ 0 & \lambda_2 & 0 \\
+ 0 & 0 & \lambda_3
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ u_1 & u_2 & u_3 \\
+ v_1 & v_2 & v_3 \\
+ w_1 & w_2 & w_3
+\end{array}\right]
+$
+\\
+\\
+& $=$ &
+$
+\lambda_1
+\left[\begin{array}{ccc}
+ u_1^2 & u_1u_2 & u_1u_3 \\
+ u_2u_1 & u_2^2 & u_2u_3 \\
+ u_3u_1 & u_3u_2 & u_3^2 \\
+\end{array}\right]
+$
+& $+$ &
+$
+\lambda_2
+\left[\begin{array}{ccc}
+ v_1^2 & v_1v_2 & v_1v_3 \\
+ v_2v_1 & v_2^2 & v_2v_3 \\
+ v_3v_1 & v_3v_2 & v_3^2 \\
+\end{array}\right]
+$
+& $+$ &
+$
+\lambda_3
+\left[\begin{array}{ccc}
+ w_1^2 & w_1w_2 & w_1w_3 \\
+ w_2w_1 & w_2^2 & w_2w_3 \\
+ w_3w_1 & w_3w_2 & w_3^2 \\
+\end{array}\right]
+$
+\\
+\\
+& $=$ &
+$\lambda_1\bm{uu^t}$
+& $+$ &
+$\lambda_2\bm{vv^t}$
+& $+$ &
+$\lambda_3\bm{ww^t}$
+\\
+\\
+$I$
+& $=$ &
+$PP^t$
+& $=$ &
+$P^tP$
+\\
+\\
+$0$
+& $=$ &
+$A\bm{u}-\lambda_1\bm{u}$
+& $=$ &
+$A\bm{v}-\lambda_2\bm{v}$
+& $=$ &
+$A\bm{w}-\lambda_3\bm{w}$
+\\
+\\
+$|P|$
+& $=$ &
+$
+\left|\begin{array}{ccc}
+ u_1 & u_2 & u_3 \\
+ v_1 & v_2 & v_3 \\
+ w_1 & w_2 & w_3
+\end{array}\right|
+$
+& $=$ &
+1
+\end{tabular}
+
+
+%% sample
+
+\begin{tabular}{ccccccc}
+\\
+$
+\left[\begin{array}{ccc}
+ \frac{3}{2} & \frac{1}{2} & 0 \\
+\\
+ \frac{1}{2} & \frac{3}{2} & 0 \\
+\\
+ 0 & 0 & 2
+\end{array}\right]
+$
+& $=$ &
+$
+\left[\begin{array}{ccc}
+ \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{1}} & -\frac{1}{\sqrt{2}} \\
+\\
+ \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{6}} & \frac{1}{\sqrt{2}} \\
+\\
+ \frac{1}{\sqrt{3}} & -\frac{2}{\sqrt{6}} & 0
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ 2 & 0 & 0 \\
+\\
+ 0 & 2 & 0 \\
+\\
+ 0 & 0 & 1
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} \\
+\\
+ \frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}} & -\frac{2}{\sqrt{6}} \\
+\\
+ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0
+\end{array}\right]
+$
+\\
+\\
+& $=$ &
+$
+2
+\left[\begin{array}{ccc}
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\\
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\\
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\end{array}\right]
+$
+& $+$ &
+$
+2
+\left[\begin{array}{ccc}
+ \frac{1}{6} & \frac{1}{6} & -\frac{2}{6} \\
+\\
+ \frac{1}{6} & \frac{1}{6} & -\frac{2}{6} \\
+\\
+ -\frac{2}{6} & -\frac{2}{6} & \frac{4}{3} \\
+\end{array}\right]
+$
+& $+$ &
+$
+1
+\left[\begin{array}{ccc}
+ \frac{1}{2} & -\frac{1}{2} & 0 \\
+\\
+ -\frac{1}{2} & \frac{1}{2} & 0 \\
+\\
+ 0 & 0 & 0 \\
+\end{array}\right]
+$
+\\
+\\
+$
+\left[\begin{array}{ccc}
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\\
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\\
+ \frac{1}{3} & \frac{1}{3} & \frac{1}{3} \\
+\end{array}\right]
+$
+& $=$ &
+$
+\left[\begin{array}{c}
+ \frac{1}{\sqrt{3}} \\
+ \frac{1}{\sqrt{3}} \\
+ \frac{1}{\sqrt{3}} \\
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} & \frac{1}{\sqrt{3}} \\
+\end{array}\right]
+$
+\\
+\\
+$
+\left[\begin{array}{ccc}
+ \frac{1}{6} & \frac{1}{6} & -\frac{2}{6} \\
+\\
+ \frac{1}{6} & \frac{1}{6} & -\frac{2}{6} \\
+\\
+ -\frac{2}{6} & -\frac{2}{6} & \frac{4}{3} \\
+\end{array}\right]
+$
+& $=$ &
+$
+\left[\begin{array}{c}
+ \frac{1}{\sqrt{6}} \\
+ \frac{1}{\sqrt{6}} \\
+ -\frac{2}{\sqrt{6}} \\
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ \frac{1}{\sqrt{6}} & \frac{1}{\sqrt{6}} & -\frac{2}{\sqrt{6}} \\
+\end{array}\right]
+$
+\\
+\\
+$
+\left[\begin{array}{ccc}
+ \frac{1}{2} & -\frac{1}{2} & 0 \\
+\\
+ -\frac{1}{2} & \frac{1}{2} & 0 \\
+\\
+ 0 & 0 & 0 \\
+\end{array}\right]
+$
+& $=$ &
+$
+\left[\begin{array}{c}
+ -\frac{1}{\sqrt{2}} \\
+ \frac{1}{\sqrt{2}} \\
+ 0 \\
+\end{array}\right]
+$
+& $\times$ &
+$
+\left[\begin{array}{ccc}
+ -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0 \\
+\end{array}\right]
+$
+\end{tabular}
+
+%%=================================================================
+\subsection{MCO for eigenvalues}
+
+In 3d, it's difficult to extract the cubic roots from the characteristic
+polynomia. The difficulties disappear when we find one of the three roots.
+A planar regression allows us to reach the equation of the plane. From the
+equation, we can determine its normal vector $\bm{w}$. It satisfies the
+following equation $A\bm{w} = \lambda_3\bm{w}$. Thus we know $\lambda_3$.
+By the way, as far as $trace(A) = \lambda_1 + \lambda_2 + \lambda_3$ and
+$det(A) = \lambda_1 \lambda_2 \lambda_3$, then we can access to the value of
+the two others eigenvalues (just solve $\lambda^2 - (trace(A) - \lambda_3)
+\lambda + \frac{det(A)}{\lambda_3} = 0$). The knowledge of $\lambda_1$ and
+$\lambda_2$ let us find $\bm{u}$ and $\bm{v}$ by the equations $A\bm{u} =
+\lambda_1\bm{u}$ and $A\bm{v} = \lambda_2\bm{v}$.
+
+Let's center the points by susbtracting their center of mass. Now, we have
+three equivalent ways to estimate the coefficients of the plane:
+\begin{itemize}
+ \item if not $c = 0$, then $\frac{a}{c}x + \frac{b}{c}y + z = 0$,
+ \item if not $b = 0$, then $\frac{a}{b}x + y + \frac{c}{b}z = 0$,
+ \item if not $a = 0$, then $x + \frac{b}{a}y + \frac{c}{a}z = 0$.
+\end{itemize}
+As we cannot decide which way is the best, may be we have to test the three
+ones.
+
+Let's choose the linear model of the major inertia plane
+($ax + by + cz + d = 0$). With not $c = 0$.
+
+\begin{tabular}{lcl}
+$\bm{y}$ & $=$ &
+$\left[\begin{array}{c}
+ z_1 \\
+ \vdots \\
+ z_r \\
+\end{array}\right]$
+\\
+\\
+$\bm{\theta}$ & $=$ &
+$\left[\begin{array}{c}
+ a \\
+ b \\
+ d \\
+\end{array}\right]$
+\\
+\\
+$J$ & $=$ &
+$\left[\begin{array}{ccc}
+ x_1 & y_1 & 1 \\
+ \vdots & \vdots & \vdots\\
+ x_r & y_r & 1\\
+\end{array}\right]$
+\\
+\\
+$W$ & $=$ &
+$\left[\begin{array}{ccc}
+ 1 & \ldots & 0 \\
+ \vdots & \ddots & \vdots\\
+ 0 & \ldots & 1\\
+\end{array}\right]$
+\\
+\\
+$\chi(\bm{\theta})^2$ & $=$ &
+$(J\theta - \bm{y})^t W (J\theta - \bm{y})$
+\\
+\\
+$grad \chi(\bm{\theta})^2$ & $=$ &
+$2J^tWJ\bm{\theta} - 2J^tW\bm{y}$
+\\
+\\
+$\bm{\theta_{min}}$ & $=$ &
+$(J^tWJ)^{-1} J^tWy$
+\end{tabular}
+
+\end{document}
--
1.5.6.5
1
0
09 Sep '09
* green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
(test_integration) : Manage conversion between rgb and vector.
---
trunk/milena/sandbox/ChangeLog | 7 +
.../tests/accu/stat/histo3d_rgb/histo3d_rgb.cc | 175 +++++++++++++++-----
2 files changed, 144 insertions(+), 38 deletions(-)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index bbcb95c..5a96357 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-09 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix bugs an compilation problem on histo3d_rgb source code.
+
+ * green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+ (test_integration) : Manage conversion between rgb and vector.
+
2009-09-07 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Work with histogram as image 3d on rgb color space.
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
index b2af06e..37645ef 100644
--- a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
@@ -37,6 +37,7 @@
#include <mln/morpho/elementary/dilation.hh>
#include <mln/morpho/elementary/closing.hh>
+#include <mln/literal/zero.hh>
#include <mln/linear/convolve.hh>
#include <mln/linear/gaussian.hh>
#include <mln/labeling/regional_maxima.hh>
@@ -171,7 +172,7 @@ void test_take_other()
std::cout << "(" << n << " bits) histo.take(other) : ok" << std::endl;
}
-double count_histo(mln::image3d<unsigned> img)
+double count_histo(const mln::image3d<unsigned>& img)
{
mln_precondition(img.is_valid());
@@ -184,42 +185,53 @@ double count_histo(mln::image3d<unsigned> img)
return result;
}
-mln::algebra::vec<3,float> mean_histo(mln::image3d<unsigned> img)
+mln::algebra::vec<3,float> conv(const mln::algebra::vec<3,float>& vec)
+{
+ mln::algebra::vec<3,float> result;
+
+ result[0] = vec[2];
+ result[1] = vec[0];
+ result[2] = vec[1];
+
+ return result;
+}
+
+mln::algebra::vec<3,float> mean_histo(const mln::image3d<unsigned>& img)
{
mln_precondition(img.is_valid());
-
+ typedef mln::algebra::vec<3,float> vec3f;
double count = 0.0;
- double sum0 = 0.0;
- double sum1 = 0.0;
- double sum2 = 0.0;
- mln::algebra::vec<3,float> result;
+ vec3f sum = mln::literal::zero;
+ vec3f result;
mln_piter_(mln::image3d<unsigned>) p(img.domain());
for_all(p)
{
+ /*
+ std::cout << "(1) " << p << std::endl;
+ std::cout << "(2) " << (vec3f)p << std::endl;
+ std::cout << "(3) " << conv((vec3f)p) << std::endl;
+ */
count += img(p);
- sum0 += p[0] * img(p);
- sum1 += p[1] * img(p);
- sum2 += p[2] * img(p);
+ sum += conv((vec3f)p) * img(p);
}
- result[0] = sum0/count;
- result[1] = sum1/count;
- result[2] = sum2/count;
+ result = sum / count;
return result;
}
-double var_histo(mln::image3d<unsigned> img)
+double var_histo(const mln::image3d<unsigned>& img)
{
mln_precondition(img.is_valid());
-
- double count = 0.0;
- double sum = 0.0;
- double sum2 = 0.0;
- double result = 0.0;
+ typedef mln::algebra::vec<3,float> vec3f;
+ typedef mln::algebra::mat<3,3,float> mat3f;
+ double count = 0.0;
+ double sum = 0.0;
+ double sum2 = 0.0;
+ double result = 0.0;
mln_piter_(mln::image3d<unsigned>) p(img.domain());
for_all(p)
@@ -234,31 +246,32 @@ double var_histo(mln::image3d<unsigned> img)
return result;
}
-/*
-double var_histo2(mln::image3d<unsigned> img)
+mln::algebra::mat<3,3,float> var_histo2(const mln::image3d<unsigned>& img)
{
mln_precondition(img.is_valid());
+ typedef mln::algebra::vec<3,float> vec3f;
+ typedef mln::algebra::mat<3,3,float> mat3f;
double count = count_histo(img);
- double mean = mean_histo(img);
- double result = 0.0;
+ vec3f mean = mean_histo(img);
+ vec3f point;
+ mat3f result = mln::literal::zero;
mln_piter_(mln::image3d<unsigned>) p(img.domain());
for_all(p)
{
- result += img(p) * (p[0] - mean) * (p[0] - mean);
+ point = conv((vec3f)p) - mean;
+ result += img(p) * (point * point.t());
}
result /= count;
return result;
}
-*/
+
template <unsigned n>
void test_integration()
{
- // mln::trace::quiet = false;
-
typedef mln::value::rgb8 rgb8;
typedef mln::value::rgb<n> rgbn;
typedef mln::algebra::vec<3,float> vec3f;
@@ -266,7 +279,7 @@ void test_integration()
typedef mln::accu::math::count<rgbn> count;
typedef mln::accu::math::sum<rgbn,vec3f> sum;
typedef mln::accu::stat::mean<rgbn,vec3f,vec3f> mean;
- typedef mln::accu::stat::var<rgbn> var;
+ typedef mln::accu::stat::var<vec3f> var;
mln::image2d<rgb8> img_fst;
mln::image2d<rgbn> img_ref;
@@ -274,40 +287,126 @@ void test_integration()
mln::io::ppm::load(img_fst, OLENA_IMG_PATH"/lena.ppm");
img_ref = mln::data::transform(img_fst, mln::fun::v2v::rgb8_to_rgbn<n>());
- // CF COMPATIBILITE DES ACCU AVEC LE RGB
-
const double count_ref = mln::data::compute(count(), img_ref);
const vec3f sum_ref = mln::data::compute(sum(), img_ref);
const vec3f mean_ref = mln::data::compute(mean(), img_ref);
- // const mat3f var_ref = mln::data::compute(var(), img_ref);
-
+ const mat3f var_ref = mln::data::compute(var(), img_ref);
img_res = mln::data::compute(mln::accu::stat::histo3d_rgb<rgbn>(), img_ref);
const double count_res = count_histo(img_res);
const vec3f mean_res = mean_histo(img_res);
-
- //const double var_res = var_histo(img_res);
+ const mat3f var_res = var_histo2(img_res);
+
+ std::cout << "count_ref : " << count_ref << std::endl;
+ std::cout << "mean_ref : " << mean_ref << std::endl;
+ std::cout << "var_ref : " << var_ref << std::endl;
+
+ std::cout << "count_res : " << count_res << std::endl;
+ std::cout << "mean_res : " << mean_res << std::endl;
+ std::cout << "var_res : " << var_res << std::endl;
+
mln_assertion(count_ref == count_res);
- mln_assertion( mean_ref == mean_res );
- //mln_assertion(0.0001 > abs(var_ref - var_res));
+
+ mln_assertion(0.0001 > abs(mean_ref[0] - mean_res[0]));
+ mln_assertion(0.0001 > abs(mean_ref[1] - mean_res[1]));
+ mln_assertion(0.0001 > abs(mean_ref[2] - mean_res[2]));
+
+ mln_assertion(0.0001 > abs(var_ref(0,0) - var_res(0,0)));
+ mln_assertion(0.0001 > abs(var_ref(0,1) - var_res(0,1)));
+ mln_assertion(0.0001 > abs(var_ref(1,0) - var_res(1,0)));
+
+ mln_assertion(0.0001 > abs(var_ref(1,1) - var_res(1,1)));
+ mln_assertion(0.0001 > abs(var_ref(0,2) - var_res(0,2)));
+ mln_assertion(0.0001 > abs(var_ref(2,0) - var_res(2,0)));
+
+
+ mln_assertion(0.0001 > abs(var_ref(2,2) - var_res(2,2)));
+ mln_assertion(0.0001 > abs(var_ref(2,1) - var_res(2,1)));
+ mln_assertion(0.0001 > abs(var_ref(1,2) - var_res(1,2)));
std::cout << "(" << n << " bits) test integration : ok" << std::endl;
}
int main()
{
-
-
+ //
+ // Doesn't work with 1 bit, compilation problem
+ //
+
+ /*
+ test_operator_equal<1>();
+ test_instantiation_without_argument<1>();
+ test_initialization<1>();
+ test_take_argument<1>();
+ test_take_other<1>();
+ test_integration<1>();
+ */
+
+ test_operator_equal<2>();
+ test_instantiation_without_argument<2>();
+ test_initialization<2>();
+ test_take_argument<2>();
+ test_take_other<2>();
+ test_integration<2>();
+
+ /*
test_operator_equal<3>();
test_instantiation_without_argument<3>();
test_initialization<3>();
test_take_argument<3>();
test_take_other<3>();
test_integration<3>();
+
+
+
+ test_operator_equal<4>();
+ test_instantiation_without_argument<4>();
+ test_initialization<4>();
+ test_take_argument<4>();
+ test_take_other<4>();
+ test_integration<4>();
+
+
+ test_operator_equal<5>();
+ test_instantiation_without_argument<5>();
+ test_initialization<5>();
+ test_take_argument<5>();
+ test_take_other<5>();
+ test_integration<5>();
+
+ test_operator_equal<6>();
+ test_instantiation_without_argument<6>();
+ test_initialization<6>();
+ test_take_argument<6>();
+ test_take_other<6>();
+ test_integration<6>();
+ */
+ /*
+ test_operator_equal<7>();
+ test_instantiation_without_argument<7>();
+ test_initialization<7>();
+ test_take_argument<7>();
+ test_take_other<7>();
+ test_integration<7>();
+ */
+
+ //
+ // Do not execute it, unless you have the time :)
+ //
+
+ /*
+ test_operator_equal<8>();
+ test_instantiation_without_argument<8>();
+ test_initialization<8>();
+ test_take_argument<8>();
+ test_take_other<8>();
+ test_integration<8>();
+ */
+
// p2p/fold+transform_domain for hcv
--
1.5.6.5
1
0
* gluit/Makefile.am,
* libsrc/Makefile.am: Add extra LD_FLAGS.
---
external/trimesh/ChangeLog | 7 +++++++
external/trimesh/gluit/Makefile.am | 1 +
external/trimesh/libsrc/Makefile.am | 1 +
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/external/trimesh/ChangeLog b/external/trimesh/ChangeLog
index cae27a2..0f1a80f 100644
--- a/external/trimesh/ChangeLog
+++ b/external/trimesh/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-09 Guillaume Lazzara <guillaume.lazzara(a)epita.fr>
+
+ Add extra LD_FLAGS in Trimesh.
+
+ * gluit/Makefile.am,
+ * libsrc/Makefile.am: Add extra LD_FLAGS.
+
2009-06-16 Guillaume Lazzara <guillaume.lazzara(a)epita.fr>
* utilsrc/mesh_shade.cc: fix compilation issues with ICC 10 and 11.
diff --git a/external/trimesh/gluit/Makefile.am b/external/trimesh/gluit/Makefile.am
index 3944737..bc336c2 100644
--- a/external/trimesh/gluit/Makefile.am
+++ b/external/trimesh/gluit/Makefile.am
@@ -20,6 +20,7 @@
# Find config.h.
AM_CPPFLAGS = -I$(top_builddir)
AM_CPPFLAGS += -I$(top_srcdir)/include -I$(top_srcdir)/include/GL
+AM_LDFLAGS = -lGL -lGLU -lX11
lib_LTLIBRARIES = libgluit.la
diff --git a/external/trimesh/libsrc/Makefile.am b/external/trimesh/libsrc/Makefile.am
index 3a22f80..36e72b4 100644
--- a/external/trimesh/libsrc/Makefile.am
+++ b/external/trimesh/libsrc/Makefile.am
@@ -18,6 +18,7 @@
## Process this file through Automake to produce Makefile.in.
AM_CPPFLAGS = -I$(top_srcdir)/include
+AM_LDFLAGS = -lGL -lGLU
# FIXME: We should use Libtool instead.
lib_LTLIBRARIES = libtrimesh.la
--
1.5.6.5
1
0
4450: tools/pretty_check.sh: Fix issues caused by an empty CXX variable.
by Guillaume Lazzara 09 Sep '09
by Guillaume Lazzara 09 Sep '09
09 Sep '09
---
milena/ChangeLog | 4 ++++
milena/tests/tools/pretty_check.sh | 6 +++++-
2 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 4bbe8e2..a37e832 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-08 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ * tools/pretty_check.sh: Fix issues caused by an empty CXX variable.
+
2009-09-08 Roland Levillain <roland(a)lrde.epita.fr>
Morphological operators on graphs (using 1-complexes).
diff --git a/milena/tests/tools/pretty_check.sh b/milena/tests/tools/pretty_check.sh
index febea51..1479675 100755
--- a/milena/tests/tools/pretty_check.sh
+++ b/milena/tests/tools/pretty_check.sh
@@ -89,7 +89,11 @@ if [ -z "$base_make_path" ]; then
fi
if [ -z "$TEST_CXX" ]; then
- TEST_CXX="$CXX"
+ if [ -z "$CXX" ]; then
+ TEST_CXX="g++"
+ else
+ TEST_CXX="$CXX"
+ fi
fi
gcc_wrapper="$PWD/$output_directory/gcc-wrapper.sh"
--
1.5.6.5
1
0
---
trunk/milena/sandbox/ChangeLog | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index 0da6ae7..bbcb95c 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -21,7 +21,7 @@
Make some test on 14 bits grayscale image.
* green/mln/accu/stat/histo1d/histo1d.hh : Improve documentation.
- * green/tests/accu/stat/histo1d/histo1d.cc
+ * green/tests/accu/stat/histo1d/histo1d.cc
(test_14bits_classifying) : Test gausian filtering.
* green/mln/io/plot/save_histo_sh.hh : Test new gnuplot style.
--
1.5.6.5
1
0
* green/tests/accu/stat/histo3d_rgb : New directory.
* green/tests/accu/stat/histo3d_rgb/Makefile.am : New makefile.
* green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc : New unitary tests.
* green/mln/accu/stat/histo3d_rgb/histo3d_rgb.hh : New library code.
* green/mln/fun/v2v/rgb8_to_rgbn.hh : New converting fun.
---
trunk/milena/sandbox/ChangeLog | 18 +
.../sandbox/green/mln/accu/stat/histo3d_rgb.hh | 330 ++++++++++++++++++++
.../sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh | 82 +++++
.../green/tests/accu/stat/histo3d_rgb/Makefile.am | 148 +++++++++
.../tests/accu/stat/histo3d_rgb/histo3d_rgb.cc | 315 +++++++++++++++++++
5 files changed, 893 insertions(+), 0 deletions(-)
create mode 100644 trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
create mode 100644 trunk/milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
create mode 100644 trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/Makefile.am
create mode 100644 trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
diff --git a/trunk/milena/sandbox/ChangeLog b/trunk/milena/sandbox/ChangeLog
index 584044a..0da6ae7 100644
--- a/trunk/milena/sandbox/ChangeLog
+++ b/trunk/milena/sandbox/ChangeLog
@@ -1,5 +1,23 @@
2009-09-07 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Work with histogram as image 3d on rgb color space.
+
+ * green/tests/accu/stat/histo3d_rgb : New directory.
+ * green/tests/accu/stat/histo3d_rgb/Makefile.am : New makefile.
+ * green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc : New unitary tests.
+ * green/mln/accu/stat/histo3d_rgb/histo3d_rgb.hh : New library code.
+ * green/mln/fun/v2v/rgb8_to_rgbn.hh : New converting fun.
+
+2009-09-07 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Prepare unitary test with histogram 2d.
+
+ * green/tests/accu/stat/histo2d : New directory.
+ * green/tests/accu/stat/histo2d/Makefile.am : New makefile.
+ * green/tests/accu/stat/histo2d/gaussian2d.sh : New calibrating tool.
+
+2009-09-07 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Make some test on 14 bits grayscale image.
* green/mln/accu/stat/histo1d/histo1d.hh : Improve documentation.
diff --git a/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
new file mode 100644
index 0000000..8a10c0b
--- /dev/null
+++ b/trunk/milena/sandbox/green/mln/accu/stat/histo3d_rgb.hh
@@ -0,0 +1,330 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_ACCU_STAT_HISTO3D_RGB_HH
+#define MLN_ACCU_STAT_HISTO3D_RGB_HH
+
+/// \file
+///
+/// \brief Define a histogram as an accumulator which returns an image1d .
+///
+/// This source implements the discrete histogram version. The number of beans
+/// is infer from the number of greylevels. A typical int_u8 image has got
+/// 256 bins. An int_u16 image has got 65535 bins.
+/// The following sample is a typical use of the histogram.
+///
+/// #include <mln/value/int_u8.hh>
+/// #include <mln/core/image/image1d.hh>
+/// #include <mln/core/image/image2d.hh>
+/// #include <mln/io/pgm/load.hh>
+/// #include <mln/accu/stat/histo1d.hh>
+/// #include <mln/data/compute.hh>
+/// #include <mln/io/plot/save_histo_sh.hh>
+///
+/// #define OLENA_LENA ""/usr/local/share/olena/images/lena.pgm"
+///
+/// void test()
+/// {
+/// typedef mln::value::int_u8 int_u8;
+/// mln::image2d<int_u8> img_ref;
+/// mln::image1d<unsigned> img_res;
+///
+/// mln::io::pgm::load(img_ref, OLENA_LENA);
+/// img_res = mln::data::compute(mln::accu::stat::histo1d<int_u8>(), img_ref);
+/// }
+
+
+#include <iostream>
+
+#include <mln/accu/internal/base.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/alias/point3d.hh>
+#include <mln/core/alias/box3d.hh>
+
+#include <mln/trait/value/comp.hh>
+
+#include <mln/arith/plus.hh>
+
+#include <mln/trace/entering.hh>
+#include <mln/trace/exiting.hh>
+
+#include <mln/value/ops.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ // Forward declaration
+ template <typename V>
+ struct histo3d_rgb;
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+
+ namespace trait
+ {
+
+ template <typename V>
+ struct accumulator_< mln::accu::stat::histo3d_rgb<V> >
+ {
+ typedef accumulator::has_untake::no has_untake;
+ typedef accumulator::has_set_value::no has_set_value;
+ typedef accumulator::has_stop::no has_stop;
+ typedef accumulator::when_pix::use_v when_pix;
+ };
+
+ template <typename V>
+ struct set_precise_binary_<op::eq,
+ accu::stat::histo3d_rgb<V>,
+ accu::stat::histo3d_rgb<V> >
+ {
+ typedef bool ret;
+ };
+
+ } // end of namespace mln::trait
+
+ namespace accu
+ {
+
+ namespace stat
+ {
+
+ /// \brief Define an histogram which returns an image1d .
+ ///
+ /// Param V defines the space in which we count the values.
+ /// For instance, this histogram works image2d<int_u8> or
+ /// image1d<int_u16>. The histogram count the occurrence of each value.
+ /// The number of bins depends of the greyscale values, for 8 bits there
+ /// is 256 bins, for 16 bits there is 65536 bins. Note that over
+ /// quantification works too.
+ ///
+ /// \ingroup modaccuvalues
+
+ template <typename V>
+ struct histo3d_rgb :
+ public mln::accu::internal::base<image3d<unsigned>, histo3d_rgb<V> >
+ {
+ typedef V argument;
+ typedef image3d<unsigned> result;
+ typedef result q_result;
+
+ /// Constructors
+ /// \{
+ /// \brief Initialize the size of the resulting image1d.
+ ///
+ /// Initialize the size the resulting image from the theorical dynamic
+ /// of the greylevel values (Use V to manage it).
+ histo3d_rgb();
+ /// \}
+
+
+ /// Manipulators.
+ /// \{
+ /// \brief Initialize the histogram with zero value.
+ ///
+ /// This method must be called just before starting the use of the
+ /// histogram. If it's not, resulting values won't converge to the
+ /// density.
+ void init();
+
+
+ /// \brief Update the histogram with the RGB pixel t.
+ /// \param[in] t a greylevel pixel of type V.
+ ///
+ /// The end user shouldn't call this method. In place of it, he can
+ /// go through the data compute interface.
+ void take(const argument& t);
+
+
+ /// \brief Update the histogram with an other histogram.
+ /// \param[in] other the other histogram.
+ void take(const histo3d_rgb<V>& other);
+ /// \}
+
+ /// Accessors.
+ /// \{
+ /// \brief Return the histogram as an image1d.
+ ///
+ /// This is the machinery to communicate with data compute interface.
+ /// The end user should'nt use it.
+ result to_result() const;
+ operator result () const;
+ /// \}
+
+ /// \brief Check whethever this accumulator is able to return a result.
+ ///
+ /// Depends if the resulting image1d is valid. We can assume it is quite
+ /// always the case.
+ bool is_valid() const;
+
+ protected:
+ result count_;
+ };
+
+ /// \brief Check wethever an histogram is equal to an other one.
+ /// \param[in] histo1 the first histogram to compare with.
+ /// \param[in] histo2 the second histogram.
+ ///
+ /// The operator compare all the bins from the two histogram.
+
+ template <typename V>
+ bool operator==(const histo3d_rgb<V>& histo1,
+ const histo3d_rgb<V>& histo2);
+
+#ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ histo3d_rgb<V>::histo3d_rgb()
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::histo3d_rgb");
+ typedef mln_trait_value_comp(V,0) comp0;
+ typedef mln_trait_value_comp(V,1) comp1;
+ typedef mln_trait_value_comp(V,2) comp2;
+
+ // comp keep a trace of the dimension of the theorical image.
+ // mln_min(comp) --> 0
+ // mln_max(comp) --> 2^(n-1) [127 for n=7][255 for n=8] ...
+
+ count_.init_(box3d(point3d(mln_min(comp0),
+ mln_min(comp1),
+ mln_min(comp2)),
+ point3d(mln_max(comp0),
+ mln_max(comp1),
+ mln_max(comp2))));
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::histo3d_rgb");
+ }
+
+ template <typename V>
+ inline
+ void histo3d_rgb<V>::init()
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::init");
+
+ data::fill(count_, 0);
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::init");
+ }
+
+ template <typename V>
+ inline
+ void histo3d_rgb<V>::take(const argument& t)
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::take");
+
+ // Just convert a greyscale value (int_u8 like) to a position for an
+ // iterator on the resulting image.
+ ++count_(point3d(t.red(), t.green(), t.blue()));
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::take");
+ }
+
+
+ template <typename V>
+ inline
+ void histo3d_rgb<V>::take(const histo3d_rgb<V>& other)
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::take");
+
+ count_ += other.count_;
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::take");
+ }
+
+ template <typename V>
+ inline
+ typename histo3d_rgb<V>::result histo3d_rgb<V>::to_result() const
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::to_result");
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::to_result");
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ histo3d_rgb<V>::operator result() const
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::operator result");
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::operator result");
+ return count_;
+ }
+
+ template <typename V>
+ inline
+ bool histo3d_rgb<V>::is_valid() const
+ {
+ trace::entering("mln::accu::stat::histo3d_rgb<V>::is_valid");
+ bool result = count_.is_valid();
+
+ trace::exiting("mln::accu::stat::histo3d_rgb<V>::is_valid");
+ return result;
+ }
+
+ template <typename V>
+ bool operator==(const histo3d_rgb<V>& histo1,
+ const histo3d_rgb<V>& histo2)
+ {
+ trace::entering("mln::accu::stat::operator==");
+
+ bool result = true;
+ const image3d<unsigned>& res1 = histo1.to_result();
+ const image3d<unsigned>& res2 = histo2.to_result();
+
+ mln_precondition(res1.is_valid());
+ mln_precondition(res2.is_valid());
+
+ mln_piter(image3d<unsigned>) p1(res1.domain());
+ mln_piter(image3d<unsigned>) p2(res2.domain());
+
+ for_all_2(p1, p2)
+ result &= (res1(p1) == res2(p2));
+
+ trace::exiting("mln::accu::stat::operator==");
+ return result;
+ }
+
+#endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::accu::stat
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+#endif // ! MLN_ACCU_STAT_HISTO3D_RGB_HH
diff --git a/trunk/milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh b/trunk/milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
new file mode 100644
index 0000000..b40ca5b
--- /dev/null
+++ b/trunk/milena/sandbox/green/mln/fun/v2v/rgb8_to_rgbn.hh
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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_FUN_V2V_RGB8_TO_RGBN_HH
+#define MLN_FUN_V2V_RGB8_TO_RGBN_HH
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+#include <mln/core/contract.hh>
+
+/// \file
+///
+/// \brief Convert rgb8 value to rgbn, n < 8.
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2v
+ {
+
+ /// \brief Convert rgb8 value to rgbn, n < 8.
+ ///
+ /// \ingroup modfunv2v
+
+ template <unsigned n>
+ struct rgb8_to_rgbn : Function_v2v< rgb8_to_rgbn<n> >
+ {
+ typedef value::rgb8 argument;
+ typedef value::rgb<n> result;
+
+ result operator()(const argument& c) const
+ {
+ mln_precondition(8 > n);
+
+ unsigned size = pow(2,(8-n));
+ /*
+ std::cout << "c : " << c << std::endl;
+ std::cout << "red : " << c.red() << std::endl;
+ std::cout << "size : " << size << std::endl;
+ std::cout << "res : " << (c.red() / size) << std::endl;
+ std::cout << "max : " << (mln_max(mln::value::int_u<n>)) << std::endl;
+ */
+ result res(c.red() / size, c.green() / size, c.blue() / size);
+
+ return res;
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif // ! MLN_FUN_V2V_RGB8_TO_RGBN_HH
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/Makefile.am b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/Makefile.am
new file mode 100644
index 0000000..d970989
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/Makefile.am
@@ -0,0 +1,148 @@
+#
+# Generic Makefile
+#
+
+#########
+# TOOLS #
+#########
+
+INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
+CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
+ECHO= echo
+RM= rm
+MKDIR= mkdir -p
+CP= cp
+
+SOURCE_PATTERN= green/tests
+BUILD__PATTERN= green/build/tests
+
+
+ifeq ($(findstring $(BUILD__PATTERN),$(PWD)), $(BUILD__PATTERN))
+# Case where make is done from build directory.
+SOURCE_DIR= $(subst $(BUILD__PATTERN),$(SOURCE_PATTERN),$(PWD))
+BUILD__DIR= $(PWD)
+else
+# Case where make is done from source directory.
+SOURCE_DIR= $(PWD)
+BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
+endif
+
+SRC= $(notdir $(wildcard $(SOURCE_DIR)/*.cc))
+OLD= $(notdir $(wildcard $(SOURCE_DIR)/*~))
+OBJ= $(patsubst %.cc,%.o,$(SRC))
+SOURCE_MAKEFILE=Makefile.am
+BUILD__MAKEFILE=Makefile
+TARGET_FILE= $(notdir $(PWD))
+SOURCE_FILES= $(notdir $(wildcard $(SOURCE_DIR)/*.*))
+BUILD__FILES= $(filter-out $(SRC) $(SOURCE_MAKEFILE), $(SOURCE_FILES))
+
+BUILD__F_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__FILES))
+SOURCE_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_FILES))
+
+BUILD__M_PATH= $(addprefix $(BUILD__DIR)/,$(BUILD__MAKEFILE))
+SOURCE_M_PATH= $(addprefix $(SOURCE_DIR)/,$(SOURCE_MAKEFILE))
+
+TARGET_F_PATH= $(addprefix $(BUILD__DIR)/,$(TARGET_FILE))
+OBJ_F_PATH= $(addprefix $(BUILD__DIR)/,$(OBJ))
+SRC_F_PATH= $(addprefix $(SOURCE_DIR)/,$(SRC))
+OLD_F_PATH= $(addprefix $(SOURCE_DIR)/,$(OLD))
+
+#############
+# BOOTSTRAP #
+#############
+
+
+bootstrap: $(BUILD__DIR) $(BUILD__F_PATH) $(BUILD__M_PATH)
+
+# Create, if nessary, the destination directory
+$(BUILD__DIR):
+ $(MKDIR) $(BUILD__DIR)
+
+# Copy, if nessary, all the files, except the Makefile.am
+$(BUILD__F_PATH): $(SOURCE_F_PATH)
+ $(CP) $(addprefix $(SOURCE_DIR)/,$(@F)) $@
+
+# Copy if nessary, the Makefile.am into Makefile
+$(BUILD__M_PATH): $(SOURCE_M_PATH)
+ $(CP) $(SOURCE_M_PATH) $(BUILD__M_PATH)
+
+
+#######
+# ALL #
+#######
+
+# We assume that the call is done from the build directory.
+# With the directive vpath, hidden files are found in the source directory.
+
+all: $(TARGET_F_PATH)
+
+
+$(TARGET_F_PATH): $(OBJ_F_PATH)
+ $(LINK.cc) $< $(LOADLIBES) $(LDLIBS) -o $@
+
+$(OBJ_F_PATH):$(SRC_F_PATH)
+ $(COMPILE.cc) $(OUTPUT_OPTION) $<
+
+
+#########
+# CLEAN #
+#########
+
+# Force every time the deletion
+clean: clean_target clean_obj clean_dst clean_old #clean_make
+
+
+clean_target:
+ -@$(RM) $(TARGET_F_PATH) &> /dev/null
+
+clean_obj:
+ -@$(RM) $(OBJ_F_PATH) &> /dev/null
+
+clean_dst:
+ -@$(RM) $(BUILD_F_PATH) &> /dev/null
+
+clean_make:
+ -@$(RM) $(BUILD_M_PATH) &> /dev/null
+
+clean_old:
+ -@$(RM) $(OLD_F_PATH) &> /dev/null
+
+
+#########
+# PRINT #
+#########
+
+print: print_tools print_bootstrap
+
+print_tools:
+ @$(ECHO) "HOME = $(HOME)"
+ @$(ECHO) "INCLUDES = $(INCLUDES)"
+ @$(ECHO) "CXXFLAGS = $(CXXFLAGS)"
+ @$(ECHO) "ECHO = $(ECHO)"
+ @$(ECHO) "RM = $(RM)"
+ @$(ECHO) "MKDIR = $(MKDIR)"
+ @$(ECHO) "CP = $(CP)"
+ @$(ECHO)
+
+print_bootstrap:
+ @$(ECHO) "PWD = $(PWD)"
+ @$(ECHO) "SOURCE_PATTERN = $(SOURCE_PATTERN)"
+ @$(ECHO) "BUILD__PATTERN = $(BUILD__PATTERN)"
+ @$(ECHO) "SOURCE_DIR = $(SOURCE_DIR)"
+ @$(ECHO) "BUILD__DIR = $(BUILD__DIR)"
+ @$(ECHO) "SOURCE_MAKEFILE = $(SOURCE_MAKEFILE)"
+ @$(ECHO) "BUILD__MAKEFILE = $(BUILD__MAKEFILE)"
+ @$(ECHO) "TARGET_FILE = $(TARGET_FILE)"
+ @$(ECHO) "SOURCE_FILES = $(SOURCE_FILES)"
+ @$(ECHO) "SOURCE_F_PATH = $(SOURCE_F_PATH)"
+ @$(ECHO) "BUILD__FILES = $(BUILD__FILES)"
+ @$(ECHO) "BUILD__F_PATH = $(BUILD__F_PATH)"
+ @$(ECHO) "BUILD__M_PATH = $(BUILD__M_PATH)"
+ @$(ECHO) "SOURCE_M_PATH = $(SOURCE_M_PATH)"
+ @$(ECHO) "SRC = $(SRC)"
+ @$(ECHO) "OBJ = $(OBJ)"
+ @$(ECHO) "OLD = $(OLD)"
+ @$(ECHO) "SRC_F_PATH = $(SRC_F_PATH)"
+ @$(ECHO) "OBJ_F_PATH = $(OBJ_F_PATH)"
+ @$(ECHO) "OLD_F_PATH = $(OLD_F_PATH)"
+ @$(ECHO)
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
new file mode 100644
index 0000000..b2af06e
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo3d_rgb/histo3d_rgb.cc
@@ -0,0 +1,315 @@
+/// TEST HISTO3D_RGB
+
+#include <mln/img_path.hh>
+
+#include <mln/io/plot/save_histo_sh.hh>
+#include <mln/accu/stat/histo3d_rgb.hh>
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+#include <mln/io/plot/save.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/transform.hh>
+#include <mln/data/fill.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+#include <mln/value/int_u.hh>
+
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/alias/box3d.hh>
+#include <mln/core/alias/point3d.hh>
+
+#include <mln/core/routine/initialize.hh>
+#include <mln/core/contract.hh>
+#include <mln/core/grids.hh>
+
+#include <mln/accu/math/sum.hh>
+#include <mln/accu/math/count.hh>
+#include <mln/accu/stat/mean.hh>
+#include <mln/accu/stat/variance.hh>
+#include <mln/accu/stat/var.hh>
+
+#include <mln/morpho/watershed/flooding.hh>
+#include <mln/morpho/elementary/dilation.hh>
+#include <mln/morpho/elementary/closing.hh>
+
+#include <mln/linear/convolve.hh>
+#include <mln/linear/gaussian.hh>
+#include <mln/labeling/regional_maxima.hh>
+#include <mln/labeling/colorize.hh>
+#include <mln/labeling/mean_values.hh>
+
+#include <mln/make/w_window3d.hh>
+
+#include <mln/math/sqr.hh>
+#include <mln/math/pi.hh>
+#include <mln/math/abs.hh>
+
+#include <mln/core/image/dmorph/image_if.hh>
+#include <mln/pw/value.hh>
+
+
+template <unsigned n>
+void test_operator_equal()
+{
+ using namespace mln::accu::stat;
+
+ typedef mln::value::rgb<n> rgbn;
+ mln::accu::stat::histo3d_rgb<rgbn> histo1;
+ mln::accu::stat::histo3d_rgb<rgbn> histo2;
+ rgbn val(3,3,3);
+
+ histo1.init();
+ histo2.init();
+
+ mln_assertion(histo1 == histo2);
+
+ histo1.take(val);
+
+ /// FIXME mln_assertion(histo1 != histo2); doesn't work!!
+ mln_assertion(!(histo1 == histo2));
+
+ histo2.take(val);
+
+ mln_assertion(histo1 == histo2);
+
+ std::cout << "(" << n << " bits) histo == histo : ok" << std::endl;
+}
+
+template <unsigned n>
+void test_instantiation_without_argument()
+{
+ typedef mln::value::rgb<n> rgbn;
+ typedef mln_trait_value_comp(rgbn,0) comp;
+ const mln::accu::stat::histo3d_rgb<rgbn> histo;
+ const mln::image3d<unsigned>& res = histo.to_result();
+ const mln::point3d& min =mln::point3d(mln_min(comp),
+ mln_min(comp),
+ mln_min(comp));
+ const mln::point3d& max =mln::point3d(mln_max(comp),
+ mln_max(comp),
+ mln_max(comp));
+ const mln::box3d& ref = mln::box3d(min, max);
+
+ mln_assertion(ref == res.domain());
+ mln_assertion(res.is_valid());
+
+ std::cout << "(" << n << " bits) histo<T> histo : ok" << std::endl;
+}
+
+template <unsigned n>
+void test_initialization()
+{
+ typedef mln::value::int_u<n> int_un;
+ typedef mln::value::rgb<n> rgbn;
+ mln::accu::stat::histo3d_rgb<rgbn> histo;
+ mln::image3d<unsigned> img_res = histo.to_result();
+ mln::image3d<unsigned> img_ref;
+
+ mln::initialize(img_ref, img_res);
+ mln::data::fill(img_ref, 0);
+ histo.init();
+
+ unsigned res = mln::data::compute(mln::accu::math::sum<int_un>(), img_res);
+ unsigned ref = mln::data::compute(mln::accu::math::sum<int_un>(), img_ref);
+
+ mln_assertion(ref == res);
+
+ std::cout << "(" << n << " bits) histo.init() : ok" << std::endl;
+}
+
+template <unsigned n>
+void test_take_argument()
+{
+ typedef mln::value::int_u<n> int_un;
+ typedef mln::value::rgb<n> rgbn;
+ mln::accu::stat::histo3d_rgb<rgbn> histo1;
+ mln::accu::stat::histo3d_rgb<rgbn> histo2;
+ rgbn val(3,3,3);
+
+ histo1.init();
+ histo2.init();
+ histo1.take(val);
+
+ const mln::image3d<unsigned> img1 = histo1.to_result();
+ const mln::image3d<unsigned> img2 = histo2.to_result();
+
+ const unsigned res = mln::data::compute(mln::accu::math::sum<int_un>(), img1);
+ const unsigned ref = mln::data::compute(mln::accu::math::sum<int_un>(), img2);
+
+ mln_assertion(ref == res-1);
+ mln_assertion(1 == img1(mln::point3d(val.red(), val.green(), val.blue())));
+
+ std::cout << "(" << n << " bits) histo.take(argument) : ok" << std::endl;
+}
+
+template <unsigned n>
+void test_take_other()
+{
+ typedef mln::value::rgb<n> rgbn;
+ mln::accu::stat::histo3d_rgb<rgbn> histo1;
+ mln::accu::stat::histo3d_rgb<rgbn> histo2;
+ mln::accu::stat::histo3d_rgb<rgbn> histo3;
+ rgbn val(3,3,3);
+
+ histo1.init();
+ histo2.init();
+ histo3.init();
+
+ histo1.take(val);
+ histo1.take(val);
+ histo3.take(val);
+ histo2.take(val);
+ histo2.take(histo3);
+
+ mln_assertion(histo1 == histo2);
+
+ std::cout << "(" << n << " bits) histo.take(other) : ok" << std::endl;
+}
+
+double count_histo(mln::image3d<unsigned> img)
+{
+ mln_precondition(img.is_valid());
+
+ double result = 0.0;
+ mln_piter_(mln::image3d<unsigned>) p(img.domain());
+
+ for_all(p)
+ result += img(p);
+
+ return result;
+}
+
+mln::algebra::vec<3,float> mean_histo(mln::image3d<unsigned> img)
+{
+ mln_precondition(img.is_valid());
+
+ double count = 0.0;
+ double sum0 = 0.0;
+ double sum1 = 0.0;
+ double sum2 = 0.0;
+ mln::algebra::vec<3,float> result;
+
+ mln_piter_(mln::image3d<unsigned>) p(img.domain());
+
+ for_all(p)
+ {
+ count += img(p);
+ sum0 += p[0] * img(p);
+ sum1 += p[1] * img(p);
+ sum2 += p[2] * img(p);
+ }
+
+ result[0] = sum0/count;
+ result[1] = sum1/count;
+ result[2] = sum2/count;
+
+ return result;
+}
+
+
+double var_histo(mln::image3d<unsigned> img)
+{
+ mln_precondition(img.is_valid());
+
+ double count = 0.0;
+ double sum = 0.0;
+ double sum2 = 0.0;
+ double result = 0.0;
+ mln_piter_(mln::image3d<unsigned>) p(img.domain());
+
+ for_all(p)
+ {
+ count += img(p);
+ sum += p[0] * img(p);
+ sum2 += p[0] * p[0] * img(p);
+ }
+
+ result = sum2 / count - (sum / count) * (sum / count);
+
+ return result;
+}
+
+/*
+double var_histo2(mln::image3d<unsigned> img)
+{
+ mln_precondition(img.is_valid());
+
+ double count = count_histo(img);
+ double mean = mean_histo(img);
+ double result = 0.0;
+ mln_piter_(mln::image3d<unsigned>) p(img.domain());
+
+ for_all(p)
+ {
+ result += img(p) * (p[0] - mean) * (p[0] - mean);
+ }
+
+ result /= count;
+
+ return result;
+}
+*/
+template <unsigned n>
+void test_integration()
+{
+ // mln::trace::quiet = false;
+
+ typedef mln::value::rgb8 rgb8;
+ typedef mln::value::rgb<n> rgbn;
+ typedef mln::algebra::vec<3,float> vec3f;
+ typedef mln::algebra::mat<3,3,float> mat3f;
+ typedef mln::accu::math::count<rgbn> count;
+ typedef mln::accu::math::sum<rgbn,vec3f> sum;
+ typedef mln::accu::stat::mean<rgbn,vec3f,vec3f> mean;
+ typedef mln::accu::stat::var<rgbn> var;
+
+ mln::image2d<rgb8> img_fst;
+ mln::image2d<rgbn> img_ref;
+ mln::image3d<unsigned> img_res;
+
+ mln::io::ppm::load(img_fst, OLENA_IMG_PATH"/lena.ppm");
+ img_ref = mln::data::transform(img_fst, mln::fun::v2v::rgb8_to_rgbn<n>());
+ // CF COMPATIBILITE DES ACCU AVEC LE RGB
+
+
+ const double count_ref = mln::data::compute(count(), img_ref);
+ const vec3f sum_ref = mln::data::compute(sum(), img_ref);
+ const vec3f mean_ref = mln::data::compute(mean(), img_ref);
+ // const mat3f var_ref = mln::data::compute(var(), img_ref);
+
+
+ img_res = mln::data::compute(mln::accu::stat::histo3d_rgb<rgbn>(), img_ref);
+
+
+ const double count_res = count_histo(img_res);
+ const vec3f mean_res = mean_histo(img_res);
+
+ //const double var_res = var_histo(img_res);
+
+ mln_assertion(count_ref == count_res);
+ mln_assertion( mean_ref == mean_res );
+ //mln_assertion(0.0001 > abs(var_ref - var_res));
+
+ std::cout << "(" << n << " bits) test integration : ok" << std::endl;
+}
+
+int main()
+{
+
+
+ test_operator_equal<3>();
+ test_instantiation_without_argument<3>();
+ test_initialization<3>();
+ test_take_argument<3>();
+ test_take_other<3>();
+ test_integration<3>();
+
+ // p2p/fold+transform_domain for hcv
+
+ return 0;
+}
--
1.5.6.5
1
0