Commit 074b98c0 authored by Roland Levillain's avatar Roland Levillain
Browse files

Fix two bugs in mln/world/binary_2d/subsample.hh.

	* mln/world/binary_2d/subsample.hh
	(world::binary_2d::subsample(const image2d<bool>&, unsigned)):
	Properly initialize (and deallocate) the sliding window (array of
	pointers).
	Fix the size of	the output image.
	Have the declaration of this function match its definition.
	* tests/world/binary_2d/subsample.cc: New test.
	* tests/world/binary_2d/Makefile.am
	(check_PROGRAMS): Add subsample.
	(MOSTLYCLEANFILES): Add subsample-small.pgm.
parent 056a7da3
2013-06-28 Roland Levillain <roland@lrde.epita.fr>
Fix two bugs in mln/world/binary_2d/subsample.hh.
* mln/world/binary_2d/subsample.hh
(world::binary_2d::subsample(const image2d<bool>&, unsigned)):
Properly initialize (and deallocate) the sliding window (array of
pointers).
Fix the size of the output image.
Have the declaration of this function match its definition.
* tests/world/binary_2d/subsample.cc: New test.
* tests/world/binary_2d/Makefile.am
(check_PROGRAMS): Add subsample.
(MOSTLYCLEANFILES): Add subsample-small.pgm.
2013-06-24 Roland Levillain <roland@lrde.epita.fr>
 
Address compiler warnings about unused variables and arguments.
......@@ -57,7 +57,7 @@ namespace mln
/// \return A gray level image.
//
image2d<value::int_u8>
subsample(image2d<bool>& input, unsigned n);
subsample(const image2d<bool>& input, unsigned n);
# ifndef MLN_INCLUDE_ONLY
......@@ -80,11 +80,10 @@ namespace mln
return output;
}
const bool** ptr;
const bool** ptr = new const bool*[n];
const unsigned nrows = input.nrows() / n;
const unsigned ncols = input.ncols() / n;
image2d<int_u8> output;
initialize(output, input);
image2d<int_u8> output(nrows, ncols);
const unsigned delta_row = input.delta_offset(down);
unsigned count = 0;
......@@ -109,6 +108,8 @@ namespace mln
}
}
delete[] ptr;
return output;
}
......
# Copyright (C) 2009, 2010 EPITA Research and Development Laboratory (LRDE)
# Copyright (C) 2009, 2010, 2013 EPITA Research and Development
# Laboratory (LRDE)
#
# This file is part of Olena.
#
......@@ -17,8 +18,10 @@
include $(top_srcdir)/milena/tests/tests.mk
check_PROGRAMS = \
enlarge
# enlarge_hq2x
enlarge \
subsample
TESTS = $(check_PROGRAMS)
MOSTLYCLEANFILES = \
subsample-small.pgm
// Copyright (C) 2013 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
/// Exercise mln::world::binary_2d::subsample.
#include <mln/core/image/image2d.hh>
#include <mln/value/int_u8.hh>
#include <mln/world/binary_2d/subsample.hh>
#include <mln/io/pbm/load.hh>
#include <mln/io/pgm/save.hh>
#include "tests/data.hh"
int main()
{
using namespace mln;
using value::int_u8;
image2d<bool> input = io::pbm::load(MLN_IMG_DIR "/small.pbm");
image2d<int_u8> output = world::binary_2d::subsample(input, 3);
io::pgm::save(output, "subsample-small.pgm");
}
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