Commit 00537669 authored by Roland Levillain's avatar Roland Levillain
Browse files

Handle the case of filling an empty border.

	* mln/border/fill.hh (mln::border::impl::fill_size_1): Here.
	Aesthetic changes.
	* tests/border/fill_0.cc: New test.
	* tests/border/Makefile.am (check_PROGRAMS): Add fill_0.
	(fill_0_SOURCES): New.
parent 943c281c
2011-10-04 Roland Levillain <roland@lrde.epita.fr>
Handle the case of filling an empty border.
* mln/border/fill.hh (mln::border::impl::fill_size_1): Here.
Aesthetic changes.
* tests/border/fill_0.cc: New test.
* tests/border/Makefile.am (check_PROGRAMS): Add fill_0.
(fill_0_SOURCES): New.
2011-09-15 Roland Levillain <roland@lrde.epita.fr>
 
Update Milena tests w.r.t. the new version of lena.pgm.
// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
// Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
//
......@@ -95,16 +96,18 @@ namespace mln
unsigned st = 0;
for_all (pl)
{
unsigned end = ima.index_of_point (pl);
{
unsigned end = ima.index_of_point (pl);
if (st < end)
std::memset((void*)&opt::element(ima, st),
*(const int*)(&v),
end - st);
st = end + len_r;
}
std::memset((void*)&opt::element(ima, st),
*(const int*)(&v),
opt::nelements(ima) - st);
st = end + len_r;
}
if (st < opt::nelements(ima))
std::memset((void*)&opt::element(ima, st),
*(const int*)(&v),
opt::nelements(ima) - st);
trace::exiting("border::impl::fill_size_1");
}
......@@ -125,12 +128,12 @@ namespace mln
unsigned st = 0;
for_all (pl)
{
unsigned end = ima.index_of_point (pl);
for (unsigned i = st; i < end; ++i)
opt::element(ima, i) = v;
st = end + len_r;
}
{
unsigned end = ima.index_of_point (pl);
for (unsigned i = st; i < end; ++i)
opt::element(ima, i) = v;
st = end + len_r;
}
for (unsigned i = st; i < opt::nelements(ima); ++i)
opt::element(ima, i) = v;
......
......@@ -146,6 +146,8 @@ namespace mln
box_runstart_piter<P>::next_()
{
// Do we want this run for image in 3d?
/* FIXME: `dim - 2' is probably the wrong (= not generic) way to
express the manipulated dimension anyway. */
for (int c = dim - 2; c >= 0; --c)
{
if (p_[c] != s_->pmax()[c])
......
# Copyright (C) 2007, 2008, 2009 EPITA Research and Development
# Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development
# Laboratory (LRDE).
#
# This file is part of Olena.
......@@ -22,6 +22,7 @@ check_PROGRAMS = \
duplicate \
equalize \
fill \
fill_0 \
find \
get \
mirror \
......@@ -43,6 +44,7 @@ adjust_SOURCES = adjust.cc
duplicate_SOURCES = duplicate.cc
equalize_SOURCES = equalize.cc
fill_SOURCES = fill.cc
fill_0_SOURCES = fill_0.cc
find_SOURCES = find.cc
get_SOURCES = get.cc
mirror_SOURCES = mirror.cc
......
// Copyright (C) 2011 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of Olena.
//
// Olena is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free
// Software Foundation, version 2 of the License.
//
// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
//
// As a special exception, you may use this file as part of a free
// software project 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.
/// \file
/// \brief Test filling an image with a border of 0.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/value/int_u16.hh>
#include <mln/debug/iota.hh>
#include <mln/border/fill.hh>
int
main()
{
using namespace mln;
border::thickness = 0;
{
// Image with values of width 1 (sizeof(int_u8) == 1), the border
// of which is filled using mln::border::impl::fill_size_1().
using mln::value::int_u8;
image2d<int_u8> ima(3, 3);
debug::iota(ima);
border::fill(ima, 42);
}
{
// Image with values of width > 1 (sizeof(int_u16) == 2), the border
// of which is filled using mln::border::impl::fill_size_n().
using mln::value::int_u16;
image2d<int_u16> ima(3, 3);
debug::iota(ima);
border::fill(ima, 42);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment