22 template <
typename T,
int dim>
44 template <
typename T,
int dim>
61 template <
typename T,
int dim>
64 typedef typename PixelTraits<T>::template CastPixel<double>::value_type doubleT;
66 double nb=pow(
double(fact),dim);
87 template <
typename T,
int dim>
90 typedef typename PixelTraits<T>::template CastPixel<double>::value_type doubleT;
94 std::pair<double,double> mM = range(f);
111 template <
typename T>
Image<T,3> inline reduce(
const Image<T,3>&I,
int w,
int h,
int d,
bool keepRatio=
false) {
return reduce(I,
Coords<3>(w,h,d),keepRatio); }
120 template <
typename T,
int dim>
136 template <
typename T,
int dim>
139 typedef typename PixelTraits<T>::template CastPixel<double> doubleT;
142 std::pair<double,double> mM = range(f);
143 assert(mM.second<=1);
158 template <
typename T>
Image<T,3> inline enlarge(
const Image<T,3>&I,
int w,
int h,
int d,
bool keepRatio=
false) {
return enlarge(I,
Coords<3>(w,h,d),keepRatio); }
167 template <
typename T,
int dim>
188 template <
typename T,
int dim>
191 assert(sigma>0 && order>=0 && order<3 && d>=0 && d<dim);
194 const typename PixelTraits<T>::scalar_type
195 alpha = 1.695f/sigma,
196 ea = std::exp(alpha),
197 ema = std::exp(-alpha),
202 typename PixelTraits<T>::scalar_type ek,ekn,parity,a1,a2,a3,a4,g0,sumg1,sumg0;
208 ek = -(1-ema)*(1-ema)*(1-ema)/(2*(ema+1)*ema);
214 sumg1 = (ek*ea) / ((ea-1)*(ea-1));
219 g0 = sumg0 = sumg1 = 0;
224 ekn = ( -2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea) );
225 ek = -(em2a-1)/(2*alpha*ema);
227 a2 = -ekn*(1+ek*alpha)*ema;
228 a3 = ekn*(1-ek*alpha)*ema;
237 g0 = sumg0 = sumg1 = 0;
242 ek = (1-ema)*(1-ema) / (1+2*alpha*ema - em2a);
244 a2 = ek*ema*(alpha-1);
245 a3 = ek*ema*(alpha+1);
249 sumg1 = ek*(alpha*ea+ea-1) / ((ea-1)*(ea-1));
254 g0 = sumg0 = sumg1 = 0;
259 T *Y =
new T[I.
size(d)];
260 const size_t offset = I.
stride(d);
261 const size_t nb = I.
size(d);
268 T I2 = *ima; ima += offset;
269 T I1 = *ima; ima += offset;
270 T Y2 = *(Y++) = sumg0*I2;
271 T Y1 = *(Y++) = g0*I1 + sumg1*I2;
272 for (
size_t i=2; i<nb; i++) {
273 I1 = *ima; ima+=offset;
274 T Y0 = *(Y++) = a1*I1 + a2*I2 + b1*Y1 + b2*Y2;
279 Y2 = Y1 = (parity*sumg1)*I2;
284 for (
size_t i=nb-3; ; i--) {
285 T Y0 = a3*I1+a4*I2+b1*Y1+b2*Y2;
311 template <
typename T,
int dim>
325 template <
typename T,
int dim>
327 for (
int i=0;i<dim;i++) {
339 template <
typename T,
int dim>
352 template <
typename T,
int dim>
367 template <
typename T,
int dim>
PixelTraits< T >::template CastPixel< V >::value_type interpolate(const FVector< V, dim > &c) const
Interpolation.
Definition: Image.h:198
Coordinates.
Definition: Coords.h:16
Vector of fixed size.
Definition: FVector.h:17
FVector & fill(const T &v)
Filling.
Definition: FVector.h:75
Image< T, dim > scaleDown(const Image< T, dim > &I, int fact)
Down scaling: fast naive version.
Definition: Algos.h:45
Iterator on Coordinates.
Definition: Coords.h:83
CoordsIterator< dim > coordsEnd() const
End coords iterator.
Definition: MultiArray.h:379
FArray< size_t, dim > stride() const
Stride.
Definition: MultiArray.h:253
Image< T, dim > blur(const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, bool neumann=true)
Blur.
Definition: Algos.h:353
Image.
Definition: Image.h:24
Image< T, dim > deriche(const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
Deriche filter.
Definition: Algos.h:312
Coords< dim > sizes() const
Sizes.
Definition: MultiArray.h:211
int size(int i) const
ith size.
Definition: MultiArray.h:225
Image clone() const
Cloning.
Definition: Image.h:146
Image< T, dim > reduce(const Image< T, dim > &I, int fact)
Reduce image (integer factor).
Definition: Algos.h:62
Imagine++ namespace.
Definition: Array.h:7
void inPlaceDeriche(Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, int order, int d, bool neumann=true)
In place Deriche filter.
Definition: Algos.h:189
void inPlaceBlur(Image< T, dim > &I, const FVector< typename PixelTraits< T >::scalar_type, dim > &sigmas, bool neumann=true)
In Place Blur (anisotropic).
Definition: Algos.h:326
Image< T, dim > scaleUp(const Image< T, dim > &I, int fact)
Up scaling: fast naive version.
Definition: Algos.h:23
CoordsIterator< dim > coordsBegin() const
Begin coords iterator.
Definition: MultiArray.h:371
Image< T, dim > enlarge(const Image< T, dim > &I, Coords< dim > nd, bool keepRatio=false)
Enlarge image (given dimensions).
Definition: Algos.h:137