URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2008-01-18 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Update processing of scores.
* sandbox/nivault/extract_score.cc: Update, processing and
labelling of big connected components, closing for highlight
notes and getting of an horizontal projection of image for
highlight lines.
---
extract_score.cc | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 68 insertions(+), 5 deletions(-)
Index: trunk/milena/sandbox/nivault/extract_score.cc
===================================================================
--- trunk/milena/sandbox/nivault/extract_score.cc (revision 1671)
+++ trunk/milena/sandbox/nivault/extract_score.cc (revision 1672)
@@ -63,6 +63,7 @@
# include <mln/draw/mesh.hh>
# include <mln/level/stretch.hh>
+# include <mln/linear/gaussian.hh>
# include <mln/core/image_if_value.hh>
# include <mln/core/sub_image.hh>
@@ -78,7 +79,8 @@
typedef point2d P;
typedef image2d<bool> IB;
-typedef image2d<int_u8> IU;
+typedef image2d<int_u8> IU8;
+typedef image2d<unsigned int> IU;
typedef image2d<value::rgb8> O;
template <typename I>
@@ -99,7 +101,7 @@
draw::line (image, p3, p1, val);
}
-IB to_binary(IU in, mln_value_(IU) val)
+IB to_binary(IU8 in, mln_value_(IU8) val)
{
// Divise L'image en deux :
// box2d gb = score_u.domain();
@@ -108,7 +110,7 @@
// image2d< accu::mean_<int_u8> > ima_mean(sb);
// {
-// mln_piter_(IU) p(gb);
+// mln_piter_( IU8) p(gb);
// for_all(p)
// ima_mean(point2d(p[0] / 2, p[1] / 2)).take(score_u(p));
@@ -117,7 +119,7 @@
IB score_b(in.domain());
{
- mln_piter_(IU) p(in.domain());
+ mln_piter_( IU8) p(in.domain());
for_all(p)
score_b(p) = in(p) < val;
@@ -126,6 +128,30 @@
return score_b;
}
+IU8 projection(IB ima, int coord)
+{
+ box2d smb = ima.domain();
+
+ point2d& pt = smb.pmax();
+ pt[coord] = 0;
+
+ IU projected(smb);
+ IU8 projected_stretched(smb);
+ level::fill(projected, literal::zero);
+
+ mln_piter_(IB) p(ima.domain());
+
+ point2d pt2;
+ for_all(p)
+ {
+ pt2 = p;
+ pt2[coord] = 0;
+ projected(pt2) += ima(p);
+ }
+ level::stretch(projected, projected_stretched);
+ return projected_stretched;
+}
+
int
main(int argc, char** argv)
{
@@ -137,12 +163,49 @@
exit(1);
}
- IU score_u;
+ IU8 score_u;
io::pgm::load(score_u, argv[1]);
IB score_b = to_binary(score_u, 175);
io::pbm::save(score_b, argv[2]);
+
+
+// { // Obtenir un histogramme vertical pour reperer les lignes de portée.
+// IU8 histo_col = projection(score_b, 1);
+
+// IU8 histo_col_blur(histo_col.domain());
+// linear::gaussian(histo_col, 5, histo_col_blur);
+// level::stretch(histo_col_blur, histo_col_blur);
+
+// io::pgm::save(histo_col, "histo_col.pgm");
+// io::pgm::save(histo_col_blur, "histo_col_blur.pgm");
+// }
+
+// { // Labelling des grosses composant connexes pour étiqueter les differentes
portées.
+// IB only_big(score_b.domain());
+// morpho::opening_area(score_b, c4(), 5000, only_big);
+
+// unsigned nlabels;
+// IU inter_labeled = labeling::blobs(only_big, c4(), nlabels); // labelling blobs
don't use algo(input, output) formalism
+// IU8 labeled(inter_labeled.domain()); // and it should
return int_u8 ?
+// level::stretch(inter_labeled, labeled);
+// io::pgm::save(labeled, "labeled.pgm");
+// }
+
+// { // fermeture avec un disk et un element vertial pour reperer les notes.
+// IB closed1 = morpho::closing(score_b, win::vline2d(5));
+// IB closed2 = morpho::closing(score_b, win::disk2d(5));
+// morpho::opening_area(closed1, c4(), 20, closed1);
+// morpho::opening_area(closed2, c4(), 15, closed2);
+// io::pbm::save(closed1, "closed1.pbm");
+// io::pbm::save(closed2, "closed2.pbm");
+// }
+
+ { // Fermeture avec un element struturant en horizontale pour obtenir les lignes de
portée.
+ IB hclosed = morpho::closing(score_b, win::hline2d(73));
+ io::pbm::save(hclosed, "hclosed.pbm");
+ }
}