35 #ifndef AIMS_SIGNALFILTER_CONVOL_H
36 #define AIMS_SIGNALFILTER_CONVOL_H
76 int x,
int y,
int z,
int t );
80 int x,
int y,
int z,
int t);
84 int x,
int y,
int z,
int t);
108 short sources=0,
bool safe=
true)
117 int x,
int y,
int z,
int t);
121 int x,
int y,
int z,
int t);
129 template<
class T >
inline
134 ASSERT( kernel->getSizeT() == 1 );
136 ASSERT( img->getBorders()[0] >= 1 );
138 if( img->getBorders()[0] >= 1 )
139 set_safe_status(
false);
143 int dx = img->getSizeX();
144 int dy = img->getSizeY();
145 int dz = img->getSizeZ();
146 int dt = img->getSizeT();
151 for ( t=0; t<dt; t++ )
152 for ( z=0; z<dz; z++ )
153 for ( y=0; y<dy; y++ )
154 for ( x=0; x<dx; x++ )
156 T val = doit_voxel(img, kernel, x, y, z, t);
159 else if ( val <
min() )
161 res( x, y, z, t ) = val;
167 template<
class T >
inline
170 int x,
int y,
int z,
int t)
172 return (this->*_doit_voxel_method)(img, kernel, x, y, z, t);
175 template<
class T >
inline
180 int i, j, k, idx, idy, idz;
182 int mx = kernel->getSizeX();
183 int my = kernel->getSizeY();
184 int mz = kernel->getSizeZ();
190 int dx = img->getSizeX();
191 int dy = img->getSizeY();
192 int dz = img->getSizeZ();
196 for ( k=0; k<mz; k++ )
197 for ( j=0; j<my; j++ )
198 for ( i=0; i<mx; i++ )
204 if ( idx >= 0 && idy >= 0 && idz >= 0 &&
205 idx < dx && idy < dy && idz < dz )
206 val += kernel->at( i, j, k ) * img->at( idx, idy, idz, t );
212 template<
class T >
inline
217 int i, j, k, idx, idy, idz;
219 int mx = kernel->getSizeX();
220 int my = kernel->getSizeY();
221 int mz = kernel->getSizeZ();
229 for ( k=0; k<mz; k++ )
230 for ( j=0; j<my; j++ )
231 for ( i=0; i<mx; i++ )
237 val += kernel->at( i, j, k ) * img->at( idx, idy, idz, t );
243 template<
class T >
inline
248 if (_mask(x, y, z, t) == _sources)
249 return img->at(x, y, z, t);
253 template<
class T >
inline
258 if (_mask(x, y, z, t) == _sources)
259 return img->at(x, y, z, t);
393 #if !defined(__sun__) || !defined(_CHAR_IS_SIGNED)
The template class to make convolutions.
T(AimsConvolution::* _doit_voxel_method)(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
AimsConvolution(bool safe=true)
virtual T doit_voxel_unsafe(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
called for each voxel (unsafe version)
void set_safe_status(bool safe=true)
T doit_voxel(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
called for each voxel (user selected function)
carto::VolumeRef< T > doit(carto::rc_ptr< carto::Volume< T > > &, carto::rc_ptr< carto::Volume< T > > &)
virtual ~AimsConvolution()
virtual T doit_voxel_safe(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
called for each voxel (safe version)
Make convolution only on a specified mask.
virtual ~AimsMaskedConvolution()
AimsMaskedConvolution(const carto::rc_ptr< carto::Volume< short > > &mask, short sources=0, bool safe=true)
virtual T doit_voxel_safe(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
called for each voxel (safe version)
const carto::VolumeRef< short > _mask
virtual T doit_voxel_unsafe(carto::rc_ptr< carto::Volume< T > > &img, carto::rc_ptr< carto::Volume< T > > &kernel, int x, int y, int z, int t)
called for each voxel (unsafe version)
void setVoxelSize(float vx, float vy=1., float vz=1., float vt=1.)
float min(float x, float y)
float max(float x, float y)
BucketMap< Void > * mask(const BucketMap< Void > &src, const BucketMap< Void > &m, bool intersect=true)