URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-10-22 Matthieu Garrigues <garrigues(a)lrde.epita.fr>
Enlarge for boxes.
* mln/convert/to_image.hh: Update convert::to_image(pset).
* mln/core/box.hh: (box_<P>::to_larger) New,
(box_<P>::enlarge) New.
---
convert/to_image.hh | 9 +++++----
core/box.hh | 32 ++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+), 4 deletions(-)
Index: trunk/milena/mln/core/box.hh
===================================================================
--- trunk/milena/mln/core/box.hh (revision 1367)
+++ trunk/milena/mln/core/box.hh (revision 1368)
@@ -107,6 +107,12 @@
*/
bool has(const P& p) const;
+ /// Enlarge the box with a border \p b.
+ void enlarge(unsigned b);
+
+ /// Give a larger box.
+ box_<P> to_larger(unsigned b) const;
+
protected:
P pmin_, pmax_;
};
@@ -203,6 +209,32 @@
}
template <typename P>
+ void
+ box_<P>::enlarge(unsigned b)
+ {
+ for (unsigned i = 0; i < P::dim; ++i)
+ {
+ pmin[i] -= b;
+ pmax[i] += b;
+ }
+ }
+
+
+ template <typename P>
+ box_<P>
+ box_<P>::to_larger(unsigned b) const
+ {
+ box_<P> tmp = *this;
+
+ for (unsigned i = 0; i < P::dim; ++i)
+ {
+ tmp.pmin[i] -= b;
+ tmp.pmax[i] += b;
+ }
+ return tmp;
+ }
+
+ template <typename P>
std::ostream& operator<<(std::ostream& ostr, const box_<P>& b)
{
return ostr << "[" << b.pmin() << ".." <<
b.pmax() << ']';
Index: trunk/milena/mln/convert/to_image.hh
===================================================================
--- trunk/milena/mln/convert/to_image.hh (revision 1367)
+++ trunk/milena/mln/convert/to_image.hh (revision 1368)
@@ -103,9 +103,10 @@
{
- /// Convert a point set \p pset into a binary image.
+ /// Convert a point set \p pset into a binary image. Width of the
+ /// converted image will be pset.bbox + 2 * \p border.
template <typename S>
- mln_image_from(S, bool) to_image(const Point_Set<S>& pset);
+ mln_image_from(S, bool) to_image(const Point_Set<S>& pset, unsigned border
= 1);
/// Convert a window \p win into a binary image.
template <typename W>
@@ -126,10 +127,10 @@
# ifndef MLN_INCLUDE_ONLY
template <typename S>
- mln_image_from(S, bool) to_image(const Point_Set<S>& pset_)
+ mln_image_from(S, bool) to_image(const Point_Set<S>& pset_, unsigned
border)
{
const S& pset = exact(pset_);
- mln_image_from(S, bool) ima(pset.bbox());
+ mln_image_from(S, bool) ima(pset.bbox().to_larger(border));
level::fill(ima, false);
mln_piter(S) p(pset);
for_all(p)