Commit 18232963 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Replace 2D specific methods in 2D images by routines.

	* mln/geom/max_col.hh: New.
	* mln/geom/nrows.hh: New.
	* mln/geom/min_row.hh: New.
	* mln/geom/max_row.hh: New.
	* mln/geom/ncols.hh: New.
	* mln/geom/size2d.hh: New.
	* mln/geom/min_col.hh: New.

	* mln/core/image2d_b.hh (image2d_b): Remove inheritance to
	box_impl.
	
	* tests/image2d_b.cc,
	* mln/core/pixter2d_b.hh,
	* mln/io/save_pgm.hh,
	* mln/io/load_pgm.hh,
	* mln/level/was.median.hh,
	* mln/level/median.hh,
	* mln/level/fast_median.hh,
	* mln/canvas/sbrowsing.hh: Update.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@1058 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 9c11b307
2007-08-28 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Replace 2D specific methods in 2D images by routines.
* mln/geom/max_col.hh: New.
* mln/geom/nrows.hh: New.
* mln/geom/min_row.hh: New.
* mln/geom/max_row.hh: New.
* mln/geom/ncols.hh: New.
* mln/geom/size2d.hh: New.
* mln/geom/min_col.hh: New.
* mln/core/image2d_b.hh (image2d_b): Remove inheritance to
box_impl.
* tests/image2d_b.cc,
* mln/core/pixter2d_b.hh,
* mln/io/save_pgm.hh,
* mln/io/load_pgm.hh,
* mln/level/was.median.hh,
* mln/level/median.hh,
* mln/level/fast_median.hh,
* mln/canvas/sbrowsing.hh: Update.
2007-08-28 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Fix compilation errors.
......
......@@ -34,6 +34,7 @@
*/
# include <mln/core/dpoint2d.hh> // for "up"
# include <mln/geom/size2d.hh>
namespace mln
......@@ -69,11 +70,11 @@ namespace mln
{
mln_precondition(f.input.has_data());
int
min_row = f.input.min_row(), max_row = f.input.max_row(),
min_col = f.input.min_col(), max_col = f.input.max_col();
min_row = geom::min_row(f.input), max_row = geom::max_row(f.input),
min_col = geom::min_col(f.input), max_col = geom::max_col(f.input);
// p
f.p = f.input.domain().pmin() + up;
f.p = f.input.bbox().pmin() + up;
int& row = f.p.row();
int& col = f.p.col();
......
......@@ -34,7 +34,6 @@
*/
# include <mln/core/internal/image_base.hh>
# include <mln/core/internal/box_impl.hh>
# include <mln/core/box2d.hh>
# include <mln/border/thickness.hh>
......@@ -75,8 +74,7 @@ namespace mln
* thickness around data.
*/
template <typename T>
struct image2d_b : public internal::image_base_< box2d, image2d_b<T> >,
public internal::box_impl_< 2, int, image2d_b<T> >
struct image2d_b : public internal::image_base_< box2d, image2d_b<T> >
{
// Warning: just to make effective types appear in Doxygen:
typedef box2d pset;
......
......@@ -35,6 +35,7 @@
# include <mln/core/internal/pixel_iterator_base.hh>
# include <mln/core/point2d.hh>
# include <mln/geom/size2d.hh>
......@@ -84,8 +85,8 @@ namespace mln
{
mln_precondition(image.has_data());
border_x2_ = 2 * image.border();
row_offset_ = image.max_col() - image.min_col() + 1 + border_x2_;
eor_ = & image.at(image.min_row(), image.max_col()) + 1;
row_offset_ = geom::max_col(image) - geom::min_col(image) + 1 + border_x2_;
eor_ = & image.at(geom::min_row(image), geom::max_col(image)) + 1;
}
template <typename I>
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_MAX_COL_HH
# define MLN_GEOM_MAX_COL_HH
/*! \file mln/geom/max_col.hh
*
* \brief Give the maximum column of an image.
*/
# include <mln/core/concept/image.hh>
namespace mln
{
namespace geom
{
/// Give the maximum column of an image.
template <typename I>
mln_coord(I) max_col(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_coord(I) max_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmax().col();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_MAX_COL_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_MAX_ROW_HH
# define MLN_GEOM_MAX_ROW_HH
/*! \file mln/geom/max_row.hh
*
* \brief Give the maximum row of an image.
*/
# include <mln/core/concept/image.hh>
namespace mln
{
namespace geom
{
/// Give the maximum row of an image.
template <typename I>
mln_coord(I) max_row(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_coord(I) max_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmax().row();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_MAX_ROW_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_MIN_COL_HH
# define MLN_GEOM_MIN_COL_HH
/*! \file mln/geom/min_col.hh
*
* \brief Give the minimum column of an image.
*/
# include <mln/core/concept/image.hh>
namespace mln
{
namespace geom
{
/// Give the minimum column of an image.
template <typename I>
mln_coord(I) min_col(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_coord(I) min_col(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmin().col();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_MIN_COL_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_MIN_ROW_HH
# define MLN_GEOM_MIN_ROW_HH
/*! \file mln/geom/min_row.hh
*
* \brief Give the minimum row of an image.
*/
# include <mln/core/concept/image.hh>
namespace mln
{
namespace geom
{
/// Give the minimum row of an image.
template <typename I>
mln_coord(I) min_row(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
mln_coord(I) min_row(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return exact(ima).bbox().pmin().row();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_MIN_ROW_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_NCOLS_HH
# define MLN_GEOM_NCOLS_HH
/*! \file mln/geom/ncols.hh
*
* \brief Give the number of columns of an image.
*/
# include <mln/geom/min_col.hh>
# include <mln/geom/max_col.hh>
namespace mln
{
namespace geom
{
/// Give the number of columns of an image.
template <typename I>
unsigned ncols(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
unsigned ncols(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return geom::max_col(ima) - geom::min_col(ima) + 1;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_NCOLS_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_NROWS_HH
# define MLN_GEOM_NROWS_HH
/*! \file mln/geom/nrows.hh
*
* \brief Give the number of rows of an image.
*/
# include <mln/geom/min_row.hh>
# include <mln/geom/max_row.hh>
namespace mln
{
namespace geom
{
/// Give the number of rows of an image.
template <typename I>
unsigned nrows(const Image<I>& ima);
# ifndef MLN_INCLUDE_ONLY
template <typename I>
unsigned nrows(const Image<I>& ima)
{
mln_precondition(exact(ima).has_data());
return geom::max_row(ima) - geom::min_row(ima) + 1;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::geom
} // end of namespace mln
#endif // ! MLN_GEOM_NROWS_HH
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_GEOM_SIZE2D_HH
# define MLN_GEOM_SIZE2D_HH
/*! \file mln/geom/size2d.hh
*
* \brief Facade to include 2D size access routines.
*/
# include <mln/geom/nrows.hh>
# include <mln/geom/ncols.hh>
#endif // ! MLN_GEOM_SIZE2D_HH
......@@ -137,11 +137,11 @@ namespace mln
point2d p = make::point2d(0, ima.domain().pmin().col());
typedef mln_value(I) V;
const mln_coord(I)
min_row = ima.domain().pmin().row(),
max_row = ima.domain().pmax().row();
min_row = geom::min_row(ima),
max_row = geom::max_row(ima);
if (sizeof(V) == 1)
{
size_t len = ima.ncols() * sizeof(mln_enc(V));
size_t len = geom::ncols(ima) * sizeof(mln_enc(V));
for (p.row() = min_row; p.row() <= max_row; ++p.row())
file.read((char*)(& ima(p)), len);
}
......@@ -149,8 +149,8 @@ namespace mln
{
// FIXME: code for g++-2.95 when sizeof(int_u8) == 2!!!
const mln_coord(I)
min_col = ima.domain().pmin().col(),
max_col = ima.domain().pmax().col();
min_col = geom::min_col(ima),
max_col = geom::max_col(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
for (p.col() = min_col; p.col() <= max_col; ++p.col())
{
......
......@@ -33,6 +33,7 @@
# include <fstream>
# include <mln/core/image2d_b.hh>
# include <mln/geom/size2d.hh>
# include <mln/value/int_u8.hh>
......@@ -53,16 +54,16 @@ namespace mln
}
file << "P5" << std::endl;
file << "# olena" << std::endl;
file << ima.ncols() << ' ' << ima.nrows() << std::endl;
file << geom::ncols(ima) << ' ' << geom::nrows(ima) << std::endl;
file << "255" << std::endl;
const int
min_row = ima.domain().pmin().row(),
max_row = ima.domain().pmax().row();
min_row = geom::min_row(ima),
max_row = geom::max_row(ima);
point2d p;
if (sizeof(value::int_u8) == 1)
{
p.col() = ima.domain().pmin().col();
size_t len = ima.ncols();
p.col() = geom::min_col(ima);
size_t len = geom::ncols(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
file.write((char*)(& ima(p)), len);
}
......@@ -70,10 +71,8 @@ namespace mln
{
// FIXME: code for g++-2.95 when sizeof(int_u8) == 2!!!
const int
min_col = ima.domain().pmin().col(),
max_col = ima.domain().pmax().col();
std::cout << min_row << ' ' << max_row << std::endl;
std::cout << min_col << ' ' << max_col << std::endl;
min_col = geom::min_col(ima),
max_col = geom::max_col(ima);
for (p.row() = min_row; p.row() <= max_row; ++p.row())
for (p.col() = min_col; p.col() <= max_col; ++p.col())
{
......
......@@ -73,8 +73,8 @@ namespace mln
mln_precondition(output.has_data());
int
min_row = input.min_row(), max_row = input.max_row(),
min_col = input.min_col(), max_col = input.max_col();
min_row = geom::min_row(input), max_row = geom::max_row(input),
min_col = geom::min_col(input), max_col = geom::max_col(input);
window2d
win_fwd_plus = win - (win + left),
......
......@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
# include <mln/geom/size2d.hh>
# include <mln/core/window2d.hh>
# include <mln/core/win/hline2d.hh>
......@@ -162,9 +163,10 @@ namespace mln
{