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>
141 std::pair<double,double> mM = range(f);
142 assert(mM.second<=1);
157 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); }
166 template <
typename T,
int dim>
187 template <
typename T,
int dim>
190 assert(sigma>0 && order>=0 && order<3 && d>=0 && d<dim);
193 const typename PixelTraits<T>::scalar_type
194 alpha = 1.695f/sigma,
195 ea = std::exp(alpha),
196 ema = std::exp(-alpha),
201 typename PixelTraits<T>::scalar_type ek,ekn,parity,a1,a2,a3,a4,g0,sumg1,sumg0;
207 ek = -(1-ema)*(1-ema)*(1-ema)/(2*(ema+1)*ema);
213 sumg1 = (ek*ea) / ((ea-1)*(ea-1));
218 g0 = sumg0 = sumg1 = 0;
223 ekn = ( -2*(-1+3*ea-3*ea*ea+ea*ea*ea)/(3*ea+1+3*ea*ea+ea*ea*ea) );
224 ek = -(em2a-1)/(2*alpha*ema);
226 a2 = -ekn*(1+ek*alpha)*ema;
227 a3 = ekn*(1-ek*alpha)*ema;
236 g0 = sumg0 = sumg1 = 0;
241 ek = (1-ema)*(1-ema) / (1+2*alpha*ema - em2a);
243 a2 = ek*ema*(alpha-1);
244 a3 = ek*ema*(alpha+1);
248 sumg1 = ek*(alpha*ea+ea-1) / ((ea-1)*(ea-1));
253 g0 = sumg0 = sumg1 = 0;
258 T *Y =
new T[I.
size(d)];
259 const size_t offset = I.
stride(d);
260 const size_t nb = I.
size(d);
267 T I2 = *ima; ima += offset;
268 T I1 = *ima; ima += offset;
269 T Y2 = *(Y++) = sumg0*I2;
270 T Y1 = *(Y++) = g0*I1 + sumg1*I2;
271 for (
size_t i=2; i<nb; i++) {
272 I1 = *ima; ima+=offset;
273 T Y0 = *(Y++) = a1*I1 + a2*I2 + b1*Y1 + b2*Y2;
278 Y2 = Y1 = (parity*sumg1)*I2;
283 for (
size_t i=nb-3; ; i--) {
284 T Y0 = a3*I1+a4*I2+b1*Y1+b2*Y2;
310 template <
typename T,
int dim>
324 template <
typename T,
int dim>
326 for (
int i=0;i<dim;i++) {
338 template <
typename T,
int dim>
351 template <
typename T,
int dim>
366 template <
typename T,
int dim>
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
int size(int i) const
ith size.
Definition: MultiArray.h:225
Coords< dim > sizes() const
Sizes.
Definition: MultiArray.h:211
Image< T, dim > blur(const Image< T, dim > &I, typename PixelTraits< T >::scalar_type sigma, bool neumann=true)
Blur.
Definition: Algos.h:352
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:311
CoordsIterator< dim > coordsEnd() const
End coords iterator.
Definition: MultiArray.h:384
FArray< size_t, dim > stride() const
Stride.
Definition: MultiArray.h:253
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:188
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:325
Image< T, dim > scaleUp(const Image< T, dim > &I, int fact)
Up scaling: fast naive version.
Definition: Algos.h:23
Image< T, dim > enlarge(const Image< T, dim > &I, Coords< dim > nd, bool keepRatio=false)
Enlarge image (given dimensions).
Definition: Algos.h:137
Image clone() const
Cloning.
Definition: Image.h:146
PixelTraits< T >::template CastPixel< V >::value_type interpolate(const FVector< V, dim > &c) const
Interpolation.
Definition: Image.h:198
CoordsIterator< dim > coordsBegin() const
Begin coords iterator.
Definition: MultiArray.h:376