37#ifndef VIGRA_RESIZEIMAGE_HXX
38#define VIGRA_RESIZEIMAGE_HXX
42#include "numerictraits.hxx"
43#include "stdimage.hxx"
44#include "recursiveconvolution.hxx"
45#include "separableconvolution.hxx"
46#include "resampling_convolution.hxx"
48#include "multi_shape.hxx"
108 VIGRA_CSTD::sin(M_PI*x) / VIGRA_CSTD::tan(M_PI * x / 2.0 / m_) *
109 (h_ + (1.0 - h_) * VIGRA_CSTD::cos(M_PI * x / m_)) / 2.0 / m_
134 return prefilterCoefficients_;
144ArrayVector<double> CoscotFunction<T>::prefilterCoefficients_;
158template <
class SrcIterator,
class SrcAccessor,
159 class DestIterator,
class DestAccessor>
161resizeLineNoInterpolation(SrcIterator i1, SrcIterator iend, SrcAccessor as,
162 DestIterator
id, DestIterator idend, DestAccessor ad)
164 int wold = iend - i1;
165 int wnew = idend - id;
173 double dx = (double)(wold - 1) / (wnew - 1);
175 for(;
id != idend; ++id, x += dx)
178 ad.set(as(i1, ix), id);
286 vigra_precondition((w > 1) && (
h > 1),
287 "resizeImageNoInterpolation(): "
288 "Source image too small.\n");
289 vigra_precondition((
wnew > 1) && (
hnew > 1),
290 "resizeImageNoInterpolation(): "
291 "Destination image too small.\n");
300 for(
int x=0; x<w; ++x, ++
is.x, ++
yt.x)
302 typename SrcIterator::column_iterator
c1 =
is.columnIterator();
303 typename TmpImageIterator::column_iterator
ct =
yt.columnIterator();
308 yt =
tmp.upperLeft();
310 for(
int y=0; y <
hnew; ++y, ++
yt.y, ++
id.y)
312 typename DestIterator::row_iterator rd =
id.rowIterator();
313 typename TmpImageIterator::row_iterator
rt =
yt.rowIterator();
315 resizeLineNoInterpolation(
rt,
rt + w,
tmp.accessor(), rd, rd +
wnew,
da);
319template <
class SrcIterator,
class SrcAccessor,
320 class DestIterator,
class DestAccessor>
323 triple<DestIterator, DestIterator, DestAccessor> dest)
326 dest.first, dest.second, dest.third);
329template <
class T1,
class S1,
333 MultiArrayView<2, T2, S2> dest)
336 destImageRange(dest));
345template <
class SrcIterator,
class SrcAccessor,
346 class DestIterator,
class DestAccessor>
348resizeLineLinearInterpolation(SrcIterator i1, SrcIterator iend, SrcAccessor as,
349 DestIterator
id, DestIterator idend, DestAccessor ad)
351 int wold = iend - i1;
352 int wnew = idend - id;
354 if((wold <= 1) || (wnew <= 1))
return;
357 NumericTraits<typename DestAccessor::value_type> DestTraits;
358 typedef typename DestTraits::RealPromote RealPromote;
360 ad.set(DestTraits::fromRealPromote(as(i1)),
id);
364 ad.set(DestTraits::fromRealPromote(as(iend)), idend);
366 double dx = (double)(wold - 1) / (wnew - 1);
369 for(;
id != idend; ++id, x += dx)
379 ad.set(DestTraits::fromRealPromote(RealPromote(x1 * as(i1) + x * as(i1, 1))), id);
501 vigra_precondition((w > 1) && (
h > 1),
502 "resizeImageLinearInterpolation(): "
503 "Source image too small.\n");
504 vigra_precondition((
wnew > 1) && (
hnew > 1),
505 "resizeImageLinearInterpolation(): "
506 "Destination image too small.\n");
508 double const scale = 2.0;
510 typedef typename SrcAccessor::value_type
SRCVT;
511 typedef typename NumericTraits<SRCVT>::RealPromote
TMPTYPE;
521 typename TmpImageIterator::row_iterator
lt =
line.upperLeft().rowIterator();
523 for(x=0; x<w; ++x, ++
is.x, ++
yt.x)
525 typename SrcIterator::column_iterator
c1 =
is.columnIterator();
526 typename TmpImageIterator::column_iterator
ct =
yt.columnIterator();
533 resizeLineLinearInterpolation(
lt,
lt +
h,
line.accessor(),
538 resizeLineLinearInterpolation(
c1,
c1 +
h,
sa,
543 yt =
tmp.upperLeft();
545 for(y=0; y <
hnew; ++y, ++
yt.y, ++
id.y)
547 typename DestIterator::row_iterator rd =
id.rowIterator();
548 typename TmpImageIterator::row_iterator
rt =
yt.rowIterator();
555 resizeLineLinearInterpolation(
lt,
lt + w,
line.accessor(),
560 resizeLineLinearInterpolation(
rt,
rt + w,
tmp.accessor(),
566template <
class SrcIterator,
class SrcAccessor,
567 class DestIterator,
class DestAccessor>
570 triple<DestIterator, DestIterator, DestAccessor> dest)
573 dest.first, dest.second, dest.third);
576template <
class T1,
class S1,
580 MultiArrayView<2, T2, S2> dest)
583 destImageRange(dest));
737 "resizeImageSplineInterpolation(): "
738 "Source image too small.\n");
741 "resizeImageSplineInterpolation(): "
742 "Destination image too small.\n");
752 double const scale = 2.0;
754 typedef typename SrcAccessor::value_type
SRCVT;
755 typedef typename NumericTraits<SRCVT>::RealPromote
TMPTYPE;
771 typename TmpImageIterator::row_iterator
line_tmp =
line.upperLeft().rowIterator();
776 typename SrcIterator::column_iterator
c_src =
src_iter.columnIterator();
777 typename TmpImageIterator::column_iterator
c_tmp =
y_tmp.columnIterator();
826 typename TmpImageIterator::row_iterator
r_tmp =
y_tmp.rowIterator();
868template <
class SrcIterator,
class SrcAccessor,
869 class DestIterator,
class DestAccessor>
872 DestIterator
id, DestIterator idend, DestAccessor da)
877template <
class SrcIterator,
class SrcAccessor,
878 class DestIterator,
class DestAccessor,
882 triple<DestIterator, DestIterator, DestAccessor> dest,
883 SPLINE
const & spline)
886 dest.first, dest.second, dest.third, spline);
889template <
class SrcIterator,
class SrcAccessor,
890 class DestIterator,
class DestAccessor>
893 triple<DestIterator, DestIterator, DestAccessor> dest)
896 dest.first, dest.second, dest.third);
899template <
class T1,
class S1,
904 MultiArrayView<2, T2, S2> dest,
905 SPLINE
const & spline)
908 destImageRange(dest), spline);
911template <
class T1,
class S1,
915 MultiArrayView<2, T2, S2> dest)
918 destImageRange(dest));
992template <
class SrcIterator,
class SrcAccessor,
993 class DestIterator,
class DestAccessor>
996 triple<DestIterator, DestIterator, DestAccessor> dest)
999 dest.first, dest.second, dest.third);
1002template <
class T1,
class S1,
1006 MultiArrayView<2, T2, S2> dest)
1009 destImageRange(dest));
1084template <
class SrcIterator,
class SrcAccessor,
1085 class DestIterator,
class DestAccessor>
1088 triple<DestIterator, DestIterator, DestAccessor> dest)
1091 dest.first, dest.second, dest.third);
1094template <
class T1,
class S1,
1098 MultiArrayView<2, T2, S2> dest)
1101 destImageRange(dest));
Definition resizeimage.hxx:83
value_type operator[](value_type x) const
Definition resizeimage.hxx:115
T value_type
Definition resizeimage.hxx:88
double radius() const
Definition resizeimage.hxx:121
ArrayVector< double > const & prefilterCoefficients() const
Definition resizeimage.hxx:132
result_type operator()(argument_type x) const
Definition resizeimage.hxx:103
T result_type
Definition resizeimage.hxx:94
T argument_type
Definition resizeimage.hxx:91
unsigned int derivativeOrder() const
Definition resizeimage.hxx:126
Class for a single RGB value.
Definition rgbvalue.hxx:128
size_type size() const
Definition tinyvector.hxx:913
void resamplingConvolveLine(...)
Performs a 1-dimensional resampling convolution of the source signal using the given set of kernels.
void resizeImageCatmullRomInterpolation(...)
Resize image using the Catmull/Rom interpolation function.
void resizeImageLinearInterpolation(...)
Resize image using linear interpolation.
void resizeImageSplineInterpolation(...)
Resize image using B-spline interpolation.
IntType lcm(IntType n, IntType m)
Definition rational.hxx:122
void resizeImageCoscotInterpolation(...)
Resize image using the Coscot interpolation function.
void resizeImageNoInterpolation(...)
Resize image by repeating the nearest pixel values.
void recursiveSmoothLine(...)
Convolves the image with a 1-dimensional exponential filter.
void recursiveFilterLine(...)
Performs a 1-dimensional recursive convolution of the source signal.