diff --git a/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.cpp b/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.cpp index 8df57d7acb..dc94cfa62f 100644 --- a/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.cpp +++ b/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.cpp @@ -1,108 +1,108 @@ /*=================================================================== 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. ===================================================================*/ #include "mitkLabelSetImageSurfaceStampFilter.h" #include "mitkImageAccessByItk.h" #include "mitkImageCast.h" #include #include #include #include mitk::LabelSetImageSurfaceStampFilter::LabelSetImageSurfaceStampFilter() { this->SetNumberOfIndexedInputs(1); this->SetNumberOfRequiredInputs(1); } mitk::LabelSetImageSurfaceStampFilter::~LabelSetImageSurfaceStampFilter() { } void mitk::LabelSetImageSurfaceStampFilter::GenerateData() { //GenerateOutputInformation(); this->SetNthOutput(0,this->GetInput(0)); mitk::Image::Pointer inputImage = this->GetInput(0); if (m_Surface.IsNull()) { MITK_ERROR << "Input surface is NULL."; return; } mitk::SurfaceToImageFilter::Pointer surfaceToImageFilter = mitk::SurfaceToImageFilter::New(); surfaceToImageFilter->MakeOutputBinaryOn(); surfaceToImageFilter->SetInput(m_Surface); surfaceToImageFilter->SetImage(inputImage); surfaceToImageFilter->Update(); mitk::Image::Pointer resultImage = surfaceToImageFilter->GetOutput(); - AccessByItk_2(inputImage, ItkImageProcessing, m_Surface, resultImage); + AccessByItk_1(inputImage, ItkImageProcessing, resultImage); inputImage->DisconnectPipeline(); } template -void mitk::LabelSetImageSurfaceStampFilter::ItkImageProcessing( itk::Image* itkImage, mitk::Surface::Pointer surface, mitk::Image::Pointer resultImage ) +void mitk::LabelSetImageSurfaceStampFilter::ItkImageProcessing( itk::Image* itkImage, mitk::Image::Pointer resultImage ) { typedef itk::Image ImageType; mitk::LabelSetImage::Pointer LabelSetInputImage = dynamic_cast(GetInput()); try { typename ImageType::Pointer itkResultImage = ImageType::New(); mitk::CastToItkImage(resultImage, itkResultImage); typedef itk::ImageRegionConstIterator< ImageType > SourceIteratorType; typedef itk::ImageRegionIterator< ImageType > TargetIteratorType; SourceIteratorType sourceIter(itkResultImage, itkResultImage->GetLargestPossibleRegion()); sourceIter.GoToBegin(); TargetIteratorType targetIter(itkImage, itkImage->GetLargestPossibleRegion()); targetIter.GoToBegin(); int activeLabel = (LabelSetInputImage->GetActiveLabel(LabelSetInputImage->GetActiveLayer()))->GetValue(); while (!sourceIter.IsAtEnd()) { int sourceValue = static_cast(sourceIter.Get()); int targetValue = static_cast(targetIter.Get()); if ((sourceValue != 0) && (m_ForceOverwrite || !LabelSetInputImage->GetLabel(targetValue)->GetLocked())) // skip exterior and locked labels { targetIter.Set(activeLabel); } ++sourceIter; ++targetIter; } } catch (itk::ExceptionObject& e) { mitkThrow() << e.GetDescription(); } this->Modified(); } void mitk::LabelSetImageSurfaceStampFilter::GenerateOutputInformation() { mitk::Image::Pointer inputImage = (mitk::Image*) this->GetInput(); mitk::Image::Pointer output = this->GetOutput(); itkDebugMacro(<<"GenerateOutputInformation()"); if(inputImage.IsNull()) return; -} \ No newline at end of file +} diff --git a/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.h b/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.h index 1a48c8248d..4056af7cf1 100644 --- a/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.h +++ b/Modules/Multilabel/mitkLabelSetImageSurfaceStampFilter.h @@ -1,71 +1,71 @@ /*=================================================================== 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 __mitkLabelSetImageSurfaceStampFilter_h #define __mitkLabelSetImageSurfaceStampFilter_h #include "MitkMultilabelExports.h" //MITK #include #include "mitkImageToImageFilter.h" #include #include namespace mitk { class MITKMULTILABEL_EXPORT LabelSetImageSurfaceStampFilter : public ImageToImageFilter { public: mitkClassMacro( LabelSetImageSurfaceStampFilter , ImageToImageFilter ); itkFactorylessNewMacro(Self); itkCloneMacro(Self); itkGetConstMacro(Surface,Surface::Pointer); itkSetMacro(Surface,Surface::Pointer); itkGetConstMacro(ForceOverwrite,bool); itkSetMacro(ForceOverwrite,bool); private: /*! \brief standard constructor */ LabelSetImageSurfaceStampFilter(); /*! \brief standard destructor */ ~LabelSetImageSurfaceStampFilter(); /*! \brief Method generating the output information of this filter (e.g. image dimension, image type, etc.). The interface ImageToImageFilter requires this implementation. Everything is taken from the input image. */ virtual void GenerateOutputInformation() override; /*! \brief Method generating the output of this filter. Called in the updated process of the pipeline. This method generates the smoothed output image. */ virtual void GenerateData() override; /*! \brief Internal templated method calling the ITK bilteral filter. Here the actual filtering is performed. */ template - void ItkImageProcessing( itk::Image* itkImage, mitk::Surface::Pointer surface, mitk::Image::Pointer resultImage ); + void ItkImageProcessing( itk::Image* itkImage, mitk::Image::Pointer resultImage ); Surface::Pointer m_Surface; bool m_ForceOverwrite; }; } //END mitk namespace #endif