34 #ifndef AIMSALGO_SIGNALFILTER_FILTERINGIMAGEALGORITHM_H
35 #define AIMSALGO_SIGNALFILTER_FILTERINGIMAGEALGORITHM_H
60 namespace singlechannel {
134 template <
typename T>
205 namespace singlechannel {
210 template <
typename T>
222 _func->setOptions( options );
227 _func->updateOptions( options );
230 virtual ::aims::singlechannel::LinearFilteringImageAlgorithm<T> *
clone()
const {
231 return new ::aims::singlechannel::LinearFilteringImageAlgorithm<T>(*
this);
254 assert(
typeid(other) ==
typeid(*
this) );
269 template <
typename T>
275 int sx, sy, sz, ex, ey, ez, x, y, z, t;
280 std::vector<float> vs(4, 1.);
282 options->setProperty(
"voxel_size", vs );
283 _func->updateOptions( options );
286 const std::vector<int> & border = in->
getBorders();
287 const std::vector<int> & amplitude = _func->getAmplitude();
290 sz = (amplitude[4] < border[4]) ? 0 : amplitude[4] - border[4];
291 sy = (amplitude[2] < border[2]) ? 0 : amplitude[2] - border[2];
292 sx = (amplitude[0] < border[0]) ? 0 : amplitude[0] - border[0];
293 ez = (amplitude[5] < border[5]) ? in->
getSizeZ() : in->
getSizeZ() - amplitude[5] + border[5];
294 ey = (amplitude[3] < border[3]) ? in->
getSizeY() : in->
getSizeY() - amplitude[3] + border[3];
295 ex = (amplitude[1] < border[1]) ? in->
getSizeX() : in->
getSizeX() - amplitude[1] + border[1];
298 std::cout <<
"Filter amplitude (voxels): [ ";
299 for(
int i = 0; i < 6; ++i)
301 std::cout <<
"]" << std::endl;
302 std::cout <<
"Processing with borders (voxels): [ ";
303 for(
int i = 0; i < 8; ++i)
305 std::cout <<
"]" << std::endl;
314 size[0] = amplitude[0] + amplitude[1] + 1;
315 size[1] = amplitude[2] + amplitude[3] + 1;
316 size[2] = amplitude[4] + amplitude[5] + 1;
320 * (ez - sz) * (ey - sy) * (ex - sx) );
322 std::cout <<
"Filtering progress: ";
324 for( t = 0; t < in->
getSizeT(); ++t )
325 for( z = sz; z < ez; ++z )
326 for( y = sy; y < ey; ++y )
327 for( x = sx; x < ex; ++x )
329 if( this->_verbose > 0 )
330 (++progress).print();
332 pos[0] = x - amplitude[0];
333 pos[1] = y - amplitude[2];
334 pos[2] = z - amplitude[4];
337 (*out)( x, y, z, t ) = _func->execute( win );
341 std::cout << std::endl;
348 template <
typename T>
360 _func->setOptions( options );
365 _func->updateOptions( options );
368 virtual ::aims::singlechannel::ElementFilteringImageAlgorithm<T> *
clone()
const {
369 return new ::aims::singlechannel::ElementFilteringImageAlgorithm<T>(*
this);
401 const ::aims::singlechannel::ElementFilteringImageAlgorithm<T> & other )
403 assert(
typeid(other) ==
typeid(*
this) );
406 _func.reset( other._func->clone() );
407 _strel.reset( other._strel->clone() );
422 template <
typename T>
429 int sx, sy, sz, ex, ey, ez, x, y, z, t;
433 const std::vector<int> & border = in->
getBorders();
434 const std::vector<int> amplitude = _strel->getAmplitude();
437 sz = (amplitude[4] < border[4]) ? 0 : amplitude[4] - border[4];
438 sy = (amplitude[2] < border[2]) ? 0 : amplitude[2] - border[2];
439 sx = (amplitude[0] < border[0]) ? 0 : amplitude[0] - border[0];
440 ez = (amplitude[5] < border[5]) ? in->
getSizeZ() : in->
getSizeZ() - amplitude[5] + border[5];
441 ey = (amplitude[3] < border[3]) ? in->
getSizeY() : in->
getSizeY() - amplitude[3] + border[3];
442 ex = (amplitude[1] < border[1]) ? in->
getSizeX() : in->
getSizeX() - amplitude[1] + border[1];
445 std::cout <<
"Filter amplitude (voxels): [ ";
446 for(
int i = 0; i < 6; ++i)
448 std::cout <<
"]" << std::endl;
449 std::cout <<
"Processing with borders (voxels): [ ";
450 for(
int i = 0; i < 8; ++i)
452 std::cout <<
"]" << std::endl;
464 * (ez - sz) * (ey - sy) *(ex - sx) );
466 std::cout <<
"Filtering progress: ";
468 for( t = 0; t < in->
getSizeT(); ++t )
469 for( z = sz; z < ez; ++z )
470 for( y = sy; y < ey; ++y )
471 for( x = sx; x < ex; ++x )
473 if( this->_verbose > 0 )
474 (++progress).print();
481 (*out)( x, y, z, t ) = _func->execute( win, _strel );
485 std::cout << std::endl;
Base class for filtering functions applied in a structuring element.
virtual ElementFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
ElementFilteringImageAlgorithm(const ElementFilteringFunction< ChannelType > &f, const StructuringElement &se=strel::Cube(1.))
carto::DataTypeTraits< T >::ChannelType ChannelType
virtual void setStructuringElement(const StructuringElement &se)
ElementFilteringImageAlgorithm & operator=(ElementFilteringImageAlgorithm &other)
ElementFilteringImageAlgorithm(const ElementFilteringImageAlgorithm< T > &other)
virtual void updateOptions(const carto::Object &options)
virtual void setOptions(const carto::Object &options)
virtual ~ElementFilteringImageAlgorithm()
SingleChannelImageAlgorithmType * _ealgo
singlechannel::ElementFilteringImageAlgorithm< ChannelType > SingleChannelImageAlgorithmType
aims::ImageAlgorithmInterface is the interface for an image processing algorithm.
aims::ImageAlgorithm class used to implement image algorithms
Base class for linear filtering functions.
singlechannel::LinearFilteringImageAlgorithm< ChannelType > SingleChannelImageAlgorithmType
LinearFilteringImageAlgorithm()
LinearFilteringImageAlgorithm(const LinearFilteringImageAlgorithm< T > &other)
SingleChannelImageAlgorithmType * _lalgo
carto::DataTypeTraits< T >::ChannelType ChannelType
virtual void setOptions(const carto::Object &options)
LinearFilteringImageAlgorithm(const LinearFilteringFunction< ChannelType > &f)
virtual void updateOptions(const carto::Object &options)
LinearFilteringImageAlgorithm & operator=(LinearFilteringImageAlgorithm &other)
virtual ~LinearFilteringImageAlgorithm()
virtual LinearFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual StructuringElement * clone() const
virtual void execute(const carto::VolumeRef< T > &in, carto::VolumeRef< T > &out) const
ImageAlgorithmInterface<T> Pure virtual method.
::aims::singlechannel::ElementFilteringImageAlgorithm< T > & operator=(const ::aims::singlechannel::ElementFilteringImageAlgorithm< T > &other)
ElementFilteringImageAlgorithm(const ElementFilteringFunction< T > &f, const StructuringElement &se=strel::Cube(1.))
carto::rc_ptr< StructuringElement > _strel
carto::rc_ptr< ElementFilteringFunction< T > > _func
virtual void setStructuringElement(const StructuringElement &se)
ElementFilteringImageAlgorithm(const ::aims::singlechannel::ElementFilteringImageAlgorithm< T > &other)
ElementFilteringImageAlgorithm()
virtual void setOptions(const carto::Object &options)
virtual ~ElementFilteringImageAlgorithm()
virtual ::aims::singlechannel::ElementFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual void updateOptions(const carto::Object &options)
virtual void execute(const carto::VolumeRef< T > &in, carto::VolumeRef< T > &out) const
ImageAlgorithmInterface<T> Pure virtual method.
virtual void updateOptions(const carto::Object &options)
LinearFilteringImageAlgorithm(const LinearFilteringFunction< T > &f)
carto::rc_ptr< LinearFilteringFunction< T > > _func
LinearFilteringImageAlgorithm()
virtual ~LinearFilteringImageAlgorithm()
virtual void setOptions(const carto::Object &options)
virtual ::aims::singlechannel::LinearFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
LinearFilteringImageAlgorithm(const ::aims::singlechannel::LinearFilteringImageAlgorithm< T > &other)
LinearFilteringImageAlgorithm & operator=(const LinearFilteringImageAlgorithm &other)
bool getProperty(const std::string &, T &) const
std::vector< int > getBorders() const
const PropertySet & header() const
void setPosInRefVolume(const Position4Di &pos)
std::string toString(const T &object)