algorithm on filters
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#define VOXIMAGEFILTER_H
|
#define VOXIMAGEFILTER_H
|
||||||
|
|
||||||
#include "Core/StaticInterface.h"
|
#include "Core/StaticInterface.h"
|
||||||
|
#include "Core/Algorithm.h"
|
||||||
#include "Math/Dense.h"
|
#include "Math/Dense.h"
|
||||||
|
|
||||||
#include "Math/VoxImage.h"
|
#include "Math/VoxImage.h"
|
||||||
@@ -57,7 +58,8 @@ protected:
|
|||||||
} // namespace Abstract
|
} // namespace Abstract
|
||||||
|
|
||||||
template <typename VoxelT, typename AlgorithmT>
|
template <typename VoxelT, typename AlgorithmT>
|
||||||
class VoxImageFilter : public Abstract::VoxImageFilter, public Object {
|
class VoxImageFilter : public Abstract::VoxImageFilter,
|
||||||
|
public Algorithm<VoxImage<VoxelT>*, VoxImage<VoxelT>*> {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -65,6 +67,16 @@ public:
|
|||||||
|
|
||||||
VoxImageFilter(const Vector3i &size);
|
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 Run();
|
||||||
|
|
||||||
void SetKernelNumericXZY(const std::vector<float> &numeric);
|
void SetKernelNumericXZY(const std::vector<float> &numeric);
|
||||||
|
|||||||
@@ -106,12 +106,19 @@ VoxImageFilter<_TPLT_>::VoxImageFilter(const Vector3i &size)
|
|||||||
: m_KernelData(size), t_Algoritm(static_cast<AlgorithmT *>(this)) {}
|
: m_KernelData(size), t_Algoritm(static_cast<AlgorithmT *>(this)) {}
|
||||||
|
|
||||||
_TPL_
|
_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;
|
VoxImage<VoxelT> buffer = *m_Image;
|
||||||
#pragma omp parallel for
|
#pragma omp parallel for
|
||||||
for (int i = 0; i < m_Image->Data().size(); ++i)
|
for (int i = 0; i < m_Image->Data().size(); ++i)
|
||||||
m_Image->operator[](i).Value = this->t_Algoritm->Evaluate(buffer, i);
|
m_Image->operator[](i).Value = this->t_Algoritm->Evaluate(buffer, i);
|
||||||
#pragma omp barrier
|
#pragma omp barrier
|
||||||
|
return m_Image;
|
||||||
|
}
|
||||||
|
|
||||||
|
_TPL_
|
||||||
|
void VoxImageFilter<_TPLT_>::Run() {
|
||||||
|
Process(m_Image);
|
||||||
}
|
}
|
||||||
|
|
||||||
_TPL_
|
_TPL_
|
||||||
|
|||||||
Reference in New Issue
Block a user