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
* green/doc/annotating: New directory.
* green/doc/annotating/class.txt: New hierarchy description.
* green/doc/annotating/testMillet2008.txt: New result interpretations.
* green/doc/annotating/syntheseMillet2008.txt: New feature extractions.
* green/demo/annotating/class.txt: Remove this obsolete file.
---
milena/sandbox/ChangeLog | 10 +
milena/sandbox/green/demo/annotating/class.txt | 33 ---
milena/sandbox/green/doc/annotating/class.txt | 42 +++
.../green/doc/annotating/syntheseMillet2008.txt | 283 ++++++++++++++++++++
milena/sandbox/green/doc/annotating/testMillet2008 | 69 +++++
5 files changed, 404 insertions(+), 33 deletions(-)
delete mode 100644 milena/sandbox/green/demo/annotating/class.txt
create mode 100644 milena/sandbox/green/doc/annotating/class.txt
create mode 100644 milena/sandbox/green/doc/annotating/syntheseMillet2008.txt
create mode 100644 milena/sandbox/green/doc/annotating/testMillet2008
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 6435445..a096559 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -75,6 +75,16 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
+2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Group Millet2008 documentation files.
+
+ * green/doc/annotating: New directory.
+ * green/doc/annotating/class.txt: New hierarchy description.
+ * green/doc/annotating/testMillet2008.txt: New result interpretations.
+ * green/doc/annotating/syntheseMillet2008.txt: New feature extractions.
+ * green/demo/annotating/class.txt: Remove this obsolete file.
+
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Correct typo into directories.
diff --git a/milena/sandbox/green/demo/annotating/class.txt b/milena/sandbox/green/demo/annotating/class.txt
deleted file mode 100644
index ec7e92e..0000000
--- a/milena/sandbox/green/demo/annotating/class.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-Dans scribo les classes de documents sont:
-
-- image seule (photo)
-- courrier manuscrit
-- courrier dactylographié
-- facture ou feuille organisée sous forme de tableau
-- article de journal
-- document composite
-- infographie (logo, carte, dessin vectoriel)
-- slide (copie d'écran ou sauvegarde au format image)
-
-
-Où se situent les faxes ?
-
-
-Description d'un fax:
-- ratio l/L assimilable à du A4 ou US Letter
-- nombre de couleurs très petit, < 1000
-- plutôt du N & B, mais quelques faxes sont en couleurs
-- généralement un % élevé de blanc (la page vierge)
-
-
-Description d'un article de journal:
-- nombre élevés de couleurs (> 10 000) en général
-- quelques articles de conférences autour de 5000
-
-
-Description des photos:
-- un nombre très élevé de couleurs
-- ratio non A4, non US Letter
-
-
-
diff --git a/milena/sandbox/green/doc/annotating/class.txt b/milena/sandbox/green/doc/annotating/class.txt
new file mode 100644
index 0000000..0fa5cf9
--- /dev/null
+++ b/milena/sandbox/green/doc/annotating/class.txt
@@ -0,0 +1,42 @@
+Dans scribo les classes de documents sont:
+
+- image seule (photo)
+- courrier manuscrit
+- courrier dactylographié
+- facture ou feuille organisée sous forme de tableau
+- article de journal
+- document composite
+- infographie (logo, carte, dessin vectoriel)
+- slide (copie d'écran ou sauvegarde au format image)
+
+Le problème avec cette hiérarchie c'est quelle induit une connaissance
+fonctionnelle des images traitées et que les extracteurs de primitives font
+plutôt ressortir des informations relatives à la nature de l'image.
+
+Par exemple, les slides peuvent contenir aussi bien du texte, que des photos
+ou des cliparts. C'est une forme de "composite" par définition.
+
+Où se situent les faxes ?
+
+
+Description d'un fax:
+- ratio l/L assimilable à du A4 ou US Letter
+- nombre de couleurs très petit, < 1000
+- plutôt du N & B, mais quelques faxes sont en couleurs
+- généralement un % élevé de blanc (la page vierge)
+
+
+Description d'un article de journal:
+- nombre élevés de couleurs (> 10 000) en général
+- quelques articles de conférences autour de 5000
+
+
+Description des photos:
+- un nombre très élevé de couleurs
+- ratio non A4, non US Letter
+
+
+Google hiérarchie:
+- line drawing
+- clipart
+- photo
diff --git a/milena/sandbox/green/doc/annotating/syntheseMillet2008.txt b/milena/sandbox/green/doc/annotating/syntheseMillet2008.txt
new file mode 100644
index 0000000..b7b3648
--- /dev/null
+++ b/milena/sandbox/green/doc/annotating/syntheseMillet2008.txt
@@ -0,0 +1,283 @@
+
+Millet utilise un certain nombre de descripteurs (p 65, Chapitre 3)
+pour l'annotation automatique. Son objectif est de formuler une
+annotation automatique simple à partir de descripteurs de bas niveaux
+qui permettent de réaliser l'opération en moins de 10 secondes.
+
+L'auteur présente dans le chapitre 4, p 77 l'arbre de classification
+et l'utilisation précise qu'il fait de ces descripteurs.
+
+
+Reconnaissance des images de clipart versus photographies
+Reconnaissance des images Noir & Blanc versus Couleur
+Reconnaissance Interieur versus Exterieur
+Autre reconnaissance cartes, photos, peintures.
+
+
+ /---------Image------------\
+ | |
+ v v
+ /-------+------+-------\ /-------+----------\
+ | | | | | | |
+ v v | v v v v
+Carte Clipart | Peinture Couleur N&B N&B colorisé
+ |
+ v
+ /----Photo----------\
+ | |
+ v |
+ /----------\ |
+ | | |
+ v | v
+Intérieur | Visages
+ |
+ v
+ /-----Extérieur------\
+ | |
+ v v
+ /-----\ /-----\
+ | | | |
+ v v v v
+Jour Nuit Nature Urbain
+
+
+Note:
+-----
+Lorsque d'un concept, on part de sa droite et de sa gauche, il s'agit en fait
+de tests différents effectués en parallèles (ex.: Image, Photo, Extérieur).
+
+Lorsqu'on aboutit à une bifurcation et qu'il ne s'agit pas d'un concept, cela
+correspond à un seul test dont les résultats sont répartis dans des classes
+différentes.
+
+Fax
+Magazine
+
+
+
+ANNEXE 1 : SYNTHESE DESCRIPTEURS MILLET
+=======================================
+
+* RGB-64
+--------
+Chaque composante est quantifiée sur 4 valeurs (4x4x4 = 64), puis on construit
+l'histogramme à 64 composantes.
+
+
+* TSVal
+-------
+A partir de l'espace RGB d'origine, on effectue
+la transformation. Attention les composantes ne sont pas quantifiées
+de la même manière (18 valeurs pour la teinte [17 + 1 pour le
+négatif], Val et S sont quantifiées sur 3 valeurs
+chacunes. L'histogramme obtenu dans cet espace contiendra 162
+composantes.
+
+Val = max(R,G,B)
+S = [max(R,G,B) - min(R,G,B)] / max(R,G,B)
+
+Si R = max(R,G,B)
+Alors T = 60 * (G-B) / [max(R,G,B) - min(R,G,B)]
+
+Si G = max(R,G,B)
+Alors T = 60 * (2 + (B-R) / [max(R,G,B) - min(R,G,B)])
+
+Si B = max(R,G,B)
+Alors T = 60 * (4 + (R-G) / [max(R,G,B) - min(R,G,B)])
+
+
+* RGB-64-9
+----------
+L'image est décomposée en 9 sous images identiques, puis on applique le
+descripteur RGB-64. L'histogramme obtenu est la concaténation des 9
+histogrammes soit un histogramme résultant à 576 composantes.
+
+
+* BIC
+-----
+L'image est quantifiée en 216 couleurs (RGB-216) 6 valeurs par couleur. On
+distingue ensuite les pixels du bord des pixels intérieurs. Les pixels
+intérieurs ont la même couleur que leurs 4-voisins. Un histogramme est crée
+pour chaque groupe de pixels. Puis on concatène
+les histogrammes en un seul de 432 composantes.
+
+
+* LEP
+-----
+On construit une image de gradient avec un sobel 3x3, puis cette image est
+seuillée à 100 et devient donc binaire. On étiquette les configurations
+obtenues avec un masque 3x3 classique (convolution). Il existe 2^9
+configurations possibles. On construit alors un histogramme à 512 composantes.
+
+masque de convolution pour l'identification de la configuration:
+001 002 004
+008 256 016
+032 064 128
+
+
+* GABOR
+-------
+Très coûteux, la réponse de 24 filtres sur une image 300x300 est de l'ordre de
+ 1s. On utilise ici des filtres de taille 8x8.
+
+F(x,y) = [1 / (2 PI sigma_x sigma_y)]
+ * exp[(-1/2)(x^2/sigma_x^2 + y^2/sigma_y^2)] * exp[j2 PI Wx]
+
+sigma_x et sigma_y sont des paramètres d'échelles.
+W permet de changer l'orientation.
+
+Il existe une formule pour trouver les coefficients des filtres une fois que
+l'on a déterminé le nombre d'orientations et d'échelles utilisées. On ne
+retiendra, en sortie de filtre, que la variance et l'énergie. L'auteur
+préconise d'utiliser 6 directions et 4 échelles.
+
+
+--------------GABOR---------MATLAB----------------------------------------------
+function gb=gabor_fn(sigma,theta,lambda,psi,gamma)
+
+sigma_x = sigma;
+sigma_y = sigma/gamma;
+
+% Bounding box
+nstds = 3;
+xmax = max(abs(nstds*sigma_x*cos(theta)),abs(nstds*sigma_y*sin(theta)));
+xmax = ceil(max(1,xmax));
+ymax = max(abs(nstds*sigma_x*sin(theta)),abs(nstds*sigma_y*cos(theta)));
+ymax = ceil(max(1,ymax));
+xmin = -xmax; ymin = -ymax;
+[x,y] = meshgrid(xmin:xmax,ymin:ymax);
+
+% Rotation
+x_theta=x*cos(theta)+y*sin(theta);
+y_theta=-x*sin(theta)+y*cos(theta);
+
+gb=exp(-.5*(x_theta.^2/sigma_x^2+y_theta.^2/sigma_y^2)).*cos(2*pi/lambda*x_theta+psi);
+
+http://matlabserver.cs.rug.nl/cgi-bin/matweb.exe
+Gabor Filters. Tech. rep., 2002.
+--------------GABOR---------MATLAB----------------------------------------------
+
+
+* PROJECTION
+------------
+L'image est redimentionnée en 100x100. Un coup de Sobel 3x3, puis une
+binarisation avec s=100. On considère les moitiées verticales puis
+horizontales. Pour les moitiées verticales, on réalise la somme sur chacune
+des lignes, on obtient alors un vecteur de taille 100.
+Pour les moitiées horizontales, on réalise les sommes des colonnes. On obtient
+alors un vecteur taille 100. Les 4 sous vecteurs obtenus peuvent être
+concaténés pour former un unique descipteur de 400 composantes.
+
+
+
+ANNEXE 2 : SYNTHESE CLASSIFICATION MILLET
+=========================================
+
+
+* Reconnaissance des images de clipart versus photographies
+-----------------------------------------------------------
+
+Construire l'histogramme de l'image, éliminer toutes les couleurs peu
+représentées et ensuite les comptées. Moins de 50 couleurs / 256, c'est un
+clipart, plus de 150 / 256 c'est une photographie. Entre les deux, indécision.
+D'après l'auteur, le test n'est pas complètement fiable et peu être évincé, tout
+dépend de la qualité de la compression des cliparts.
+
+Diviser l'image en 16 imagettes (4x4), calculer la suite pour chaque imagette.
+Trouver le maxima de l'histogramme (noté p)/ p = argmax H(x), x in [0,255].
+Puis on calcule un sigma autour du pic.
+
+sigma^2 = Sum(p-1,p-5) r(x) pour p > 250
+sigma^2 = Sum(p+1,p+5) r(x) pour p < 005
+sigma^2 = (1/2) (Sum(p-1,p-5) r(x) + Sum(p+1,p+5) r(x)) pour les autres p
+
+r(x) = ((H(x)/H(p)) * (x-p))^2
+
+
+Le descripteur de l'image entière est alors le maximum des 16 sigma^2. Si le
+pic est resseré, c'est plutôt un clipart (< 5), sinon plutôt une photographie
+(> 40). Le seuil est fixé à 15.
+
+
+
+* Reconnaissance des images Noir & Blanc versus Couleur
+-------------------------------------------------------
+
+Achromatisme (en passant par TSVal)
+
+si |R - G| < s
+et si |R - B| < s alors R ~ G ~ B
+et si |G - B| < s
+
+==> T = -1
+==> Val = (R + G + B)/3
+
+L'auteur propose s = 0,03
+
+Une image est dite Noir & Blanc (donc Achromatique) si + de 99% des pixels le
+sont. Le test peut être appliqué aux images étiquetées comme des cliparts, ou
+des photographies.
+
+
+Faible saturation:
+
+On établit l'histogramme de la saturation de l'image (0 à 255). Si plus de 95%
+des pixels sont inférieurs à une saturation de 100, alors l'image est faiblement
+saturée. Ce test ne s'applique sur les photographies, surtout pas aux cliparts.
+
+
+Dominance de la teinte (image jaunie):
+
+On construit l'histogramme de la teinte (0 à 255). On localise le maximum de
+l'histogramme. Si + de 95% des pixels ont une distance < 20 du maximum, alors
+l'image est considérée comme Noir & Blanc et on peut donner sa teinte dominante.
+De plus il faut qu'au moins 50% des pixels soient faiblement saturés.
+
+T = -1 Achromatisme
+ 0 <= T < 14 Rouge
+ 14 <= T < 29 Orange
+ 29 <= T < 45 Jaune
+ 45 <= T < 113 Vert
+113 <= T < 149 Cyan
+149 <= T < 205 Bleu
+205 <= T < 235 Violet
+235 <= T < 242 Rose, Magenta
+242 <= T < 255 Rouge
+
+
+ 0 <= V < 82 Noir
+ 82 <= V < 179 Gris
+179 <= V < 255 Blanc
+
+
+Pour un pixel (S, Val)
+si |184 - S| + |65 - Val| < |255 - S| + |125 - Val| alors marron sinon orange.
+
+Et encore
+si la teinte est jaune et Val < 80 alors vert sinon jaune.
+
+
+
+* Reconnaissance Interieur versus Exterieur
+-------------------------------------------
+
+Utilisation des descripteurs LEP et RGB-64. Expérience avec un kpp ~ 80%. Puis
+expérimentation avec un SVM ~ 90% de réussite. Finalement, inclusion dans le SVM
+de LEP, RGB-64, TSVal-125, projection, Bic, Gabor.
+
+
+
+
+* Localisation des visages
+--------------------------
+
+Une semaine d'apprentissage, 5 secondes pour leur localisation. Je ne suis pas
+sûr que cette méthode soit pertinente pour notre contexte applicatif.
+
+
+
+* Autre classification
+----------------------
+
+Utilisation de SVM et de tous les descripteurs possibles comme pour Interieur
+versus Exterieur.
diff --git a/milena/sandbox/green/doc/annotating/testMillet2008 b/milena/sandbox/green/doc/annotating/testMillet2008
new file mode 100644
index 0000000..a5cf22d
--- /dev/null
+++ b/milena/sandbox/green/doc/annotating/testMillet2008
@@ -0,0 +1,69 @@
+Dans le cadre de nos recherches, nous testons le classifieur de
+Millet2008 pour la classification des images en clipart ou en
+photographies. Deux tests sont proposés, le premier est basé sur le
+nombre de couleurs de l'image après un seuillage de l'histogramme de
+façon à éliminer les couleurs de faible contribution; le second test
+consiste à extraire le pic de l'histogramme et à mesurer une
+"variance" normalisée autour de ce pic. Le premier test part du
+principe que les photographies possèdent de très nombreuses couleurs,
+tandis que les cliparts n'en ont que quelques unes. Le test n'est pas
+toujours vérifié. Le second test s'intéresse à la nature de
+l'histogramme. L'idée étant de montrer qu'un histogramme continu, donc
+avec une "variance" élevé autour du pic principal est plutôt
+représentatif des phtotographies, alors qu'une "variance" faible tient
+d'avantage du clipart (peu de couleurs, couleurs isolées). Selon
+l'auteur, ce second test donne de très bon résultats. Il peut être
+affiné en divisant l'image en 16 sous parties et en analysant chacune
+des imagettes avec la technique décrite ci-dessus. Dans ce cas, la
+"variance" de l'image est le max des "variances" des imagettes. Les
+repères suivnt sont donnés par l'auteur, "variance" < 5 pour les
+clipart et "variance" ~ 40 pour les photographies (seuil fixé à 15).
+
+
+Test A (Nombre de couleurs dans l'histogramme):
+-----------------------------------------------
+
+
+Test B ("Variance" autour du pic principal):
+--------------------------------------------
+
+bill: Les images de factures contiennent un ensemble d'informations
+groupés sous forme de tableau. Il peut y avoir plusieurs tableaux,
+visibles ou non. Pour la pupart des histogrammes observés,
+l'information en niveau de gris montre un grand pic blanc sans
+voisinage ou avec un voisinage de taille insignifiante. Toutes les
+factures devraient être classées comme des cliparts sauf exception.
+
+deux images sortent du lot:
+- bill17.ppm => 12.7828
+- bill23.ppm => 17.2565
+
+bill17 contient des dégradés qui viennent épaissir le pic blanc, du
+coup le voisinage autour du pic devient plus important.
+
+bill23 contient un logo et une image de fond en transparence sur le
+tableau. Par ailleurs, certains textes sont sur un fond
+composite. Tous ces éléments viennent épaissir le pic blanc.
+
+Résultat : 29 images / 30 passent le test
+
+
+photo: Les images de l'AFP ont la particularité d'être cadré serré
+pour faire ressortir un élément clé de la scène photographiée. On
+s'attend, d'après l'auteur à obtenir une "variance" proche de 40 (seuil ~ 15).
+
+5 vrai positifs:
+- photo01 ==> 42.9224
+- photo10 ==> 48.0298
+- photo25 ==> 33.6833
+- photo27 ==> 42.9025
+- photo28 ==> 43.5689
+
+des scores faibles:
+-
+
+
+
+
+Test C ("Variance" sur les 16 imagettes):
+-----------------------------------------
\ No newline at end of file
--
1.5.6.5
1
0
last-svn-commit-200-ge9bf3ef Introduce the local deviation operator (Millet2008) which subdivise the image in 16 parts.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/demo/annotating/stddev_color_16: New directory.
* green/demo/annotating/stddev_color_16/Makefile.am: New Makefile.
* green/demo/annotating/stddev_color_16/stddev_color_16.cc: New demo.
---
milena/sandbox/ChangeLog | 9 +
.../{bic => stddev_color_16}/Makefile.am | 0
.../annotating/stddev_color_16/stddev_color_16.cc | 178 ++++++++++++++++++++
3 files changed, 187 insertions(+), 0 deletions(-)
copy milena/sandbox/green/demo/annotating/{bic => stddev_color_16}/Makefile.am (100%)
create mode 100644 milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index a096559..423c61b 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,15 @@
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Introduce the local deviation operator (Millet2008) which
+ subdivise the image in 16 parts.
+
+ * green/demo/annotating/stddev_color_16: New directory.
+ * green/demo/annotating/stddev_color_16/Makefile.am: New Makefile.
+ * green/demo/annotating/stddev_color_16/stddev_color_16.cc: New demo.
+
+2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Group Millet2008 documentation files.
* green/doc/annotating: New directory.
diff --git a/milena/sandbox/green/demo/annotating/bic/Makefile.am b/milena/sandbox/green/demo/annotating/stddev_color_16/Makefile.am
similarity index 100%
copy from milena/sandbox/green/demo/annotating/bic/Makefile.am
copy to milena/sandbox/green/demo/annotating/stddev_color_16/Makefile.am
diff --git a/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc b/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
new file mode 100644
index 0000000..5e95c76
--- /dev/null
+++ b/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
@@ -0,0 +1,178 @@
+// COMPUTING THE STDEV OF THE COLORS
+
+#include <iostream>
+#include <sstream>
+
+#include <mln/img_path.hh>
+
+#include <mln/accu/max_site.hh>
+#include <mln/accu/stat/histo1d.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/image/image1d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/debug/println.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/fill.hh>
+#include <mln/data/transform.hh>
+#include <mln/data/paste.hh>
+
+#include <mln/fun/v2v/rgb8_to_int_u8.hh>
+
+#include <mln/io/ppm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/plot/save_image_sh.hh>
+
+#include <mln/math/sqr.hh>
+
+#include <mln/opt/at.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/int_u.hh>
+
+
+float r(short p, unsigned histo_p, short x, unsigned histo_x)
+{
+ float result = mln::math::sqr(((float)histo_x / histo_p) * (x-p));
+
+ return result;
+}
+
+unsigned stddev_color(mln::image2d<mln::value::int_u8> input_int_u8,
+ const char *name_histo,
+ const char *name_image)
+{
+ typedef mln::point1d t_point1d;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image1d<unsigned> t_histo1d;
+ typedef mln::fun::v2v::rgb8_to_int_u8 t_rgb8_to_int_u8;
+ typedef mln::accu::meta::stat::histo1d t_histo1d_fun;
+ typedef mln::accu::max_site<t_histo1d> t_max_site_fun;
+
+ t_histo1d histo;
+
+ std::cout << "histo : " << name_histo << std::endl;
+ std::cout << "image : " << name_image << std::endl;
+
+ histo = mln::data::compute(t_histo1d_fun(), input_int_u8);
+
+ mln::io::pgm::save(input_int_u8, name_image);
+ mln::io::plot::save_image_sh(histo, name_histo);
+ mln::debug::println(histo);
+
+ // Find the peak of the histogram
+ unsigned v_max = mln::opt::at(histo, 0);
+ short p_max = 0;
+
+ mln_piter_(t_histo1d) p(histo.domain());
+
+ for_all(p)
+ {
+ if (v_max < histo(p))
+ {
+ v_max = histo(p);
+ p_max = p.ind();
+ }
+ }
+
+ // Compute the specific stddev
+
+ float stddev_low = 0.0;
+ float stddev_up = 0.0;
+ float stddev = 0.0;
+
+ if (250 > p_max)
+ for (short i = p_max+1; i < p_max+6; ++i)
+ stddev_up += r(p_max, mln::opt::at(histo,p_max),
+ i, mln::opt::at(histo,i));
+
+ if (5 < p_max)
+ for (short i = p_max-1; i > p_max-6; --i)
+ stddev_low += r(p_max, mln::opt::at(histo,p_max),
+ i, mln::opt::at(histo,i));
+
+ stddev = (250 < p_max)? stddev_low : (5 > p_max)? stddev_up :
+ (stddev_low + stddev_up)/2;
+
+ std::cout << "max_site : " << p_max << std::endl;
+ std::cout << "h(max_site) : " << v_max << std::endl;
+ std::cout << "stddev_up : " << stddev_up << std::endl;
+ std::cout << "stddev_low : " << stddev_low << std::endl;
+ std::cout << "stddev : " << stddev << std::endl;
+
+ return 0;
+}
+
+unsigned stddev_color_16(const std::string& image)
+{
+ typedef mln::point1d t_point1d;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image1d<unsigned> t_histo1d;
+ typedef mln::fun::v2v::rgb8_to_int_u8 t_rgb8_to_int_u8;
+ typedef mln::accu::meta::stat::histo1d t_histo1d_fun;
+ typedef mln::accu::max_site<t_histo1d> t_max_site_fun;
+
+ t_image2d_rgb8 input_rgb8;
+ t_image2d_int_u8 input_int_u8;
+
+ mln::io::ppm::load(input_rgb8, image.c_str());
+ input_int_u8 = mln::data::transform(input_rgb8, t_rgb8_to_int_u8());
+
+ // IMAGE SPLITTING PHASE
+ mln::box2d domain = input_int_u8.domain();
+ mln::point2d pmin = domain.pmin();
+ mln::point2d pmax = domain.pmax();
+
+ unsigned sz_row = (pmax.row() - pmin.row())/ 4;
+ unsigned sz_col = (pmax.col() - pmin.col())/ 4;
+
+ std::cout << domain << std::endl;
+
+ // Divide the domain in nine sub-domains.
+ for (unsigned i = 0; i < 4; ++i)
+ for (unsigned j = 0; j < 4; ++j)
+ {
+ mln::point2d min(pmin.row()+sz_row*i,pmin.col()+sz_col*j);
+ mln::point2d max(pmin.row()+sz_row*(i+1),pmin.col()+sz_col*(j+1));
+ mln::box2d dom(min,max);
+
+ std::cout << dom << std::endl;
+
+ // Save it
+ t_image2d_int_u8 input_1o16_int_u8(dom);
+ std::ostringstream name_histo("");
+ std::ostringstream name_image("");
+
+ name_histo << "histo" << i << "_" << j << ".sh";
+ name_image << "image" << i << "_" << j << ".ppm";
+
+ mln::data::paste(input_int_u8 | dom, input_1o16_int_u8);
+
+ stddev_color(input_1o16_int_u8,
+ name_histo.str().c_str(),
+ name_image.str().c_str());
+ }
+
+ return 0;
+}
+
+
+int main()
+{
+// unsigned val = stddev_color_16(ANNOTATING_PHOTO_IMG_PATH "/photo01.ppm");
+ unsigned val = stddev_color_16(ANNOTATING_LOGO_IMG_PATH "/logo06.ppm");
+
+// std::cout << "nb color : " << val << std::endl;
+
+ return 0;
+}
+
--
1.5.6.5
1
0
last-svn-commit-201-g07b0d84 Test the local deviation operator (Millet2008) on the annotating base.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/exp/annotating/stddev_color_16: New directory.
* green/exp/annotating/stddev_color_16/Makefile.am: New Makefile.
* green/exp/annotating/stddev_color_16/stddev_color_16.cc: New demo.
---
milena/sandbox/ChangeLog | 8 ++
.../{nb_color => stddev_color_16}/Makefile.am | 0
.../annotating/stddev_color_16/stddev_color_16.cc | 87 ++++++++++++--------
3 files changed, 60 insertions(+), 35 deletions(-)
copy milena/sandbox/green/exp/annotating/{nb_color => stddev_color_16}/Makefile.am (100%)
copy milena/sandbox/green/{demo => exp}/annotating/stddev_color_16/stddev_color_16.cc (70%)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 423c61b..7ec7a8a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,14 @@
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Test the local deviation operator (Millet2008) on the annotating base.
+
+ * green/exp/annotating/stddev_color_16: New directory.
+ * green/exp/annotating/stddev_color_16/Makefile.am: New Makefile.
+ * green/exp/annotating/stddev_color_16/stddev_color_16.cc: New demo.
+
+2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Introduce the local deviation operator (Millet2008) which
subdivise the image in 16 parts.
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am b/milena/sandbox/green/exp/annotating/stddev_color_16/Makefile.am
similarity index 100%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/exp/annotating/stddev_color_16/Makefile.am
diff --git a/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc b/milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
similarity index 70%
copy from milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
copy to milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
index 5e95c76..c196595 100644
--- a/milena/sandbox/green/demo/annotating/stddev_color_16/stddev_color_16.cc
+++ b/milena/sandbox/green/exp/annotating/stddev_color_16/stddev_color_16.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
+#include <boost/filesystem.hpp>
#include <mln/img_path.hh>
@@ -27,6 +28,7 @@
#include <mln/io/plot/save_image_sh.hh>
#include <mln/math/sqr.hh>
+#include <mln/math/max.hh>
#include <mln/opt/at.hh>
@@ -41,9 +43,7 @@ float r(short p, unsigned histo_p, short x, unsigned histo_x)
return result;
}
-unsigned stddev_color(mln::image2d<mln::value::int_u8> input_int_u8,
- const char *name_histo,
- const char *name_image)
+float stddev_color(mln::image2d<mln::value::int_u8> input_int_u8)
{
typedef mln::point1d t_point1d;
typedef mln::value::rgb8 t_rgb8;
@@ -57,15 +57,8 @@ unsigned stddev_color(mln::image2d<mln::value::int_u8> input_int_u8,
t_histo1d histo;
- std::cout << "histo : " << name_histo << std::endl;
- std::cout << "image : " << name_image << std::endl;
-
histo = mln::data::compute(t_histo1d_fun(), input_int_u8);
- mln::io::pgm::save(input_int_u8, name_image);
- mln::io::plot::save_image_sh(histo, name_histo);
- mln::debug::println(histo);
-
// Find the peak of the histogram
unsigned v_max = mln::opt::at(histo, 0);
short p_max = 0;
@@ -100,16 +93,10 @@ unsigned stddev_color(mln::image2d<mln::value::int_u8> input_int_u8,
stddev = (250 < p_max)? stddev_low : (5 > p_max)? stddev_up :
(stddev_low + stddev_up)/2;
- std::cout << "max_site : " << p_max << std::endl;
- std::cout << "h(max_site) : " << v_max << std::endl;
- std::cout << "stddev_up : " << stddev_up << std::endl;
- std::cout << "stddev_low : " << stddev_low << std::endl;
- std::cout << "stddev : " << stddev << std::endl;
-
- return 0;
+ return stddev;
}
-unsigned stddev_color_16(const std::string& image)
+float stddev_color_16(const std::string& image)
{
typedef mln::point1d t_point1d;
typedef mln::value::rgb8 t_rgb8;
@@ -134,8 +121,7 @@ unsigned stddev_color_16(const std::string& image)
unsigned sz_row = (pmax.row() - pmin.row())/ 4;
unsigned sz_col = (pmax.col() - pmin.col())/ 4;
-
- std::cout << domain << std::endl;
+ float stddev = 0.0;
// Divide the domain in nine sub-domains.
for (unsigned i = 0; i < 4; ++i)
@@ -145,34 +131,65 @@ unsigned stddev_color_16(const std::string& image)
mln::point2d max(pmin.row()+sz_row*(i+1),pmin.col()+sz_col*(j+1));
mln::box2d dom(min,max);
- std::cout << dom << std::endl;
-
// Save it
t_image2d_int_u8 input_1o16_int_u8(dom);
- std::ostringstream name_histo("");
- std::ostringstream name_image("");
-
- name_histo << "histo" << i << "_" << j << ".sh";
- name_image << "image" << i << "_" << j << ".ppm";
mln::data::paste(input_int_u8 | dom, input_1o16_int_u8);
- stddev_color(input_1o16_int_u8,
- name_histo.str().c_str(),
- name_image.str().c_str());
+ stddev = mln::math::max(stddev, stddev_color(input_1o16_int_u8));
}
- return 0;
+ return stddev;
}
int main()
{
-// unsigned val = stddev_color_16(ANNOTATING_PHOTO_IMG_PATH "/photo01.ppm");
- unsigned val = stddev_color_16(ANNOTATING_LOGO_IMG_PATH "/logo06.ppm");
+ typedef boost::filesystem::path t_path;
+ typedef boost::filesystem::directory_iterator t_iter_path;
+
+ t_path full_path[] = {t_path(ANNOTATING_BILL_IMG_PATH),
+ t_path(ANNOTATING_FAX_IMG_PATH),
+ t_path(ANNOTATING_HANDWRITTEN_IMG_PATH),
+ t_path(ANNOTATING_LOGO_IMG_PATH),
+ t_path(ANNOTATING_MAP_IMG_PATH),
+ t_path(ANNOTATING_PHOTO_IMG_PATH),
+ t_path(ANNOTATING_SCREENSHOT_IMG_PATH),
+ t_path(ANNOTATING_SLIDE_IMG_PATH),
+ t_path(ANNOTATING_TYPED_IMG_PATH)};
+
+ for (int i = 0; i < 9; ++i)
+ {
+ std::cerr << "entering " << full_path[i] << std::endl;
+ std::cout << "entering " << full_path[i] << std::endl;
-// std::cout << "nb color : " << val << std::endl;
+ if (boost::filesystem::exists(full_path[i]) &&
+ boost::filesystem::is_directory(full_path[i]))
+ {
+ boost::filesystem::system_complete(full_path[i]);
+ const t_iter_path end_iter;
+ float count = 0;
+ float sum1 = 0;
+ float sum2 = 0;
+
+ for (t_iter_path dir_iter(full_path[i]); end_iter != dir_iter; ++dir_iter)
+ {
+ float val = stddev_color_16(dir_iter->path().string());
+
+ ++count;
+ sum1 += val;
+ sum2 += val*val;
+
+ std::cout << dir_iter->path().string() << " => " << val << std::endl;
+ }
+
+ float mean = sum1 / count;
+ float var = ((float)sum2 / count) - (mean * mean);
+
+ std::cout << "mean : " << mean << std::endl;
+ std::cout << "var : " << var << std::endl;
+ }
+ }
return 0;
}
-
--
1.5.6.5
1
0
last-svn-commit-202-gb98887a Fix bugs in regional_maxima routine, work with rgb8 for stats.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/demo/labeling/regional_maxima/regional_maxima.cc
(compute_stats): New function.
* green/demo/labeling/regional_maxima/regional_maxima.cc
(demo,main): Update functions to map Theo's view.
---
milena/sandbox/ChangeLog | 11 +
.../labeling/regional_maxima/regional_maxima.cc | 261 ++++++++++++++++----
2 files changed, 222 insertions(+), 50 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 7ec7a8a..1ea3546 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -75,6 +75,17 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
+2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix bugs in regional_maxima routine, work with rgb8 for stats.
+
+ * green/demo/labeling/regional_maxima/regional_maxima.cc
+ (compute_stats): New function.
+
+ * green/demo/labeling/regional_maxima/regional_maxima.cc
+ (demo,main): Update functions to map Theo's view.
+
+
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Test the local deviation operator (Millet2008) on the annotating base.
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
index 266fbfe..c832486 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
@@ -2,6 +2,7 @@
#include <iostream>
#include <sstream>
+#include <boost/format.hpp>
#include <mln/img_path.hh>
@@ -106,30 +107,31 @@ struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
}
};
+// Version optimisée de mean_values
-// version non optimisée de label
-
-template <unsigned n>
-mln::image2d<mln::value::label_8>
-label_image(const mln::image2d< mln::value::rgb<n> >& input,
- const mln::image3d< mln::value::label_8>& label)
+struct t_mean_lbl8_with_rgb8 : mln::Function_v2v< t_mean_lbl8_with_rgb8 >
{
- mln::image2d<mln::value::label_8> output;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_lbl8 argument;
+ typedef t_rgb8 result;
+ typedef mln::image3d<t_lbl8> t_label;
+ typedef mln::util::array<t_vec3f> t_mean_array;
- initialize(output, input);
+ const t_mean_array& _mean_array;
- mln_piter(mln::image2d< mln::value::label_8 >) po(output.domain());
- mln_piter(mln::image2d< mln::value::rgb<n> >) pi(input.domain());
+ t_mean_lbl8_with_rgb8(const t_mean_array& mean_array) :
+ _mean_array(mean_array) {}
- for_all_2(po, pi)
+ result operator()(const argument& c) const
{
- const mln::value::rgb<n>& vi = input(pi);
+ t_rgb8 tmp = _mean_array[c];
- output(po) = mln::opt::at(label, vi.blue(), vi.red(), vi.green());
+ return tmp;
}
+};
- return output;
-}
template <unsigned n>
unsigned unquant(const float& value)
@@ -253,6 +255,109 @@ void print_count2(const mln::image2d<mln::value::rgb<n> >& input_rgbn,
}
}
+template <unsigned n>
+mln::image2d<mln::value::label_8>
+compute_stats(const mln::image2d<mln::value::rgb8>& input_rgb8,
+ const mln::image2d<mln::value::rgb<n> >& input_rgbn,
+ const mln::image3d<unsigned>& histo,
+ const mln::image3d<mln::value::label_8>& label,
+ const unsigned n_labels)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::int_u<n> t_int_un;
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_int_un> t_image2d_int_un;
+ typedef mln::util::array<unsigned> t_count_array;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ abs[i] = 0.0;
+ rel[i] = 0.0;
+ }
+
+ // COMPUTE THE SUM
+ t_count_array count = mln::labeling::compute(t_sum(),
+ histo,
+ label,
+ n_labels);
+
+ // COMPUTE THE TOTAL
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+
+ // COMPUTE THE PERCENTAGES
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
+
+ // COMPUTE THE MEAN
+ t_image2d_lbl8 label_img = mln::data::transform(input_rgbn,
+ t_labeling_rgbn<n>(label));
+
+ t_mean_array mean = mln::labeling::compute(t_mean(),
+ input_rgb8,
+ label_img,
+ n_labels);
+
+ // CORRECT LABEL 0 STATS
+ rel[0] = 0;
+ mean[0][0] = 255.0;
+ mean[0][1] = 255.0;
+ mean[0][2] = 0.0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ const t_vec3f& mean_v = mean[i];
+
+ std::cout << boost::format("%2i|"
+ "r = %6.2f, g = %6.2f, b = %6.2f |"
+ "c = %7i, %%i = %5.2f, %%c = %5.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ % count[i]
+ % abs[i]
+ % rel[i]
+ << std::endl;
+ /*
+ std::cout << i << "|("
+ << "r = " << unquant<n>(mean_v[0]) << ", "
+ << "g = " << unquant<n>(mean_v[1]) << ", "
+ << "b = " << unquant<n>(mean_v[2]) << ")|("
+ << "c = " << count[i] << ", "
+ << "%i= " << abs[i] << "%, "
+ << "%c= " << rel[i] << "%)"
+ << std::endl;
+ */
+ }
+
+ t_image2d_rgb8 mean_rgb8 = mln::data::transform(label_img,
+ t_mean_lbl8_with_rgb8(mean));
+
+ mln::io::ppm::save(mean_rgb8, "mean.ppm");
+
+ return label_img;
+}
+
void print_count(const mln::image3d<unsigned>& histo,
const mln::image3d<mln::value::label_8>& label,
const unsigned n_labels)
@@ -320,26 +425,32 @@ void print_count(const mln::image3d<unsigned>& histo,
template <unsigned n>
struct t_merge_lbl8_with_rgbn : mln::Function_v2v< t_merge_lbl8_with_rgbn<n> >
{
- typedef mln::value::rgb<n> t_rgbn;
- typedef mln::value::label_8 t_lbl8;
- typedef t_rgbn argument;
- typedef t_rgbn result;
- typedef mln::image3d<t_lbl8> t_label;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_rgb8 argument;
+ typedef t_rgb8 result;
+ typedef mln::image3d<t_lbl8> t_label;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
- const t_label& _label;
+ const t_label& _label;
+ const t_rgb8_to_rgbn _convert;
t_merge_lbl8_with_rgbn(const t_label& label) : _label(label) {}
result operator()(const argument& c) const
{
- t_rgbn tmp = c;
+ t_rgb8 tmp_rgb8 = c;
+ t_rgbn tmp_rgbn = _convert(c);
- if (0 == mln::opt::at(_label, c.blue(), c.red(), c.green()))
+ if (0==mln::opt::at(_label,tmp_rgbn.blue(),tmp_rgbn.red(),tmp_rgbn.green()))
{
- tmp = mln::literal::black;
+ // tmp = mln::literal::black;
+ // tmp = mln::literal::yellow;
+ tmp_rgb8 = mln::literal::red;
}
- return tmp;
+ return tmp_rgb8;
}
};
@@ -452,13 +563,8 @@ int main2()
// n < 8, n is the degree of quantification
template <unsigned n>
-void demo()
+void demo(const std::string& image, const unsigned min_volume)
{
- const unsigned min_volume = 1000;
- //const std::string& image = OLENA_IMG_PATH"/fly.ppm";
- const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
- //const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
-
typedef mln::value::label_8 t_lbl8;
typedef mln::value::int_u8 t_int_u8;
typedef mln::value::rgb8 t_rgb8;
@@ -473,16 +579,13 @@ void demo()
typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
- mln::util::timer timer;
-
// START OF IMAGE PROCESSING CHAIN
- timer.start();
-
t_image2d_rgb8 input_rgb8;
t_image2d_rgbn input_rgbn;
- t_image2d_rgbn output_rgbn;
- // t_image2d_rgbn mean_rgb5;
+ t_image2d_rgb8 output_rgb8;
+ t_image2d_rgb8 mean_rgb8;
t_histo3d histo;
+ t_histo3d histo2;
// t_image2d_int_u8 projected;
// t_image2d_int_u8 filtered;
t_histo3d opened;
@@ -490,18 +593,35 @@ void demo()
t_image2d_lbl8 label_img;
t_image3d_lbl8 dilated;
t_lbl8 n_labels;
- // t_rgbn value_rgbn;
mln::io::ppm::load(input_rgb8, image.c_str());
input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
histo = mln::data::compute(t_histo3d_fun(), input_rgbn);
opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
- dilated = mln::morpho::elementary::dilation(label, mln::c26());
+ // dilated = mln::morpho::elementary::dilation(label, mln::c26());
- timer.stop();
// END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ label_img = compute_stats(input_rgb8, input_rgbn, histo, label, n_labels);
+ // mean_rgb8 = mln::labeling::mean_values(input_rgb8, label_img, n_labels);
+ // mln::io::ppm::save(mean_rgb8, "mean.ppm");
+
+ output_rgb8 = mln::data::transform(input_rgb8,
+ t_merge_lbl8_with_rgbn<5>(label));
+
+
+ mln::io::ppm::save(output_rgb8, "merge.ppm");
+ mln::io::pgm::save(label_img, "label.pgm");
+
+
+// histo2 = mln::data::compute(t_histo3d_fun(), mean_rgbn);
+// mln::debug::println(histo2);
+ // END DUMPING
+
+/*
std::ostringstream name;
std::ostringstream name2;
std::ostringstream name3;
@@ -510,17 +630,11 @@ void demo()
name2 << "output_rgb" << n << ".ppm";
name3 << "label_img" << n << ".pgm";
- std::cout << "Done in : " << timer.read() << " s" << std::endl;
std::cout << "Labels : " << n_labels << std::endl;
std::cout << "Name : " << name.str() << std::endl;
- mln::io::ppm::save(input_rgbn, name.str());
-
- mln::util::timer timer2;
+// mln::io::ppm::save(input_rgbn, name.str());
- timer2.start();
- print_count2(input_rgbn, histo, dilated, n_labels);
- timer2.stop();
std::cout << "timer2 : " << timer2.read() << std::endl;
output_rgbn = mln::data::transform(input_rgbn,
t_merge_lbl8_with_rgbn<n>(label));
@@ -531,7 +645,7 @@ void demo()
t_labeling_rgbn<n>(label));
// label_img = label_image<n>(input_rgbn, dilated);
mln::io::pgm::save(label_img, name3.str());
-
+*/
// localiser les couleurs sur l'image (fond en black, le reste)
@@ -571,8 +685,8 @@ void demo()
*/
}
-
-int main()
+/*
+int main_old()
{
demo<2>(); // 2.26 s
demo<3>(); // 2.29 s
@@ -582,3 +696,50 @@ int main()
demo<7>(); // 11.43 s
demo<8>(); // 96.19 s
}
+*/
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "regional_maxima" << std::endl;
+ std::cout << "image <name>" << std::endl;
+ std::cout << "quantification {5,6}" << std::endl;
+ std::cout << "volume 1000" << std::endl;
+
+ // 3 paramètres en entré:
+ // * l'image
+ // * la quantification utilisée
+ // * le volume minimale laissé pour les pics de l'histo
+
+ // sorties:
+ // * fichier de stats [etiquette|couleur moyenne|% image|% classé]
+ // * couleur moyenne de l'étiquette + couleur specifique pour étiquette 0
+ // * histo sur l'image d'étiquette
+}
+
+int main(int argc, char* args[])
+{
+ if (argc != 3)
+ {
+ // const std::string& image = OLENA_IMG_PATH"/fly.ppm";
+ const std::string& image = SCRIBO_PPM_IMG_PATH"/mp00082c_50p.ppm";
+ // const std::string& image = OLENA_IMG_PATH"/tiny.ppm";
+ // const std::string image = OLENA_IMG_PATH"/tiny.ppm";
+ const unsigned min_volume = 1000;
+ // const unsigned min_volume = atoi(args[2]);
+
+ switch(args[2][0])
+ {
+ case '2': demo<2>(image, min_volume); break;
+ case '3': demo<3>(image, min_volume); break;
+ case '4': demo<4>(image, min_volume); break;
+ case '5': demo<5>(image, min_volume); break;
+ case '6': demo<6>(image, min_volume); break;
+ case '7': demo<7>(image, min_volume); break;
+ case '8': demo<8>(image, min_volume); break;
+ default: demo<5>(image, min_volume); break;
+ // default: usage(); break;
+ }
+ }
+ else
+ usage();
+}
--
1.5.6.5
1
0
* green/mln/display/display_histo.hh: Fix bug in the direction.
* green/mln/display/project_histo.hh: Add spaces to follow the LRDE
norm.
---
milena/sandbox/ChangeLog | 8 ++++++++
milena/sandbox/green/mln/display/display_histo.hh | 13 +++++++++----
milena/sandbox/green/mln/display/project_histo.hh | 4 ++--
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 1ea3546..b94de66 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -75,6 +75,14 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
+2009-12-17 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Fix bug in the direction of projection.
+
+ * green/mln/display/display_histo.hh: Fix bug in the direction.
+ * green/mln/display/project_histo.hh: Add spaces to follow the LRDE
+ norm.
+
2009-12-16 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Fix bugs in regional_maxima routine, work with rgb8 for stats.
diff --git a/milena/sandbox/green/mln/display/display_histo.hh b/milena/sandbox/green/mln/display/display_histo.hh
index d34914c..1fd5da4 100644
--- a/milena/sandbox/green/mln/display/display_histo.hh
+++ b/milena/sandbox/green/mln/display/display_histo.hh
@@ -28,10 +28,12 @@
#ifndef MLN_DISPLAY_DISPLAY_HISTO_HH
# define MLN_DISPLAY_DISPLAY_HISTO_HH
+# include <mln/accu/math/sum.hh>
# include <mln/data/stretch.hh>
-# include <mln/fun/v2v/log.hh>
# include <mln/display/project_histo.hh>
-# include <mln/accu/math/sum.hh>
+# include <mln/fun/v2v/log.hh>
+# include <mln/value/int_u8.hh>
+
/// \file
///
@@ -59,9 +61,12 @@ namespace mln
///
/// The 3d histogram is projected in red/green space by
/// accumulating around the the blue dimension (green and blue
- /// composantes are being correlated). In fact, we sum in along
+ /// composantes are being correlated). In fact, we sum along
/// the blue direction. Then, we stretch value to feet pgm
/// format.
+ /// Direction r = 1
+ /// Direction g = 2
+ /// Direction b = 0
///
/// \parameter[in] histo the histogram in 3d.
/// \result return a equivalent 2d image.
@@ -74,7 +79,7 @@ namespace mln
typedef value::int_u8 t_int_u8;
typedef fun::v2v::log<float> t_log;
- image2d<unsigned> proj = project_histo<t_sum,2>(histo);
+ image2d<unsigned> proj = project_histo<t_sum,0>(histo);
image2d<t_int_u8> proj_int = data::stretch(t_int_u8(),
data::transform(proj,
t_log()));
diff --git a/milena/sandbox/green/mln/display/project_histo.hh b/milena/sandbox/green/mln/display/project_histo.hh
index 63ea84e..f0e6858 100644
--- a/milena/sandbox/green/mln/display/project_histo.hh
+++ b/milena/sandbox/green/mln/display/project_histo.hh
@@ -54,7 +54,7 @@ namespace mln
image2d<mln_result(A)>
project_histo(const image3d<V>& histo);
-#ifndef MLN_INCLUDE_ONLY
+# ifndef MLN_INCLUDE_ONLY
/// \brief Allow the visualization of 3d histogram.
///
@@ -86,7 +86,7 @@ namespace mln
return accu::image::to_result(histo_accu);
}
-#endif // ! MLN_INCLUDE_ONLY
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::transform
--
1.5.6.5
1
0
30 Jun '10
* green/demo/labeling/regional_maxima/regional_maxima.cc: Add
many modifications to reach the current software state. There is some
nomenclatura, some refactoring and debugging.
---
milena/sandbox/ChangeLog | 8 +
.../labeling/regional_maxima/regional_maxima.cc | 354 ++++++++++++--------
2 files changed, 214 insertions(+), 148 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index b94de66..e1a6235 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -75,6 +75,14 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
+2009-12-18 Yann Jacquelet<jacquelet(a)lrde.epita.fr>
+
+ Fix the right behaviour of the regmax software.
+
+ * green/demo/labeling/regional_maxima/regional_maxima.cc: Add
+ many modifications to reach the current software state. There is some
+ nomenclatura, some refactoring and debugging.
+
2009-12-17 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Fix bug in the direction of projection.
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
index c832486..65b6608 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/regional_maxima.cc
@@ -27,7 +27,8 @@
// #include <mln/data/stretch.hh>
#include <mln/data/transform.hh>
-// #include <mln/display/display_histo.hh>
+// #include <mln/debug/println.hh>
+#include <mln/display/display_histo.hh>
#include <mln/fun/v2v/rgb8_to_rgbn.hh>
@@ -49,6 +50,7 @@
#include <mln/opt/at.hh>
+#include <mln/transform/influence_zone_geodesic.hh>
// #include <mln/pw/value.hh>
#include <mln/util/array.hh>
@@ -255,108 +257,6 @@ void print_count2(const mln::image2d<mln::value::rgb<n> >& input_rgbn,
}
}
-template <unsigned n>
-mln::image2d<mln::value::label_8>
-compute_stats(const mln::image2d<mln::value::rgb8>& input_rgb8,
- const mln::image2d<mln::value::rgb<n> >& input_rgbn,
- const mln::image3d<unsigned>& histo,
- const mln::image3d<mln::value::label_8>& label,
- const unsigned n_labels)
-{
- typedef mln::value::label_8 t_lbl8;
- typedef mln::value::rgb<n> t_rgbn;
- typedef mln::value::rgb8 t_rgb8;
- typedef mln::value::int_u<n> t_int_un;
- typedef mln::algebra::vec<3,float> t_vec3f;
- typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
- typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
- typedef mln::image2d<t_lbl8> t_image2d_lbl8;
- typedef mln::image2d<t_rgbn> t_image2d_rgbn;
- typedef mln::image2d<t_rgb8> t_image2d_rgb8;
- typedef mln::image2d<t_int_un> t_image2d_int_un;
- typedef mln::util::array<unsigned> t_count_array;
- typedef mln::util::array<t_vec3f> t_mean_array;
-
- mln::util::array<float> abs((unsigned)(n_labels)+1);
- mln::util::array<float> rel((unsigned)(n_labels)+1);
- unsigned nb = 0;
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- abs[i] = 0.0;
- rel[i] = 0.0;
- }
-
- // COMPUTE THE SUM
- t_count_array count = mln::labeling::compute(t_sum(),
- histo,
- label,
- n_labels);
-
- // COMPUTE THE TOTAL
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- unsigned c = count[i];
- nb += c;
- }
-
- // COMPUTE THE PERCENTAGES
- for (unsigned i = 0; i <= n_labels; ++i)
- if (0 < count[i])
- {
- abs[i] = ((float)count[i] / nb)*100.0;
- rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
- }
-
- // COMPUTE THE MEAN
- t_image2d_lbl8 label_img = mln::data::transform(input_rgbn,
- t_labeling_rgbn<n>(label));
-
- t_mean_array mean = mln::labeling::compute(t_mean(),
- input_rgb8,
- label_img,
- n_labels);
-
- // CORRECT LABEL 0 STATS
- rel[0] = 0;
- mean[0][0] = 255.0;
- mean[0][1] = 255.0;
- mean[0][2] = 0.0;
-
- for (unsigned i = 0; i <= n_labels; ++i)
- {
- const t_vec3f& mean_v = mean[i];
-
- std::cout << boost::format("%2i|"
- "r = %6.2f, g = %6.2f, b = %6.2f |"
- "c = %7i, %%i = %5.2f, %%c = %5.2f")
- % i
- % mean_v[0]
- % mean_v[1]
- % mean_v[2]
- % count[i]
- % abs[i]
- % rel[i]
- << std::endl;
- /*
- std::cout << i << "|("
- << "r = " << unquant<n>(mean_v[0]) << ", "
- << "g = " << unquant<n>(mean_v[1]) << ", "
- << "b = " << unquant<n>(mean_v[2]) << ")|("
- << "c = " << count[i] << ", "
- << "%i= " << abs[i] << "%, "
- << "%c= " << rel[i] << "%)"
- << std::endl;
- */
- }
-
- t_image2d_rgb8 mean_rgb8 = mln::data::transform(label_img,
- t_mean_lbl8_with_rgb8(mean));
-
- mln::io::ppm::save(mean_rgb8, "mean.ppm");
-
- return label_img;
-}
void print_count(const mln::image3d<unsigned>& histo,
const mln::image3d<mln::value::label_8>& label,
@@ -561,9 +461,111 @@ int main2()
return 0;
}
+void compute_stats(const mln::image2d<mln::value::rgb8>& i_input_rgb8,
+ const mln::image2d<mln::value::label_8>& l_input_lbl8,
+ const mln::image3d<unsigned>& h_histo_rgbn,
+ const mln::image3d<mln::value::label_8>& l_histo_lbl8,
+ const mln::value::label_8& n_labels)
+{
+ typedef mln::algebra::vec<3,float> t_vec3f;
+ typedef mln::accu::math::sum<unsigned,unsigned> t_sum;
+ typedef mln::accu::stat::mean<t_vec3f,t_vec3f,t_vec3f> t_mean;
+ typedef mln::util::array<unsigned> t_count_array;
+ typedef mln::util::array<t_vec3f> t_mean_array;
+
+ mln::util::array<float> abs((unsigned)(n_labels)+1);
+ mln::util::array<float> rel((unsigned)(n_labels)+1);
+ unsigned nb = 0;
+
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ abs[i] = 0.0;
+ rel[i] = 0.0;
+ }
+
+ // COMPUTE THE SUM
+ t_count_array count = mln::labeling::compute(t_sum(),
+ h_histo_rgbn,
+ l_histo_lbl8,
+ n_labels);
+
+ // COMPUTE THE TOTAL
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ unsigned c = count[i];
+ nb += c;
+ }
+
+ // COMPUTE THE PERCENTAGES
+ for (unsigned i = 0; i <= n_labels; ++i)
+ if (0 < count[i])
+ {
+ abs[i] = ((float)count[i] / nb)*100.0;
+ rel[i] = ((float)count[i] / (nb - count[0]))*100.0;
+ }
+
+ // COMPUTE THE MEAN
+
+ t_mean_array mean = mln::labeling::compute(t_mean(),
+ i_input_rgb8,
+ l_input_lbl8,
+ n_labels);
+
+ // CORRECT 0 LABEL STATS
+ rel[0] = 0;
+ mean[0][0] = 255.0;
+ mean[0][1] = 255.0;
+ mean[0][2] = 0.0;
+
+ // PRINT STATS
+ for (unsigned i = 0; i <= n_labels; ++i)
+ {
+ const t_vec3f& mean_v = mean[i];
+
+ std::cout << boost::format("%2i|"
+ "r = %6.2f, g = %6.2f, b = %6.2f |"
+ "c = %7i, %%i = %5.2f, %%c = %5.2f")
+ % i
+ % mean_v[0]
+ % mean_v[1]
+ % mean_v[2]
+ % count[i]
+ % abs[i]
+ % rel[i]
+ << std::endl;
+ /*
+ std::cout << i << "|("
+ << "r = " << unquant<n>(mean_v[0]) << ", "
+ << "g = " << unquant<n>(mean_v[1]) << ", "
+ << "b = " << unquant<n>(mean_v[2]) << ")|("
+ << "c = " << count[i] << ", "
+ << "%i= " << abs[i] << "%, "
+ << "%c= " << rel[i] << "%)"
+ << std::endl;
+ */
+ }
+
+ std::cout << std::endl << std::endl;
+
+}
+
+void save_histo(const mln::image2d<mln::value::rgb8>& input_rgb8,
+ const std::string& name)
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ t_histo3d histo = mln::data::compute(t_histo3d_fun(), input_rgb8);
+ t_image2d_int_u8 display = mln::display::display_histo3d_unsigned(histo);
+ mln::io::pgm::save(display, name);
+}
+
+
// n < 8, n is the degree of quantification
template <unsigned n>
-void demo(const std::string& image, const unsigned min_volume)
+void demo(const std::string& image, const unsigned min_vol)
{
typedef mln::value::label_8 t_lbl8;
typedef mln::value::int_u8 t_int_u8;
@@ -580,45 +582,106 @@ void demo(const std::string& image, const unsigned min_volume)
typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
// START OF IMAGE PROCESSING CHAIN
- t_image2d_rgb8 input_rgb8;
- t_image2d_rgbn input_rgbn;
- t_image2d_rgb8 output_rgb8;
- t_image2d_rgb8 mean_rgb8;
- t_histo3d histo;
- t_histo3d histo2;
- // t_image2d_int_u8 projected;
- // t_image2d_int_u8 filtered;
- t_histo3d opened;
- t_image3d_lbl8 label;
- t_image2d_lbl8 label_img;
- t_image3d_lbl8 dilated;
- t_lbl8 n_labels;
-
- mln::io::ppm::load(input_rgb8, image.c_str());
- input_rgbn = mln::data::transform(input_rgb8, t_rgb8_to_rgbn());
- histo = mln::data::compute(t_histo3d_fun(), input_rgbn);
- opened = mln::morpho::opening::volume(histo, mln::c6(), min_volume);
- label = mln::labeling::regional_maxima(opened, mln::c6(), n_labels);
- // dilated = mln::morpho::elementary::dilation(label, mln::c26());
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_histo3d h0_input; // histo input
+
+ t_image2d_rgbn i1_input; // input rgbn
+ t_histo3d h1_input; // histo input
+
+ t_histo3d h2_input; // histo opened
+ t_image3d_lbl8 l2_histo; // label histo
+ t_image2d_lbl8 l2_input; // label image
+ t_image2d_rgb8 i2_merge; // merge label
+ t_image2d_rgb8 i2_mean; // mean label
+
+ t_image3d_lbl8 l3_histo; // label dilated
+ t_image2d_lbl8 l3_input; // label image
+ t_image2d_rgb8 i3_merge; // merge label
+ t_image2d_rgb8 i3_mean; // mean label
+
+ t_image3d_lbl8 l4_histo; // label iz
+ t_image2d_lbl8 l4_input; // label image
+ t_image2d_rgb8 i4_merge; // merge label
+ t_image2d_rgb8 i4_mean; // mean label
+
+ t_image3d_lbl8 l5_histo; // label iz 2
+ t_image2d_lbl8 l5_input; // label image
+ t_image2d_rgb8 i5_merge; // merge label
+ t_image2d_rgb8 i5_mean; // mean label
+
+ t_lbl8 n_lbl; // nb class
+
+ mln::io::ppm::load(i0_input, image.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ l3_histo = mln::morpho::elementary::dilation(l2_histo, mln::c26());
+ l4_histo = mln::transform::influence_zone_geodesic(l2_histo, mln::c26());
+ l5_histo = mln::transform::influence_zone_geodesic(l2_histo, mln::c26(), 2);
// END OF IMAGE PROCESSING CHAIN
+// i2_mean = mln::data::transform(l0_input,t_mean_lbl8_with_rgb8(mean_array));
// BEGIN DUMPING
- label_img = compute_stats(input_rgb8, input_rgbn, histo, label, n_labels);
- // mean_rgb8 = mln::labeling::mean_values(input_rgb8, label_img, n_labels);
- // mln::io::ppm::save(mean_rgb8, "mean.ppm");
+ save_histo(i0_input, "h0_input.pgm");
+
+ // without anything
+ l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
+ i2_mean = mln::labeling::mean_values(i0_input, l2_input, n_lbl);
+ i2_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l2_histo));
+
+ compute_stats(i0_input, l2_input, h1_input, l2_histo, n_lbl);
+
+ mln::io::pgm::save(l2_input, "l2_input.pgm");
+ mln::io::ppm::save(i2_mean, "i2_mean.ppm");
+ mln::io::ppm::save(i2_merge, "i2_merge.ppm");
+
+ save_histo(i2_mean, "h2_mean.pgm");
+ save_histo(i2_merge, "h2_merge.pgm");
- output_rgb8 = mln::data::transform(input_rgb8,
- t_merge_lbl8_with_rgbn<5>(label));
+ // with dilation
+ l3_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l3_histo));
+ i3_mean = mln::labeling::mean_values(i0_input, l3_input, n_lbl);
+ i3_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l3_histo));
+ compute_stats(i0_input, l3_input, h1_input, l3_histo, n_lbl);
- mln::io::ppm::save(output_rgb8, "merge.ppm");
- mln::io::pgm::save(label_img, "label.pgm");
+ mln::io::pgm::save(l3_input, "l3_input.pgm");
+ mln::io::ppm::save(i3_mean, "i3_mean.ppm");
+ mln::io::ppm::save(i3_merge, "i3_merge.ppm");
+ save_histo(i3_mean, "h3_mean.pgm");
+ save_histo(i3_merge, "h3_merge.pgm");
-// histo2 = mln::data::compute(t_histo3d_fun(), mean_rgbn);
-// mln::debug::println(histo2);
+ // with geodesic influence
+ l4_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l4_histo));
+ i4_mean = mln::labeling::mean_values(i0_input, l4_input, n_lbl);
+ i4_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l4_histo));
+
+ compute_stats(i0_input, l4_input, h1_input, l4_histo, n_lbl);
+
+ mln::io::pgm::save(l4_input, "l4_input.pgm");
+ mln::io::ppm::save(i4_mean, "i4_mean.ppm");
+ mln::io::ppm::save(i4_merge, "i4_merge.ppm");
+
+ save_histo(i4_mean, "h4_mean.pgm");
+ save_histo(i4_merge, "h4_merge.pgm");
+
+ // with restricted geodesic influence
+ l5_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l5_histo));
+ i5_mean = mln::labeling::mean_values(i0_input, l5_input, n_lbl);
+ i5_merge = mln::data::transform(i0_input,t_merge_lbl8_with_rgbn<n>(l5_histo));
+
+ compute_stats(i0_input, l5_input, h1_input, l5_histo, n_lbl);
+
+ mln::io::pgm::save(l5_input, "l5_input.pgm");
+ mln::io::ppm::save(i5_mean, "i5_mean.ppm");
+ mln::io::ppm::save(i5_merge, "i5_merge.ppm");
+
+ save_histo(i5_mean, "h5_mean.pgm");
+ save_histo(i5_merge, "h5_merge.pgm");
// END DUMPING
/*
@@ -685,25 +748,14 @@ void demo(const std::string& image, const unsigned min_volume)
*/
}
-/*
-int main_old()
-{
- demo<2>(); // 2.26 s
- demo<3>(); // 2.29 s
- demo<4>(); // 2.29 s
- demo<5>(); // 2.37 s
- demo<6>(); // 3.19 s
- demo<7>(); // 11.43 s
- demo<8>(); // 96.19 s
-}
-*/
+
void usage()
{
std::cout << std::endl;
std::cout << "regional_maxima" << std::endl;
std::cout << "image <name>" << std::endl;
std::cout << "quantification {5,6}" << std::endl;
- std::cout << "volume 1000" << std::endl;
+ std::cout << "min_volume 1000" << std::endl;
// 3 paramètres en entré:
// * l'image
@@ -712,8 +764,14 @@ void usage()
// sorties:
// * fichier de stats [etiquette|couleur moyenne|% image|% classé]
- // * couleur moyenne de l'étiquette + couleur specifique pour étiquette 0
- // * histo sur l'image d'étiquette
+ // * image de labels
+ // * image reconstruite avec la moyenne de chaque classe [i_mean]
+ // * image reconstruite avec les couleurs de chaque classe [i_merge]
+ // * histogramme original de l'image d'entrée [h_input]
+ // * histogramme projeté de mean [h_mean]
+ // * histogramme projeté de merge [h_merge]
+
+ // *
}
int main(int argc, char* args[])
--
1.5.6.5
1
0
last-svn-commit-207-gfe92959 Write the opening volume thresholds for the scribo image mp00082c.ppm.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/demo/labeling/regional_maxima/thresholds.txt: New documentation.
---
milena/sandbox/ChangeLog | 6 ++++
.../demo/labeling/regional_maxima/thresholds.txt | 27 ++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
create mode 100644 milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 11565c5..48cf813 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,12 @@
2009-12-23 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Write the opening volume thresholds for the scribo image mp00082c.ppm.
+
+ * green/demo/labeling/regional_maxima/thresholds.txt: New documentation.
+
+2009-12-23 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Experiment various quantifications on regional maxima labeling.
* green/doc/regional_maxima/cmp_quant/h0_input.pgm.gz: New histogram.
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt b/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
new file mode 100644
index 0000000..ddf5ca7
--- /dev/null
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
@@ -0,0 +1,27 @@
+image = 1169 x 1567 = 1831823
+
+
+% image | min_volume
+-----------------------
+ 0.05 % | 1000.00
+ 1.00 % | 18318.23
+ 5.00 % | 91591.15
+ 10.00 % | 183182.30
+ 15.00 % | 274773.45
+ 20.00 % | 366364.60
+ 25.00 % | 457955.75
+ 30.00 % | 549546.90
+ 35.00 % | 641138.05
+ 40.00 % | 732729.20
+ 45.00 % | 824320.35
+ 50.00 % | 915911.50
+ 55.00 % | 1007502.65
+ 60.00 % | 1099093.80
+ 65.00 % | 1190684.95
+ 70.00 % | 1282276.10
+ 75.00 % | 1373867.25
+ 80.00 % | 1465458.40
+ 85.00 % | 1557049.55
+ 90.00 % | 1648640.70
+ 95.00 % | 1740231.85
+100.00 % | 1831823.00
--
1.5.6.5
1
0
last-svn-commit-208-g7c558b5 Split the regional maxima binary in small atomic binaries.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/tools/annotating/histo: New directory.
* green/tools/annotating/histo/Makefile.am: New Makefile.
* green/tools/annotating/histo/histo.cc: New source file.
* green/tools/annotating/opening: New directory.
* green/tools/annotating/opening/Makefile.am: New Makefile.
* green/tools/annotating/opening/opening.cc: New source file.
* green/tools/annotating/regmax: New directory.
* green/tools/annotating/regmax/Makefile.am: New Makefile.
* green/tools/annotating/regmax/regmax.cc: New source file.
---
milena/sandbox/ChangeLog | 15 +++
.../annotating/histo}/Makefile.am | 9 +-
.../sandbox/green/tools/annotating/histo/histo.cc | 121 ++++++++++++++++++
.../annotating/opening}/Makefile.am | 9 +-
.../green/tools/annotating/opening/opening.cc | 79 ++++++++++++
.../annotating/regmax}/Makefile.am | 9 +-
.../green/tools/annotating/regmax/regmax.cc | 133 ++++++++++++++++++++
7 files changed, 360 insertions(+), 15 deletions(-)
copy milena/sandbox/green/{exp/annotating/nb_color => tools/annotating/histo}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/histo/histo.cc
copy milena/sandbox/green/{exp/annotating/nb_color => tools/annotating/opening}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/opening/opening.cc
copy milena/sandbox/green/{exp/annotating/nb_color => tools/annotating/regmax}/Makefile.am (96%)
create mode 100644 milena/sandbox/green/tools/annotating/regmax/regmax.cc
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index 48cf813..c8734e4 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -75,6 +75,21 @@
* bin/pgm_to_pbm.cc,
* bin/ppm_negate.cc: New.
+2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
+ Split the regional maxima binary in small atomic binaries.
+
+ * green/tools/annotating/histo: New directory.
+ * green/tools/annotating/histo/Makefile.am: New Makefile.
+ * green/tools/annotating/histo/histo.cc: New source file.
+ * green/tools/annotating/opening: New directory.
+ * green/tools/annotating/opening/Makefile.am: New Makefile.
+ * green/tools/annotating/opening/opening.cc: New source file.
+ * green/tools/annotating/regmax: New directory.
+ * green/tools/annotating/regmax/Makefile.am: New Makefile.
+ * green/tools/annotating/regmax/regmax.cc: New source file.
+
+
2009-12-23 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
Write the opening volume thresholds for the scribo image mp00082c.ppm.
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am b/milena/sandbox/green/tools/annotating/histo/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/histo/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/histo/Makefile.am
@@ -6,7 +6,6 @@
# TOOLS #
#########
-LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/histo/histo.cc b/milena/sandbox/green/tools/annotating/histo/histo.cc
new file mode 100644
index 0000000..ab0b8af
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/histo/histo.cc
@@ -0,0 +1,121 @@
+// TOOLS ==> Color histogram
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+#include <mln/core/image/dmorph/image_if.hh>
+
+#include <mln/data/compute.hh>
+#include <mln/data/transform.hh>
+
+#include <mln/display/display_histo.hh>
+
+#include <mln/fun/v2v/rgb8_to_rgbn.hh>
+
+#include <mln/io/dump/save.hh>
+#include <mln/io/pbm/load.hh>
+#include <mln/io/pbm/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/load.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/opt/at.hh>
+
+#include <mln/pw/value.hh>
+
+#include <mln/value/rgb8.hh>
+#include <mln/value/rgb.hh>
+
+
+template <unsigned n>
+void mk_histo(const std::string& input,
+ const std::string& output,
+ const std::string& histo,
+ const std::string& mask)
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image2d<t_rgbn> t_image2d_rgbn;
+ typedef mln::image2d<bool> t_image2d_bool;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::fun::v2v::rgb8_to_rgbn<n> t_rgb8_to_rgbn;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_image2d_rgb8 i0_input; // input rgb8
+ t_image2d_rgbn i1_input; // input rgbn
+ t_image2d_bool m0_input; // mask input
+ t_histo3d h1_input; // histo input
+ t_image2d_int_u8 p1_histo; // histo proj
+
+ mln::io::ppm::load(i0_input, input.c_str());
+ i1_input = mln::data::transform(i0_input, t_rgb8_to_rgbn());
+
+ if (0 < mask.size())
+ {
+ mln::io::pbm::load(m0_input, mask.c_str());
+ h1_input = mln::data::compute(t_histo3d_fun(),
+ (i1_input | mln::pw::value(m0_input)).rw());
+ }
+ else
+ {
+ h1_input = mln::data::compute(t_histo3d_fun(), i1_input);
+ }
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ p1_histo = mln::display::display_histo3d_unsigned(h1_input);
+ mln::io::dump::save(h1_input, histo.c_str());
+ mln::io::pgm::save(p1_histo, output.c_str());
+ // END DUMPING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "histo input.ppm q out.ppm histo.dump [msk.pbm]" << std::endl;
+ std::cout << "where" << std::endl;
+ std::cout << "input.ppm is the 8 bits color ppm image" << std::endl;
+ std::cout << "q is the degree of quanification {2,3,4,5,6,7,8}" << std::endl;
+ std::cout << "out.pgm is the r/g projection of the histogram" << std::endl;
+ std::cout << "out.dump is the quantified color histogram" << std::endl;
+ std::cout << "msk.pbm is the mask which select the pixels" << std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (5 == argc || 6 == argc)
+ {
+ const std::string input(args[1]);
+ const char q = args[2][0];
+ const std::string output(args[3]);
+ const std::string histo(args[4]);
+ const std::string mask(6 == argc? args[5] : "");
+
+ switch(q)
+ {
+ case '2': mk_histo<2>(input, output, histo, mask); break;
+ case '3': mk_histo<3>(input, output, histo, mask); break;
+ case '4': mk_histo<4>(input, output, histo, mask); break;
+ case '5': mk_histo<5>(input, output, histo, mask); break;
+ case '6': mk_histo<6>(input, output, histo, mask); break;
+ case '7': mk_histo<7>(input, output, histo, mask); break;
+ case '8': mk_histo<8>(input, output, histo, mask); break;
+ default: usage(); break;
+ }
+ }
+ else
+ usage();
+
+ return 0;
+}
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am b/milena/sandbox/green/tools/annotating/opening/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/opening/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/opening/Makefile.am
@@ -6,7 +6,6 @@
# TOOLS #
#########
-LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/opening/opening.cc b/milena/sandbox/green/tools/annotating/opening/opening.cc
new file mode 100644
index 0000000..3e1dbf2
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/opening/opening.cc
@@ -0,0 +1,79 @@
+// TOOLS ==> histogram filtering
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/data/compute.hh>
+
+#include <mln/display/display_histo.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+
+#include <mln/morpho/opening/volume.hh>
+
+#include <mln/value/int_u8.hh>
+
+void mk_opening(const std::string& input,
+ const unsigned min_vol,
+ const std::string& output,
+ const std::string& opened)
+{
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+
+ // START OF IMAGE PROCESSING CHAIN
+ t_histo3d h1_input; // histo input
+ t_histo3d h2_input; // histo input
+ t_image2d_int_u8 p1_histo; // histo proj
+
+ mln::io::dump::load(h1_input, input.c_str());
+ h2_input = mln::morpho::opening::volume(h1_input, mln::c6(), min_vol);
+ // END OF IMAGE PROCESSING CHAIN
+
+ // BEGIN DUMPING
+ p1_histo = mln::display::display_histo3d_unsigned(h2_input);
+ mln::io::dump::save(h2_input, opened.c_str());
+ mln::io::pgm::save(p1_histo, output.c_str());
+ // END DUMPING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "opening input.dump v out.dump out.ppm" << std::endl;
+ std::cout << "where" << std::endl;
+ std::cout << "input.dump is the 3d color input histo" << std::endl;
+ std::cout << "v is the minimum size of each composant" << std::endl;
+ std::cout << "out.pgm is the r/g proj of the opened histogram" << std::endl;
+ std::cout << "out.dump is the opened histogram" << std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (5 == argc)
+ {
+ const std::string input(args[1]);
+ const unsigned min_vol = atoi(args[2]);
+ const std::string output(args[3]);
+ const std::string opened(args[4]);
+
+ mk_opening(input, min_vol, output, opened);
+ }
+ else
+ usage();
+
+ return 0;
+}
diff --git a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am b/milena/sandbox/green/tools/annotating/regmax/Makefile.am
similarity index 96%
copy from milena/sandbox/green/exp/annotating/nb_color/Makefile.am
copy to milena/sandbox/green/tools/annotating/regmax/Makefile.am
index 8e204c6..8cd7511 100644
--- a/milena/sandbox/green/exp/annotating/nb_color/Makefile.am
+++ b/milena/sandbox/green/tools/annotating/regmax/Makefile.am
@@ -6,7 +6,6 @@
# TOOLS #
#########
-LOADLIBES= -lboost_filesystem
INCLUDES= -I$(HOME)/svn/oln/trunk/milena/sandbox/green
#CXXFLAGS= -ggdb -O0 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
#CXXFLAGS= -DNDEBUG -O1 -Wall -W -pedantic -ansi -pipe $(INCLUDES)
@@ -16,17 +15,17 @@ RM= rm
MKDIR= mkdir -p
CP= cp
-SOURCE_PATTERN= green/exp
-BUILD__PATTERN= green/build/exp
+SOURCE_PATTERN= green/tools
+BUILD__PATTERN= green/build/tools
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)/
+BUILD__DIR= $(PWD)
else
# Case where make is done from source directory.
-SOURCE_DIR= $(PWD)/
+SOURCE_DIR= $(PWD)
BUILD__DIR= $(subst $(SOURCE_PATTERN),$(BUILD__PATTERN),$(PWD))
endif
diff --git a/milena/sandbox/green/tools/annotating/regmax/regmax.cc b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
new file mode 100644
index 0000000..2079bc4
--- /dev/null
+++ b/milena/sandbox/green/tools/annotating/regmax/regmax.cc
@@ -0,0 +1,133 @@
+// TOOLS ==> regmax on histo
+
+#include <iostream>
+
+#include <mln/accu/stat/histo3d_rgb.hh>
+
+#include <mln/core/macros.hh>
+#include <mln/core/alias/neighb3d.hh>
+#include <mln/core/image/image2d.hh>
+#include <mln/core/image/image3d.hh>
+
+#include <mln/data/compute.hh>
+
+#include <mln/debug/println.hh>
+#include <mln/display/display_histo.hh>
+
+#include <mln/io/dump/load.hh>
+#include <mln/io/dump/save.hh>
+#include <mln/io/pgm/load.hh>
+#include <mln/io/pgm/save.hh>
+#include <mln/io/ppm/save.hh>
+
+#include <mln/labeling/regional_maxima.hh>
+
+#include <mln/morpho/opening/volume.hh>
+
+#include <mln/value/label_8.hh>
+#include <mln/value/int_u8.hh>
+#include <mln/value/rgb8.hh>
+
+template <unsigned n>
+struct t_labeling_rgbn : mln::Function_v2v< t_labeling_rgbn<n> >
+{
+ typedef mln::value::rgb<n> t_rgbn;
+ typedef mln::value::label_8 t_lbl8;
+ typedef t_rgbn argument;
+ typedef t_lbl8 result;
+ typedef mln::image3d<t_lbl8> t_label;
+
+ const t_label& _label;
+
+ t_labeling_rgbn(const t_label& label) : _label(label) {}
+
+ result operator()(const argument& c) const
+ {
+ t_lbl8 tmp = mln::opt::at(_label, c.blue(), c.red(), c.green());
+
+ return tmp;
+ }
+};
+
+void mk_regmax(const std::string& input,
+ const std::string& quant,
+ const std::string& histo,
+ const std::string& label,
+ const std::string& output)
+{
+ typedef mln::value::label_8 t_lbl8;
+ typedef mln::value::rgb8 t_rgb8;
+ typedef mln::value::rgbn t_rgbn;
+ typedef mln::value::int_u8 t_int_u8;
+ typedef mln::algebra::vec<3,float> t_v3f;
+ typedef mln::image2d<t_int_u8> t_image2d_int_u8;
+ typedef mln::image2d<t_rgb8> t_image2d_rgb8;
+ typedef mln::image3d<t_lbl8> t_image3d_lbl8;
+ typedef mln::image2d<t_lbl8> t_image2d_lbl8;
+ typedef mln::image3d<unsigned> t_histo3d;
+ typedef mln::accu::meta::stat::histo3d_rgb t_histo3d_fun;
+ typedef mln::accu::stat::mean<t_v3f,t_v3f,t_v3f> t_mean;
+ typedef mln::util::array<t_v3f> t_mean_array;
+
+ t_image2d_rgb8 i0_input; // input img
+ t_image2d_rgbn i1_input; // quant img
+ t_histo3d h2_input; // opened histo
+// t_image2d_int_u8 p2_label; // histo proj
+ t_image2d_lbl8 p2_label; // histo proj
+// t_image2d_rgb8 p2_label; // histo proj
+ t_image3d_lbl8 l2_histo; // label histo
+ t_mean_array m2_label; // palette
+
+ t_lbl8 n_lbl; // nb class
+
+ // BEGIN LOADING
+ mln::io::ppm::load(i0_input, input.c_str());
+ mln::io::ppm::load(i1_input, quant.c_str());
+ mln::io::dump::load(h2_input, histo.c_str());
+ // END LOADING
+
+ // BEGIN IMAGE PROCESSING
+ l2_histo = mln::labeling::regional_maxima(h2_input, mln::c6(), n_lbl);
+ // END IMAGE PROCESSING
+
+ // BEGIN SAVING
+ mln::debug::println(h2_input);
+ mln::io::dump::save(l2_histo, labeled.c_str());
+
+ l2_input = mln::data::transform(i1_input, t_labeling_rgbn<n>(l2_histo));
+ m2_label = mln::labeling::compute(t_mean(), i0_input, l2_input, n_labels);
+ p2_label =mln::display::display3_histo3d_unsigned(h2_input,l2_histo,m2_label);
+
+// mln::io::pgm::save(p2_label, output.c_str());
+ mln::io::ppm::save(p2_label, output.c_str());
+ std::cout << "Nb classes : " << n_lbl << std::endl;
+ // END SAVING
+}
+
+
+void usage()
+{
+ std::cout << std::endl;
+ std::cout << "regmax input.dump out.dump out.ppm" << std::endl;
+ std::cout << "where" << std::endl;
+ std::cout << "input.dump is opened histo" << std::endl;
+ std::cout << "out.pgm is the r/g proj of the opened histogram" << std::endl;
+ std::cout << "out.dump is the labeled histogram" << std::endl;
+ std::cout << std::endl;
+}
+
+int main(int argc, char* args[])
+{
+ if (4 == argc)
+ {
+ const std::string input(args[1]);
+ const std::string output(args[2]);
+ const std::string labeled(args[3]);
+
+ mk_regmax(input, output, labeled);
+ }
+ else
+ usage();
+
+ return 0;
+}
--
1.5.6.5
1
0
last-svn-commit-209-g5179913 Build translation table between number of pixels and percentage of pixels in image for the scribo database.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/demo/labeling/regional_maxima/threshold.txt: New translation
table.
---
milena/sandbox/ChangeLog | 8 ++++++++
.../demo/labeling/regional_maxima/thresholds.txt | 15 +++++++++++++++
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index c8734e4..de56c51 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,14 @@
2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Build translation table between number of pixels and percentage of
+ pixels in image for the scribo database.
+
+ * green/demo/labeling/regional_maxima/threshold.txt: New translation
+ table.
+
+2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Split the regional maxima binary in small atomic binaries.
* green/tools/annotating/histo: New directory.
diff --git a/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt b/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
index ddf5ca7..58f3e6a 100644
--- a/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
+++ b/milena/sandbox/green/demo/labeling/regional_maxima/thresholds.txt
@@ -5,9 +5,24 @@ image = 1169 x 1567 = 1831823
-----------------------
0.05 % | 1000.00
1.00 % | 18318.23
+ 2.00 % | 36636.46
+ 3.00 % | 54954.69
+ 4.00 % | 73272.92
5.00 % | 91591.15
+ 6.00 % | 109909.38
+ 7.00 % | 128227.61
+ 8.00 % | 146545.84
+ 9.00 % | 164864.07
10.00 % | 183182.30
+ 11.00 % | 201500.53
+ 12.00 % | 219818.76
+ 13.00 % | 238136.99
+ 14.00 % | 256455.22
15.00 % | 274773.45
+ 16.00 % | 293091.68
+ 17.00 % | 311409.91
+ 18.00 % | 329728.14
+ 19.00 % | 348046.37
20.00 % | 366364.60
25.00 % | 457955.75
30.00 % | 549546.90
--
1.5.6.5
1
0
last-svn-commit-210-g17304c0 Extend the histogram visualization tools for new projection concept.
by green 30 Jun '10
by green 30 Jun '10
30 Jun '10
* green/mln/display/project_histo.hh (project2_histo): New functions
that keep the max of the histogram or the class associate to it while
projecting along a direction.
* green/mln/display/project_histo.hh (project3_histo): New functions
that keep the color of the class associate to the histogram maximum
while projecting along a direction.
* green/mln/display/display_histo.hh: New interface functions for
project2_histo and project3_histo.
---
milena/sandbox/ChangeLog | 13 +
milena/sandbox/green/mln/display/display_histo.hh | 50 +++
milena/sandbox/green/mln/display/project_histo.hh | 344 +++++++++++++++++++++
3 files changed, 407 insertions(+), 0 deletions(-)
diff --git a/milena/sandbox/ChangeLog b/milena/sandbox/ChangeLog
index de56c51..f56ea7a 100644
--- a/milena/sandbox/ChangeLog
+++ b/milena/sandbox/ChangeLog
@@ -77,6 +77,19 @@
2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+ Extend the histogram visualization tools for new projection concept.
+
+ * green/mln/display/project_histo.hh (project2_histo): New functions
+ that keep the max of the histogram or the class associate to it while
+ projecting along a direction.
+ * green/mln/display/project_histo.hh (project3_histo): New functions
+ that keep the color of the class associate to the histogram maximum
+ while projecting along a direction.
+ * green/mln/display/display_histo.hh: New interface functions for
+ project2_histo and project3_histo.
+
+2010-01-05 Yann Jacquelet <jacquelet(a)lrde.epita.fr>
+
Build translation table between number of pixels and percentage of
pixels in image for the scribo database.
diff --git a/milena/sandbox/green/mln/display/display_histo.hh b/milena/sandbox/green/mln/display/display_histo.hh
index 1fd5da4..2ba0b61 100644
--- a/milena/sandbox/green/mln/display/display_histo.hh
+++ b/milena/sandbox/green/mln/display/display_histo.hh
@@ -33,6 +33,8 @@
# include <mln/display/project_histo.hh>
# include <mln/fun/v2v/log.hh>
# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/label_8.hh>
/// \file
@@ -55,6 +57,20 @@ namespace mln
image2d<value::int_u8>
display_histo3d_unsigned(const image3d<unsigned>& histo);
+ image2d<value::int_u8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo);
+
+ image2d<value::label_8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label);
+
+ image2d<value::rgb8>
+ display3_histo3d_unsigned(const image3d<unsigned>& histo);
+
+ image2d<value::rgb8>
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label);
+
#ifndef MLN_INCLUDE_ONLY
/// \brief Allow the visualization of a 3d histogram by projection.
@@ -86,6 +102,40 @@ namespace mln
return proj_int;
}
+ image2d<value::int_u8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo)
+ {
+ image2d<value::int_u8> proj = project2_histo<0>(histo);
+
+ return proj;
+ }
+
+ image2d<value::label_8>
+ display2_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label)
+ {
+ image2d<value::label_8> proj = project2_histo<0>(histo, label);
+
+ return proj;
+ }
+
+ image2d<value::rgb8>
+ display3_histo3d_unsigned(const image3d<unsigned>& histo)
+ {
+ image2d<value::rgb8> proj = project3_histo<0>(histo);
+
+ return proj;
+ }
+
+ image2d<value::rgb8>
+ display3_histo3d_unsigned(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label)
+ {
+ image2d<value::rgb8> proj = project3_histo<0>(histo, label);
+
+ return proj;
+ }
+
#endif // ! MLN_INCLUDE_ONLY
diff --git a/milena/sandbox/green/mln/display/project_histo.hh b/milena/sandbox/green/mln/display/project_histo.hh
index f0e6858..d842c70 100644
--- a/milena/sandbox/green/mln/display/project_histo.hh
+++ b/milena/sandbox/green/mln/display/project_histo.hh
@@ -37,6 +37,12 @@
# include <mln/accu/image/take.hh>
# include <mln/accu/image/to_result.hh>
+# include <mln/opt/at.hh>
+
+# include <mln/value/int_u8.hh>
+# include <mln/value/rgb8.hh>
+# include <mln/value/label_8.hh>
+
/// \file
///
/// \brief Allow the visualization of 3d histogram.
@@ -54,6 +60,10 @@ namespace mln
image2d<mln_result(A)>
project_histo(const image3d<V>& histo);
+ template <typename A, unsigned direction, typename V>
+ image2d<mln_result(A)>
+ project2_histo(const image3d<V>& histo);
+
# ifndef MLN_INCLUDE_ONLY
/// \brief Allow the visualization of 3d histogram.
@@ -86,6 +96,340 @@ namespace mln
return accu::image::to_result(histo_accu);
}
+ template <unsigned direction>
+ image2d<value::int_u8>
+ project2_histo(const image3d<unsigned>& histo)
+ {
+ image2d<value::int_u8> result;
+
+ if (0 == direction) // blue
+ {
+ image2d<value::int_u8> arg_max(histo.ncols(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nslices(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nrows(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = pos;
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d<value::int_u8> arg_max(histo.nrows(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.nslices(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.ncols(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = pos;
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d<value::int_u8> arg_max(histo.nrows(), histo.ncols());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nslices(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = pos;
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+ template <unsigned direction>
+ image2d<value::label_8>
+ project2_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label)
+ {
+ image2d<value::label_8> result;
+
+ if (0 == direction) // blue
+ {
+ image2d<value::label_8> arg_max(histo.ncols(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nslices(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nrows(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = opt::at(label,i,j,pos);
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d<value::label_8> arg_max(histo.nrows(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.nslices(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.ncols(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = opt::at(label,pos,i,j);
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d<value::label_8> arg_max(histo.nrows(), histo.ncols());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nslices(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = opt::at(label,i,pos,j);
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+
+ // FIXME ... determine the color of each class.
+ template <unsigned direction>
+ image2d<value::rgb8>
+ project3_histo(const image3d<unsigned>& histo,
+ const image3d<value::label_8>& label)
+ {
+ image2d<value::rgb8> result;
+
+ if (0 == direction) // blue
+ {
+ image2d<value::rgb8> arg_max(histo.ncols(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nslices(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nrows(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = value::rgb8(i,j,pos);
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d<value::rgb8> arg_max(histo.nrows(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.nslices(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.ncols(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = value::rgb8(pos,i,j);
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d<value::rgb8> arg_max(histo.nrows(), histo.ncols());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nslices(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ // FIXME ... how to fix the n of rgb
+ opt::at(arg_max,i,j) = value::rgb8(i,pos,j);
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
+ template <unsigned direction>
+ image2d<value::rgb8>
+ project3_histo(const image3d<unsigned>& histo)
+ {
+ image2d<value::rgb8> result;
+
+ if (0 == direction) // blue
+ {
+ image2d<value::rgb8> arg_max(histo.ncols(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nslices(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nrows(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = value::rgb8(i,j,pos);
+ }
+
+ result = arg_max;
+ }
+ else if (1 == direction) // red
+ {
+ image2d<value::rgb8> arg_max(histo.nrows(), histo.nslices());
+
+ for (unsigned j = 0; j < histo.nslices(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.ncols(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ opt::at(arg_max,i,j) = value::rgb8(pos,i,j);
+ }
+
+ result = arg_max;
+ }
+ else // 2 == direction // green
+ {
+ image2d<value::rgb8> arg_max(histo.nrows(), histo.ncols());
+
+ for (unsigned j = 0; j < histo.ncols(); ++j)
+ for (unsigned i = 0; i < histo.nrows(); ++i)
+ {
+ unsigned max = 0; // minimum as possible
+ signed pos = -1;
+
+ for (unsigned k = 0; k < histo.nslices(); ++k)
+ {
+ if (max <= opt::at(histo,i,j,k))
+ {
+ max = opt::at(histo,i,j,k);
+ pos = k;
+ }
+ }
+
+ // FIXME ... how to fix the n of rgb
+ opt::at(arg_max,i,j) = value::rgb8(i,pos,j);
+ }
+
+ result = arg_max;
+ }
+
+ return result;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
--
1.5.6.5
1
0