Commit e0089be5 authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

mln/world/binary_2d/subsample.hh: Cleanup code. Fix a memory leak.

parent c6262b2d
2013-03-27 Guillaume Lazzara <z@lrde.epita.fr>
* mln/world/binary_2d/subsample.hh: Cleanup code. Fix a memory
leak.
2013-03-27 Guillaume Lazzara <z@lrde.epita.fr>
 
Add constant Boolean functions.
// Copyright (C) 2009, 2011, 2012 EPITA Research and Development
// Copyright (C) 2009, 2011, 2012, 2013 EPITA Research and Development
// Laboratory (LRDE)
//
// This file is part of Olena.
......@@ -33,6 +33,7 @@
///
/// FIXME: not enough generic. Does not work on image having
/// the top left corner different from (0,0).
/// FIXME: To be removed ?
# include <mln/core/image/image2d.hh>
# include <mln/core/alias/dpoint2d.hh>
......@@ -63,7 +64,7 @@ namespace mln
inline
image2d<value::int_u8>
subsample(image2d<bool>& input, unsigned n)
subsample(const image2d<bool>& input, unsigned n)
{
mln_trace("world::binary_2d::subsample");
......@@ -79,21 +80,13 @@ namespace mln
return output;
}
const bool** ptr = new const bool*[n];
const bool** ptr;
const unsigned nrows = input.nrows() / n;
const unsigned ncols = input.ncols() / n;
algebra::vec<2, unsigned int> vmin;
algebra::vec<2, unsigned int> vmax;
vmin[0] = 0;
vmin[1] = 0;
vmax[0] = nrows - 1;
vmax[1] = ncols - 1;
point2d pmin(vmin);
point2d pmax(vmax);
image2d<int_u8> output(box<point2d>(pmin, pmax));
dpoint2d dp_row(1, 0);
const unsigned delta_row = input.delta_offset(dp_row);
image2d<int_u8> output;
initialize(output, input);
const unsigned delta_row = input.delta_offset(down);
unsigned count = 0;
for (unsigned row = 0; row < nrows; ++row)
......
Markdown is supported
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