// -*- c-basic-offset: 4 -*- /** @file Pyramid.h * * @author Pablo d'Angelo * * $Id: Pyramid.h,v 1.2 2007/01/27 05:00:36 acmihal Exp $ * * This 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; either * version 2 of the License, or (at your option) any later version. * * This software 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef VIGRA_EXT_PYRAMID_H #define VIGRA_EXT_PYRAMID_H #include namespace vigra_ext { /** Gaussian reduction to next pyramid level * * out is rescaled to the correct size. */ template void reduceToNextLevel(Image & in, Image & out) { DEBUG_TRACE(""); // image size at current level int width = in.width(); int height = in.height(); // image size at next smaller level int newwidth = (width + 1) / 2; int newheight = (height + 1) / 2; // resize result image to appropriate size out.resize(newwidth, newheight); // define a Gaussian kernel (size 5x1) // with sigma = 1 vigra::Kernel1D filter; filter.initExplicitly(-2, 2) = 0.054, 0.242, 0.4, 0.242, 0.054; vigra::BasicImage tmpimage1(width, height); vigra::BasicImage tmpimage2(width, height); // smooth (band limit) input image separableConvolveX(srcImageRange(in), destImage(tmpimage1), kernel1d(filter)); separableConvolveY(srcImageRange(tmpimage1), destImage(tmpimage2), kernel1d(filter)); // downsample smoothed image resizeImageNoInterpolation(srcImageRange(tmpimage2), destImageRange(out)); } } // namespace #endif // VIGRA_EXT_PYRAMID_H