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 2009
- 9 participants
- 188 discussions
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
* 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.
---
.../green/tests/accu/stat/histo2d/Makefile.am | 148 ++++++++++++++++++++
.../green/tests/accu/stat/histo2d/gaussian2d.sh | 21 +++
2 files changed, 169 insertions(+), 0 deletions(-)
create mode 100644 trunk/milena/sandbox/green/tests/accu/stat/histo2d/Makefile.am
create mode 100755 trunk/milena/sandbox/green/tests/accu/stat/histo2d/gaussian2d.sh
diff --git a/trunk/milena/sandbox/green/tests/accu/stat/histo2d/Makefile.am b/trunk/milena/sandbox/green/tests/accu/stat/histo2d/Makefile.am
new file mode 100644
index 0000000..d970989
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo2d/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/histo2d/gaussian2d.sh b/trunk/milena/sandbox/green/tests/accu/stat/histo2d/gaussian2d.sh
new file mode 100755
index 0000000..313fbf0
--- /dev/null
+++ b/trunk/milena/sandbox/green/tests/accu/stat/histo2d/gaussian2d.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+############
+# gaussian #
+############
+
+# support 6 sigma sur chaque axe
+
+gnuplot <<EOF
+set terminal x11 persist 1
+square(x)=x*x
+gaussian(x,mean,sigma)=exp(-0.5*square((x-mean)/sigma))/(sigma*sqrt(2*pi))
+gaussian2d(x,y,mx,my,sx,sy)=gaussian(x,mx,sx)*gaussian(y,my,sy)
+
+
+set view 50
+#set grid
+#set contour
+set isosample 20
+splot [x=-20:20][y=-20:20] gaussian2d(x,y,0,0,6,6) with line palette
+EOF
--
1.5.6.5
1
0
[PATCH 5/5] configure.ac: Configure milena/apps/graph-morpho/Makefile.
by Roland Levillain 08 Sep '09
by Roland Levillain 08 Sep '09
08 Sep '09
---
ChangeLog | 4 ++++
configure.ac | 1 +
2 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 8e7d38b..e2991df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2009-09-08 Roland Levillain <roland(a)lrde.epita.fr>
+
+ * configure.ac: Configure milena/apps/graph-morpho/Makefile.
+
2009-09-04 Roland Levillain <roland(a)lrde.epita.fr>
* configure.ac: s/statues/mesh-segm-skel/.
diff --git a/configure.ac b/configure.ac
index 30706f0..c7a2487 100644
--- a/configure.ac
+++ b/configure.ac
@@ -399,6 +399,7 @@ AM_CONDITIONAL([ENABLE_APPS], [test "x$enable_apps" = "xyes"])
AC_CONFIG_FILES([
milena/apps/Makefile
milena/apps/mesh-segm-skel/Makefile
+ milena/apps/graph-morpho/Makefile
])
# Configure tests.
--
1.6.4.2
1
0
08 Sep '09
* apps/graph-morpho/: New directory.
* apps/graph-morpho/complex1d.cc: New.
* apps/graph-morpho/Makefile.am: New.
---
milena/ChangeLog | 8 +
milena/apps/Makefile.am | 2 +-
milena/apps/{ => graph-morpho}/Makefile.am | 14 +-
milena/apps/graph-morpho/complex1d.cc | 390 ++++++++++++++++++++++++++++
4 files changed, 409 insertions(+), 5 deletions(-)
copy milena/apps/{ => graph-morpho}/Makefile.am (67%)
create mode 100644 milena/apps/graph-morpho/complex1d.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 223d040..4bbe8e2 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,11 @@
+2009-09-08 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Morphological operators on graphs (using 1-complexes).
+
+ * apps/graph-morpho/: New directory.
+ * apps/graph-morpho/complex1d.cc: New.
+ * apps/graph-morpho/Makefile.am: New.
+
2009-09-04 Roland Levillain <roland(a)lrde.epita.fr>
Adjust names w.r.t. apps/mesh-segm-skel/.
diff --git a/milena/apps/Makefile.am b/milena/apps/Makefile.am
index 3e41536..2150657 100644
--- a/milena/apps/Makefile.am
+++ b/milena/apps/Makefile.am
@@ -17,4 +17,4 @@
## Process this file through Automake to produce Makefile.in.
-SUBDIRS = mesh-segm-skel
+SUBDIRS = mesh-segm-skel graph-morpho
diff --git a/milena/apps/Makefile.am b/milena/apps/graph-morpho/Makefile.am
similarity index 67%
copy from milena/apps/Makefile.am
copy to milena/apps/graph-morpho/Makefile.am
index 3e41536..590e756 100644
--- a/milena/apps/Makefile.am
+++ b/milena/apps/graph-morpho/Makefile.am
@@ -1,4 +1,4 @@
-# Copyright (C) 2008, 2009 EPITA Research and Development Laboratory (LRDE).
+# Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE).
#
# This file is part of Olena.
#
@@ -13,8 +13,14 @@
#
# You should have received a copy of the GNU General Public License
# along with Olena. If not, see <http://www.gnu.org/licenses/>.
-#
-## Process this file through Automake to produce Makefile.in.
+# Find Milena headers.
+AM_CPPFLAGS = -I$(top_srcdir)/milena
+# Produce fast code.
+APPS_CXXFLAGS = @APPS_CXXFLAGS@
+AM_CXXFLAGS = $(APPS_CXXFLAGS)
+
+bin_PROGRAMS = complex1d
+complex1d_SOURCES = complex1d.cc
-SUBDIRS = mesh-segm-skel
+TESTS = complex1d
diff --git a/milena/apps/graph-morpho/complex1d.cc b/milena/apps/graph-morpho/complex1d.cc
new file mode 100644
index 0000000..8587040
--- /dev/null
+++ b/milena/apps/graph-morpho/complex1d.cc
@@ -0,0 +1,390 @@
+// Copyright (C) 2008, 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.
+
+/// \file
+/// \brief Morphological operators in graph space implemented on
+/// 1-complex images.
+///
+/// \todo There should be a second version of this program, where the
+/// graph structure is implemented with an actual graph.
+
+#include <mln/core/image/complex_image.hh>
+#include <mln/geom/complex_geometry.hh>
+#include <mln/core/image/complex_neighborhoods.hh>
+#include <mln/core/image/complex_neighborhood_piter.hh>
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/point2d.hh>
+#include <mln/core/alias/box2d.hh>
+
+#include <mln/core/site_set/p_set.hh>
+#include <mln/util/site_pair.hh>
+
+
+using namespace mln;
+
+// A graph is considered as a 1-complex here.
+const unsigned dim = 1;
+typedef topo::complex<dim> complex_t;
+
+// Binary graph-based image with vertices aligned on a discrete 2D grid.
+typedef point2d site_t;
+typedef geom::complex_geometry<dim, site_t> geom_t;
+typedef complex_image<dim, geom_t, bool> ima_t;
+
+// Iterator type on faces (vertices and edges).
+typedef p_n_faces_fwd_piter<dim, geom_t> face_iter;
+// Edge-to-vertices neighborhood.
+typedef complex_lower_neighborhood<dim, geom_t> e2v_t;
+const e2v_t e2v;
+// Vertex-to-edges neighborhood.
+typedef complex_higher_neighborhood<dim, geom_t> v2e_t;
+const v2e_t v2e;
+
+
+// FIXME: We should turn this routine into something much more
+// generic, and move it to the library (into make/).
+ima_t
+build_regular_complex1d_image(const box2d& support)
+{
+ unsigned nrows = support.pmax().row() - support.pmin().row() + 1;
+ unsigned ncols = support.pmax().col() - support.pmin().col() + 1;
+
+ typedef topo::n_face<0, dim> vertex_t;
+
+ complex_t c;
+ geom_t geom;
+
+ // Vertices.
+ for (unsigned row = 0; row < nrows; ++row)
+ for (unsigned col = 0; col < ncols; ++col)
+ {
+ c.add_face();
+ geom.add_location(point2d(row,col));
+ }
+
+ // Edges.
+ for (unsigned row = 0; row < nrows; ++row)
+ {
+ // Horizontal edges.
+ for (unsigned col = 1; col < ncols; ++col)
+ {
+ // First vertex.
+ vertex_t v1(c, row * ncols + col - 1);
+ // Second vertex.
+ vertex_t v2(c, row * ncols + col);
+ // Edge bewteen V1 and V2.
+ c.add_face(v1 + v2);
+ }
+
+ // Vertical edges.
+ if (row != 0)
+ for (unsigned col = 0; col < ncols; ++col)
+ {
+ // First vertex.
+ vertex_t v1(c, (row - 1) * ncols + col);
+ // Second vertex.
+ vertex_t v2(c, row * ncols + col);
+ // Edge bewteen V1 and V2.
+ c.add_face(v1 + v2);
+ }
+ }
+
+ // Site set (domain) of the image.
+ p_complex<dim, geom_t> pc(c, geom);
+
+ // Image based on this site set.
+ ima_t ima(pc);
+ return ima;
+}
+
+
+template <typename T>
+void
+println(const complex_image<dim, geom_t, T>& ima, const box2d& support)
+{
+ // These are admittedly loose preconditions, but we cannot check
+ // much.
+ mln_precondition(ima.nsites() == support.nsites());
+
+ image2d<bool> vertices(support);
+ image2d<bool> h_edges(box2d(support.pmin(), support.pmax() - dpoint2d(0, 1)));
+ image2d<bool> v_edges(box2d(support.pmin(), support.pmax() - dpoint2d(1, 0)));
+
+ // Iterator on vertices.
+ p_n_faces_fwd_piter<dim, geom_t> v(ima.domain(), 0);
+ for_all(v)
+ {
+ mln_site_(geom_t) s(v);
+ // Site S is point2d multi-site and should be a singleton (since V
+ // iterates on vertices).
+ mln_invariant(s.size() == 1);
+ point2d p = s.front();
+ vertices(p) = ima(v);
+ }
+
+ // Iterator on edges.
+ p_n_faces_fwd_piter<dim, geom_t> e(ima.domain(), 1);
+ for_all(e)
+ {
+ mln_site_(geom_t) s(e);
+ // Site S is point2d multi-site and should be a pair (since E
+ // iterates on vertices).
+ mln_invariant(s.size() == 2);
+ point2d p1 = s[0];
+ point2d p2 = s[1];
+ if (p1.row() == p2.row())
+ {
+ // Horizontal edge.
+ h_edges(p1) = ima(e);
+ }
+ else
+ {
+ // Vertical edge.
+ mln_assertion(p1.col() == p2.col());
+ v_edges(p1) = ima(e);
+ }
+ }
+
+ for (int row = vertices.domain().pmin().row();
+ row <= vertices.domain().pmax().row(); ++row)
+ {
+ for (int col = vertices.domain().pmin().col();
+ col <= vertices.domain().pmax().col(); ++col)
+ {
+ point2d p(row, col);
+ // Vertex.
+ std::cout << (vertices(p) ? "O" : ".");
+ // Potential horizontal edge on the right of the vertex.
+ if (col != vertices.domain().pmax().col())
+ std::cout << (h_edges(p) ? " - " : " ");
+ }
+ std::cout << std::endl;
+
+ // Potential vertical edge below the vertices of the current ROW.
+ if (row != vertices.domain().pmax().row())
+ for (int col = vertices.domain().pmin().col();
+ col <= vertices.domain().pmax().col(); ++col)
+ {
+ point2d p(row, col);
+ std::cout << (v_edges(p) ? "| " : " ");
+ }
+ std::cout << std::endl;
+ }
+}
+
+/*------------------------------------.
+| Morphological operators on graphs. |
+`------------------------------------*/
+
+/* FIXME: By constraining the domain of the input and passing the
+ neighborhood, one should be able to use a truly generic dilation
+ (resp. erosion), or even use Milena's standard morpho::dilation
+ (resp. morpho::erosion). */
+
+/// Dilation from edges to vertices (delta^dot).
+template <typename I>
+mln_concrete(I)
+dilation_e2v(const Image<I>& input_)
+{
+ const I& input = exact(input_);
+ mln_concrete(I) output;
+ initialize(output, input);
+ p_n_faces_fwd_piter<dim, geom_t> v(input.domain(), 0);
+ mln_niter_(v2e_t) e(v2e, v);
+ for_all(v)
+ {
+ output(v) = false;
+ for_all(e)
+ if (input(e))
+ {
+ output(v) = true;
+ break;
+ }
+ }
+ return output;
+}
+
+/// Erosion from vertices to edges (erosion^cross).
+template <typename I>
+mln_concrete(I)
+erosion_v2e(const Image<I>& input_)
+{
+ const I& input = exact(input_);
+ mln_concrete(I) output;
+ initialize(output, input);
+ p_n_faces_fwd_piter<dim, geom_t> e(input.domain(), 1);
+ mln_niter_(e2v_t) v(e2v, e);
+ for_all(e)
+ {
+ output(e) = true;
+ for_all(v)
+ if (!input(v))
+ {
+ output(e) = false;
+ break;
+ }
+ }
+ return output;
+}
+
+/// Erosion from edges to vertices (erosion^dot).
+template <typename I>
+mln_concrete(I)
+erosion_e2v(const Image<I>& input_)
+{
+ const I& input = exact(input_);
+ mln_concrete(I) output;
+ initialize(output, input);
+ p_n_faces_fwd_piter<dim, geom_t> v(input.domain(), 0);
+ mln_niter_(v2e_t) e(v2e, v);
+ for_all(v)
+ {
+ output(v) = true;
+ for_all(e)
+ if (!input(e))
+ {
+ output(v) = false;
+ break;
+ }
+ }
+ return output;
+}
+
+/// Dilation from vertices to edges (dilation^cross).
+template <typename I>
+mln_concrete(I)
+dilation_v2e(const Image<I>& input_)
+{
+ const I& input = exact(input_);
+ mln_concrete(I) output;
+ initialize(output, input);
+ p_n_faces_fwd_piter<dim, geom_t> e(input.domain(), 1);
+ mln_niter_(e2v_t) v(e2v, e);
+ for_all(e)
+ {
+ output(e) = false;
+ for_all(v)
+ if (input(v))
+ {
+ output(e) = true;
+ break;
+ }
+ }
+ return output;
+}
+
+
+int main()
+{
+ /*--------------.
+ | Input image. |
+ `--------------*/
+
+ /* Build a ``regular'' graph image. Of course, it would have been
+ better, simpler and faster to use a cubical 1-complex here, but
+ they are not yet available. */
+ 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
+ 2009 paper from Jean Cousty et al. */
+
+ // The set of vertices of the graph.
+ p_set<point2d> vertices;
+ vertices.insert(point2d(1, 2));
+ vertices.insert(point2d(2, 1));
+ vertices.insert(point2d(2, 2));
+ vertices.insert(point2d(3, 4));
+ vertices.insert(point2d(5, 2));
+ vertices.insert(point2d(5, 3));
+ vertices.insert(point2d(5, 4));
+ vertices.insert(point2d(6, 1));
+ vertices.insert(point2d(6, 2));
+ vertices.insert(point2d(6, 3));
+ vertices.insert(point2d(6, 4));
+ vertices.insert(point2d(7, 2));
+ vertices.insert(point2d(7, 3));
+ // Add vertices.
+ p_n_faces_fwd_piter<dim, geom_t> v(ima.domain(), 0);
+ for_all(v)
+ {
+ mln_site_(geom_t) s(v);
+ // Site S is point2d multi-site and should be a singleton (since V
+ // iterates on vertices).
+ mln_invariant(s.size() == 1);
+ point2d p = s.front();
+ ima(v) = vertices.has(p);
+ }
+
+ // The set of edges of the graph.
+ typedef util::site_pair<point2d> point2d_pair;
+ p_set< util::site_pair<point2d> > edges;
+ edges.insert(point2d_pair(point2d(2, 1), point2d(2, 2)));
+ edges.insert(point2d_pair(point2d(5, 3), point2d(5, 4)));
+ edges.insert(point2d_pair(point2d(5, 2), point2d(6, 2)));
+ edges.insert(point2d_pair(point2d(5, 3), point2d(6, 3)));
+ edges.insert(point2d_pair(point2d(6, 1), point2d(6, 2)));
+ edges.insert(point2d_pair(point2d(6, 2), point2d(6, 3)));
+ edges.insert(point2d_pair(point2d(6, 3), point2d(6, 4)));
+ edges.insert(point2d_pair(point2d(6, 2), point2d(7, 2)));
+ edges.insert(point2d_pair(point2d(6, 3), point2d(7, 3)));
+ edges.insert(point2d_pair(point2d(7, 2), point2d(7, 3)));
+ // Add edges.
+ p_n_faces_fwd_piter<dim, geom_t> e(ima.domain(), 1);
+ for_all(e)
+ {
+ mln_site_(geom_t) s(e);
+ // Site S is point2d multi-site and should be a pair (since E
+ // iterates on vertices).
+ mln_invariant(s.size() == 2);
+ point2d p1 = s[0];
+ point2d p2 = s[1];
+ ima(e) =
+ edges.has(point2d_pair(p1, p2)) || edges.has(point2d_pair(p2, p1));
+ }
+ std::cout << "ima:" << std::endl;
+ println(ima, b);
+
+ /*-----------------------------------.
+ | Applying morphological operators. |
+ `-----------------------------------*/
+
+ ima_t dil_e2v_ima = dilation_e2v(ima);
+ std::cout << "dil_e2v_ima:" << std::endl;
+ println(dil_e2v_ima, b);
+
+ ima_t ero_v2e_ima = erosion_v2e(ima);
+ std::cout << "ero_v2e_ima:" << std::endl;
+ println(ero_v2e_ima, b);
+
+ ima_t ero_e2v_ima = erosion_e2v(ima);
+ std::cout << "ero_e2v_ima:" << std::endl;
+ println(ero_e2v_ima, b);
+
+ ima_t dil_v2e_ima = dilation_v2e(ima);
+ std::cout << "dil_v2e_ima:" << std::endl;
+ println(dil_v2e_ima, b);
+}
--
1.6.4.2
1
0