diff --git a/src/Math/VoxImageFilter.h b/src/Math/VoxImageFilter.h index e66778a..9af5099 100644 --- a/src/Math/VoxImageFilter.h +++ b/src/Math/VoxImageFilter.h @@ -27,6 +27,7 @@ #define VOXIMAGEFILTER_H #include "Core/StaticInterface.h" +#include "Core/Algorithm.h" #include "Math/Dense.h" #include "Math/VoxImage.h" @@ -57,7 +58,8 @@ protected: } // namespace Abstract template -class VoxImageFilter : public Abstract::VoxImageFilter, public Object { +class VoxImageFilter : public Abstract::VoxImageFilter, + public Algorithm*, VoxImage*> { public: @@ -65,6 +67,16 @@ public: VoxImageFilter(const Vector3i &size); + /** + * @brief Process implements Algorithm::Process. + * Applies the filter in-place on the input image and returns it. + */ + VoxImage* Process(VoxImage* const& image) override; + + /** + * @brief Run implements Abstract::VoxImageFilter::Run. + * Calls Process on the current image. + */ void Run(); void SetKernelNumericXZY(const std::vector &numeric); diff --git a/src/Math/VoxImageFilter.hpp b/src/Math/VoxImageFilter.hpp index 9b3f243..fdf1df6 100644 --- a/src/Math/VoxImageFilter.hpp +++ b/src/Math/VoxImageFilter.hpp @@ -106,12 +106,19 @@ VoxImageFilter<_TPLT_>::VoxImageFilter(const Vector3i &size) : m_KernelData(size), t_Algoritm(static_cast(this)) {} _TPL_ -void VoxImageFilter<_TPLT_>::Run() { +VoxImage* VoxImageFilter<_TPLT_>::Process(VoxImage* const& image) { + if (m_Image != image) SetImage(image); VoxImage buffer = *m_Image; #pragma omp parallel for for (int i = 0; i < m_Image->Data().size(); ++i) m_Image->operator[](i).Value = this->t_Algoritm->Evaluate(buffer, i); #pragma omp barrier + return m_Image; +} + +_TPL_ +void VoxImageFilter<_TPLT_>::Run() { + Process(m_Image); } _TPL_