diff --git a/Modules/Classification/CLActiveLearning/include/mitkPredictionUncertaintyFilter.h b/Modules/Classification/CLActiveLearning/include/mitkPredictionUncertaintyFilter.h index 06899e4042..21e832c99f 100644 --- a/Modules/Classification/CLActiveLearning/include/mitkPredictionUncertaintyFilter.h +++ b/Modules/Classification/CLActiveLearning/include/mitkPredictionUncertaintyFilter.h @@ -1,60 +1,68 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkPredictionUncertaintyFilter_h #define mitkPredictionUncertaintyFilter_h #include #include // ITK #include #include #include namespace mitk { + template class MITKCLACTIVELEARNING_EXPORT PredictionUncertaintyFilter : public itk::ImageToImageFilter { public: typedef itk::ImageToImageFilter SuperClassName; mitkClassMacro(PredictionUncertaintyFilter, SuperClassName) -// itkFactorylessNewMacro(Self) -// itkCloneMacro(Self) itkNewMacro(Self) +// itkFactorylessNewMacro(Self) + typedef typename Superclass::InputImageDimension InputDimension; + typedef typename Superclass::InputImagePixelType InputPixelType; + typedef typename Superclass::InputImageRegionType InputRegionType; + typedef typename Superclass::OutputImageDimension OutputDimension; + typedef typename Superclass::OutputImagePixelType OutputPixelType; + typedef typename Superclass::OutputImageRegionType OutputRegionType; protected: PredictionUncertaintyFilter(){} ~PredictionUncertaintyFilter(){} - virtual void ThreadedGenerateData(const typename Superclass::OutputImageRegionType& outputRegionForThread, itk::ThreadIdType threadId); + virtual OutputPixelType CalculateUncertainty(const InputPixelType& inputVector); + + virtual void ThreadedGenerateData(const OutputRegionType& outputRegionForThread, itk::ThreadIdType threadId); private: // ITK examples do this... PredictionUncertaintyFilter(const Self&); void operator=(const Self&); }; } #endif diff --git a/Modules/Classification/CLActiveLearning/src/mitkPredictionUncertaintyFilter.cpp b/Modules/Classification/CLActiveLearning/src/mitkPredictionUncertaintyFilter.cpp index 0f397a185a..c7fde04ccb 100644 --- a/Modules/Classification/CLActiveLearning/src/mitkPredictionUncertaintyFilter.cpp +++ b/Modules/Classification/CLActiveLearning/src/mitkPredictionUncertaintyFilter.cpp @@ -1,28 +1,43 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ +// ITK +#include +#include + +// MITK #include namespace mitk { template - void PredictionUncertaintyFilter::ThreadedGenerateData(const Superclass::OutputImageRegionType &outputRegionForThread, itk::ThreadIdType threadId) + void PredictionUncertaintyFilter::ThreadedGenerateData(const OutputRegionType &outputRegionForThread, itk::ThreadIdType threadId) { typename InputImageType::ConstPointer input = this->GetInput(); - typename OutputImageType::Pointer output = this->GetOutput() + typename OutputImageType::Pointer output = this->GetOutput(); + + itk::ImageRegionConstIterator inputIt(input, outputRegionForThread); + itk::ImageRegionIterator outputIt(output, outputRegionForThread); + + while (!outputIt.IsAtEnd()) + { + outputIt.Set(CalculateUncertainty(inputIt.Get())); + ++inputIt; + ++outputIt; + } } }