algorithm on filters

This commit is contained in:
AndreaRigoni
2026-03-27 02:45:40 +00:00
parent f5c1e317e8
commit 69b47623f8
2 changed files with 21 additions and 2 deletions

View File

@@ -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 <typename VoxelT, typename AlgorithmT>
class VoxImageFilter : public Abstract::VoxImageFilter, public Object {
class VoxImageFilter : public Abstract::VoxImageFilter,
public Algorithm<VoxImage<VoxelT>*, VoxImage<VoxelT>*> {
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<VoxelT>* Process(VoxImage<VoxelT>* const& image) override;
/**
* @brief Run implements Abstract::VoxImageFilter::Run.
* Calls Process on the current image.
*/
void Run();
void SetKernelNumericXZY(const std::vector<float> &numeric);

View File

@@ -106,12 +106,19 @@ VoxImageFilter<_TPLT_>::VoxImageFilter(const Vector3i &size)
: m_KernelData(size), t_Algoritm(static_cast<AlgorithmT *>(this)) {}
_TPL_
void VoxImageFilter<_TPLT_>::Run() {
VoxImage<VoxelT>* VoxImageFilter<_TPLT_>::Process(VoxImage<VoxelT>* const& image) {
if (m_Image != image) SetImage(image);
VoxImage<VoxelT> 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_