24 #ifndef VIGRA_EXT_PYRAMID_H
25 #define VIGRA_EXT_PYRAMID_H
27 #include <vigra/separableconvolution.hxx>
38 template <
class ImageIn,
class Image>
41 typedef typename Image::value_type vt;
42 typedef typename vigra::NumericTraits<vt>::RealPromote SKIPSMType;
48 size_t w = in.width();
49 size_t h = in.height();
79 template <
class Image,
class ImageMask>
80 void reduceNTimes(Image & in, ImageMask & inMask, Image & out, ImageMask & outMask,
int n)
82 typedef typename Image::value_type vt;
83 typedef typename vigra::NumericTraits<vt>::RealPromote SKIPSMType;
84 typedef double SKIPSMAlphaType;
92 size_t w = in.width();
93 size_t h = in.height();
100 Image * curr = &temp;
101 ImageMask * currMask = &tempMask;
103 ImageMask * nextMask = &outMask;
110 nextMask = &tempMask;
113 currMask->resize(w,h);
119 for( ; n > 0 ; --n) {
121 nextMask->resize(w,h);
127 ImageMask * tm = currMask;
135 template <
class ImageIn,
class ImageOut>
138 typedef typename ImageOut::value_type vt;
139 typedef typename vigra::NumericTraits<vt>::RealPromote SKIPSMType;
141 size_t w = in.width();
142 size_t h = in.height();
150 template <
class ImageIn,
class ImageInMask,
class ImageOut,
class ImageOutMask>
151 void reduceToNextLevel(ImageIn & in, ImageInMask & inMask, ImageOut & out, ImageOutMask & outMask)
153 typedef typename ImageOut::value_type vt;
154 typedef typename vigra::NumericTraits<vt>::RealPromote SKIPSMType;
156 typedef double SKIPSMAlphaType;
158 size_t w = in.width();
159 size_t h = in.height();
164 outMask.resize(w, h);
170 static const double AA = 0.4;
171 static const double W[] = {0.25 -
AA / 2.0, 0.25,
AA, 0.25, 0.25 -
AA / 2.0};
177 template <
class Image>
182 int width = in.width();
183 int height = in.height();
186 int newwidth = (width + 1) / 2;
187 int newheight = (height + 1) / 2;
190 out.resize(newwidth, newheight);
194 vigra::Kernel1D<double> filter;
195 filter.initExplicitly(-2, 2) =
W[0],
W[1], W[2], W[3], W[4];
197 vigra::BasicImage<typename Image::value_type> tmpimage1(width, height);
198 vigra::BasicImage<typename Image::value_type> tmpimage2(width, height);
214 #endif // VIGRA_EXT_PYRAMID_H
void reduceToNextLevel(ImageIn &in, ImageOut &out)
void reduceToNextLevelOld(Image &in, Image &out)
Gaussian reduction to next pyramid level.
vigra::pair< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImage(const ROIImage< Image, Mask > &img)
vigra::pair< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImage(ROIImage< Image, Alpha > &img)
vigra::triple< typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::image_const_traverser, typename ROIImage< Image, Mask >::ImageConstAccessor > srcImageRange(const ROIImage< Image, Mask > &img)
helper function for ROIImages
vigra::triple< typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::image_traverser, typename ROIImage< Image, Alpha >::ImageAccessor > destImageRange(ROIImage< Image, Alpha > &img)
void reduceNTimes(ImageIn &in, Image &out, int n)