---
scribo/ChangeLog | 12 ++-
scribo/upsampling/{bs2x.hh => eagle.hh} | 108 +++++++++++++++----------------
2 files changed, 61 insertions(+), 59 deletions(-)
copy scribo/upsampling/{bs2x.hh => eagle.hh} (50%)
diff --git a/scribo/ChangeLog b/scribo/ChangeLog
index 609abf5..b03b8e4 100644
--- a/scribo/ChangeLog
+++ b/scribo/ChangeLog
@@ -1,11 +1,15 @@
+2010-06-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ * upsampling/eagle.hh: Add a new upsampling algorithm.
+
2010-06-23 Arthur Crepin-Leblond <crepin(a)stockholm.lrde.epita.fr>
Add extensions to ICDAR XML format.
-
+
* io/xml/save_text_lines.hh: Rename as...
* io/xml/save.hh: ...this.
-
- * src/pbm_text_in_doc.cc: update call to io::xml::save.
+
+ * src/pbm_text_in_doc.cc: update call to io::xml::save.
2010-06-18 green <jacquelet(a)lrde.epita.fr>
@@ -14,7 +18,7 @@
* sandbox: New experimental directory.
* sandbox/green: New green'work.
* sandbox/green/ChangeLog: New ChangeLog file.
-
+
2010-06-15 Guillaume Lazzara <z(a)lrde.epita.fr>
Small fixes.
diff --git a/scribo/upsampling/bs2x.hh b/scribo/upsampling/eagle.hh
similarity index 50%
copy from scribo/upsampling/bs2x.hh
copy to scribo/upsampling/eagle.hh
index c701e47..eab1989 100644
--- a/scribo/upsampling/bs2x.hh
+++ b/scribo/upsampling/eagle.hh
@@ -23,34 +23,32 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef SCRIBO_UPSAMPLING_BS2X_HH
-# define SCRIBO_UPSAMPLING_BS2X_HH
+#ifndef SCRIBO_UPSAMPLING_EAGLE_HH_
+# define SCRIBO_UPSAMPLING_EAGLE_HH_
/// \file
///
/// Scale 2x algorithm for binary images.
# include <mln/core/concept/image.hh>
-# include <mln/core/alias/box2d.hh>
+# include <mln/core/def/coord.hh>
# include <mln/opt/at.hh>
-# include <mln/geom/all.hh>
-
-
+# include <mln/make/box2d.hh>
namespace scribo
{
namespace upsampling
{
- using namespace mln;
+ using namespace mln;
/// \brief Scale 2x algorithm for binary images.
///
//
template <typename I>
mln_concrete(I)
- bs2x(const Image<I>& input);
+ eagle(const Image<I>& ima);
@@ -59,80 +57,81 @@ namespace scribo
template <typename I>
mln_concrete(I)
- bs2x(const mln::Image<I>& input_)
+ eagle(const Image<I>& input_)
{
- trace::entering("scribo::upsampling::bs2x");
+ trace::entering("scribo::upsampling::eagle");
+ typedef mln_value(I) V;
const I& input = exact(input_);
- mlc_is(mln_domain(I), mln::box2d)::check();
- mlc_is(mln_value(I), bool)::check();
-
mln_precondition(input.is_valid());
- typedef mln_value(I) V;
-
mln::def::coord
mrow = geom::min_row(input),
- mcol = geom::min_col(input);
+ mcol = geom::min_col(input),
+ mxrow = geom::max_row(input),
+ mxcol = geom::max_col(input);
mln_piter(I) p(input.domain());
- mln_concrete(I) output(mln::make::box2d(mrow, mcol,
- mrow + 2 * input.nrows() - 1,
- mcol + 2 * input.ncols() - 1));
+ mln_concrete(I)
+ output(mln::make::box2d(mrow, mcol,
+ mrow + 2 * input.nrows() - 1,
+ mcol + 2 * input.ncols() - 1));
+
for_all(p)
{
mln::def::coord
- row = mrow + 2 * (p.row() - mrow),
- col = mcol + 2 * (p.col() - mcol);
+ prow = p.row() - mrow,
+ pcol = p.col() - mcol;
- if(p.row() == geom::min_row(input)
- || p.col() == geom::min_col(input)
- || p.row() == geom::max_row(input)
- || p.col() == geom::max_col(input))
+ if (p.row() == mrow
+ || p.col() == mcol
+ || p.row() == mxrow
+ || p.col() == mxcol)
{
- mln::box2d b = mln::make::box2d(row, col,
- row + 1, col + 1);
+ box2d b = mln::make::box2d(2 * prow, 2 * pcol,
+ 2 * prow + 1, 2 * pcol + 1);
+ mln_piter_(box2d) pb(b);
V value = opt::at(input, p.row(), p.col());
- data::fill((output | b).rw(), value);
+ for_all(pb)
+ opt::at(output, mrow + pb.row(), mcol + pb.col()) = value;
}
else
{
- // nw n ne
- //
- // w value e
- //
- // sw s se
-
- V n = input(p + mln::up),
- s = input(p + mln::down),
- e = input(p + mln::right),
- w = input(p + mln::left),
- nw = input(p + mln::up_left),
- ne = input(p + mln::up_right),
- sw = input(p + mln::down_left),
- se = input(p + mln::down_right),
- value = input(p);
-
- if(e != w && n != s)
+ V
+ n = opt::at(input, p.row() - 1, p.col()),
+ s = opt::at(input, p.row() + 1, p.col()),
+ e = opt::at(input, p.row(), p.col() + 1),
+ w = opt::at(input, p.row(), p.col() - 1),
+ nw = opt::at(input, p.row() - 1, p.col() - 1),
+ ne = opt::at(input, p.row() - 1, p.col() + 1),
+ sw = opt::at(input, p.row() + 1, p.col() - 1),
+ se = opt::at(input, p.row() + 1, p.col() + 1),
+ value = opt::at(input, p.row(), p.col());
+
+ if (e != w || n != s || e != n)
{
- opt::at(output, row, col) = (w == n &&((se != nw) || !value)) ? w : value;
- opt::at(output, row, col + 1) = (e == n &&((sw != ne) || !value)) ? e :
value;
- opt::at(output, row + 1, col) = (w == s &&((ne != sw) || !value)) ? w :
value;
- opt::at(output, row + 1, col + 1) = (e == s &&((nw != se) || !value)) ? e :
value;
+ opt::at(output, mrow + 2 * prow, mcol + 2 * pcol) = ((w == n && w == nw
&& nw == n) ? nw : value);
+ opt::at(output, mrow + 2 * prow, mcol + 2 * pcol + 1) = ((e == n && e == ne
&& ne == n) ? ne : value);
+ opt::at(output, mrow + 2 * prow + 1, mcol + 2 * pcol) = ((w == s && w == sw
&& sw == s) ? sw : value);
+ opt::at(output, mrow + 2 * prow + 1, mcol + 2 * pcol + 1) = ((e == s && e ==
se && se == s) ? se : value);
}
else
{
- mln::box2d b = mln::make::box2d(row, col,
- row + 1, col + 1);
- data::fill((output | b).rw(), value);
+ box2d b = mln::make::box2d(2 * prow, 2 * pcol,
+ 2 * prow + 1, 2 * pcol + 1);
+ mln_piter_(box2d) pb(b);
+ V value = opt::at(input, p.row(), p.col());
+
+ for_all(pb)
+ opt::at(output, mrow + pb.row(), mcol + pb.col()) = value;
}
}
}
- trace::exiting("scribo::upsampling::bs2x");
+ trace::exiting("scribo::upsampling::eagle");
return output;
}
@@ -143,5 +142,4 @@ namespace scribo
} // end of namespace scribo
-
-#endif // ! SCRIBO_UPSAMPLING_BS2X_HH
+#endif // ! SCRIBO_UPSAMPLING_EAGLE_HH_
--
1.5.6.5