34 #ifndef AIMSALGO_SIGNALFILTER_FILTERINGIMAGEALGORITHM_H 35 #define AIMSALGO_SIGNALFILTER_FILTERINGIMAGEALGORITHM_H 61 namespace singlechannel {
85 _lalgo->setOptions( options );
90 _lalgo->updateOptions( options );
105 _lalgo( SingleChannelImageAlgorithmType( f ).
clone() )
111 _lalgo( other._lalgo->
clone() )
128 SingleChannelImageAlgorithmType *
_lalgo;
135 template <
typename T>
151 _ealgo->setOptions( options );
156 _ealgo->updateOptions( options );
168 _ealgo->setStructuringElement( se );
180 _ealgo( SingleChannelImageAlgorithmType( f, se ).
clone() )
186 _ealgo(other._ealgo->
clone())
203 SingleChannelImageAlgorithmType *
_ealgo;
206 namespace singlechannel {
211 template <
typename T>
223 _func->setOptions( options );
228 _func->updateOptions( options );
231 virtual ::aims::singlechannel::LinearFilteringImageAlgorithm<T> *
clone()
const {
232 return new ::aims::singlechannel::LinearFilteringImageAlgorithm<T>(*this);
255 assert(
typeid(other) ==
typeid(*
this) );
270 template <
typename T>
276 int sx, sy, sz, ex, ey, ez, x, y, z, t;
281 std::vector<float> vs(4, 1.);
282 in.
header().getProperty(
"voxel_size", vs );
283 options->setProperty(
"voxel_size", vs );
284 _func->updateOptions( options );
287 const std::vector<int> & border = in->
getBorders();
288 const std::vector<int> & amplitude =
_func->getAmplitude();
291 sz = (amplitude[4] < border[4]) ? 0 : amplitude[4] - border[4];
292 sy = (amplitude[2] < border[2]) ? 0 : amplitude[2] - border[2];
293 sx = (amplitude[0] < border[0]) ? 0 : amplitude[0] - border[0];
294 ez = (amplitude[5] < border[5]) ? in->
getSizeZ() : in->
getSizeZ() - amplitude[5] + border[5];
295 ey = (amplitude[3] < border[3]) ? in->
getSizeY() : in->
getSizeY() - amplitude[3] + border[3];
296 ex = (amplitude[1] < border[1]) ? in->
getSizeX() : in->
getSizeX() - amplitude[1] + border[1];
299 std::cout <<
"Filter amplitude (voxels): [ ";
300 for(
int i = 0; i < 6; ++i)
302 std::cout <<
"]" << std::endl;
303 std::cout <<
"Processing with borders (voxels): [ ";
304 for(
int i = 0; i < 8; ++i)
306 std::cout <<
"]" << std::endl;
315 size[0] = amplitude[0] + amplitude[1] + 1;
316 size[1] = amplitude[2] + amplitude[3] + 1;
317 size[2] = amplitude[4] + amplitude[5] + 1;
321 * (ez - sz) * (ey - sy) * (ex - sx) );
323 std::cout <<
"Filtering progress: ";
325 for( t = 0; t < in->
getSizeT(); ++t )
326 for( z = sz; z < ez; ++z )
327 for( y = sy; y < ey; ++y )
328 for( x = sx; x < ex; ++x )
331 (++progress).print();
333 pos[0] = x - amplitude[0];
334 pos[1] = y - amplitude[2];
335 pos[2] = z - amplitude[4];
338 (*out)( x, y, z, t ) =
_func->execute( win );
342 std::cout << std::endl;
349 template <
typename T>
361 _func->setOptions( options );
366 _func->updateOptions( options );
369 virtual ::aims::singlechannel::ElementFilteringImageAlgorithm<T> *
clone()
const {
370 return new ::aims::singlechannel::ElementFilteringImageAlgorithm<T>(*this);
378 _strel.reset( se.
clone() );
398 _strel(other._strel->
clone())
402 const ::aims::singlechannel::ElementFilteringImageAlgorithm<T> & other )
404 assert(
typeid(other) ==
typeid(*
this) );
407 _func.reset( other._func->clone() );
408 _strel.reset( other._strel->clone() );
423 template <
typename T>
430 int sx, sy, sz, ex, ey, ez, x, y, z, t;
434 const std::vector<int> & border = in->
getBorders();
435 const std::vector<int> amplitude = _strel->getAmplitude();
438 sz = (amplitude[4] < border[4]) ? 0 : amplitude[4] - border[4];
439 sy = (amplitude[2] < border[2]) ? 0 : amplitude[2] - border[2];
440 sx = (amplitude[0] < border[0]) ? 0 : amplitude[0] - border[0];
441 ez = (amplitude[5] < border[5]) ? in->
getSizeZ() : in->
getSizeZ() - amplitude[5] + border[5];
442 ey = (amplitude[3] < border[3]) ? in->
getSizeY() : in->
getSizeY() - amplitude[3] + border[3];
443 ex = (amplitude[1] < border[1]) ? in->
getSizeX() : in->
getSizeX() - amplitude[1] + border[1];
446 std::cout <<
"Filter amplitude (voxels): [ ";
447 for(
int i = 0; i < 6; ++i)
449 std::cout <<
"]" << std::endl;
450 std::cout <<
"Processing with borders (voxels): [ ";
451 for(
int i = 0; i < 8; ++i)
453 std::cout <<
"]" << std::endl;
465 * (ez - sz) * (ey - sy) *(ex - sx) );
467 std::cout <<
"Filtering progress: ";
469 for( t = 0; t < in->
getSizeT(); ++t )
470 for( z = sz; z < ez; ++z )
471 for( y = sy; y < ey; ++y )
472 for( x = sx; x < ex; ++x )
475 (++progress).print();
482 (*out)( x, y, z, t ) =
_func->execute( win, _strel );
486 std::cout << std::endl;
LinearFilteringImageAlgorithm(const LinearFilteringFunction< T > &f)
virtual void updateOptions(const carto::Object &options)
SingleChannelImageAlgorithmType * _ealgo
virtual void setStructuringElement(const StructuringElement &se)
virtual ~ElementFilteringImageAlgorithm()
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)
SingleChannelImageAlgorithmType * _lalgo
singlechannel::ElementFilteringImageAlgorithm< ChannelType > SingleChannelImageAlgorithmType
singlechannel::LinearFilteringImageAlgorithm< ChannelType > SingleChannelImageAlgorithmType
Base class for filtering functions applied in a structuring element.
virtual ~ElementFilteringImageAlgorithm()
const PropertySet & header() const
virtual ElementFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual LinearFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual void setOptions(const carto::Object &options)
carto::rc_ptr< LinearFilteringFunction< T > > _func
virtual ::aims::singlechannel::ElementFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual ::aims::singlechannel::LinearFilteringImageAlgorithm< T > * clone() const
ImageAlgorithmInterface<T> Pure virtual method.
virtual void updateOptions(const carto::Object &options)
LinearFilteringImageAlgorithm(const LinearFilteringFunction< ChannelType > &f)
virtual void setStructuringElement(const StructuringElement &se)
void setPosInRefVolume(const Position4Di &pos)
virtual ~LinearFilteringImageAlgorithm()
carto::DataTypeTraits< T >::ChannelType ChannelType
aims::ImageAlgorithm class used to implement image algorithms
virtual void setOptions(const carto::Object &options)
LinearFilteringImageAlgorithm & operator=(const LinearFilteringImageAlgorithm &other)
virtual ~LinearFilteringImageAlgorithm()
LinearFilteringImageAlgorithm(const LinearFilteringImageAlgorithm< T > &other)
ElementFilteringImageAlgorithm(const ElementFilteringImageAlgorithm< T > &other)
carto::rc_ptr< ElementFilteringFunction< T > > _func
aims::ImageAlgorithmInterface is the interface for an image processing algorithm. ...
Base class for linear filtering functions.
virtual void setOptions(const carto::Object &options)
LinearFilteringImageAlgorithm(const ::aims::singlechannel::LinearFilteringImageAlgorithm< T > &other)
virtual void execute(const carto::VolumeRef< T > &in, carto::VolumeRef< T > &out) const
ImageAlgorithmInterface<T> Pure virtual method.
ElementFilteringImageAlgorithm(const ::aims::singlechannel::ElementFilteringImageAlgorithm< T > &other)
std::string toString(const T &object)
carto::DataTypeTraits< T >::ChannelType ChannelType
ElementFilteringImageAlgorithm(const ElementFilteringFunction< T > &f, const StructuringElement &se=strel::Cube(1.))
virtual void setOptions(const carto::Object &options)
::aims::singlechannel::ElementFilteringImageAlgorithm< T > & operator=(const ::aims::singlechannel::ElementFilteringImageAlgorithm< T > &other)
std::vector< int > getBorders() const
carto::rc_ptr< StructuringElement > _strel
virtual void updateOptions(const carto::Object &options)
LinearFilteringImageAlgorithm()
ElementFilteringImageAlgorithm(const ElementFilteringFunction< ChannelType > &f, const StructuringElement &se=strel::Cube(1.))
virtual StructuringElement * clone() const