25 #include "itkImageRegionConstIterator.h"
26 #include "itkImageRegionIteratorWithIndex.h"
32 this->SetNumberOfIndexedInputs(2);
33 this->SetNumberOfRequiredInputs(2);
49 this->ProcessObject::SetNthInput(1, m_Mask);
59 Superclass::GenerateInputRequestedRegion();
79 if ((output->IsInitialized()) && (this->GetMTime() <= m_TimeOfHeaderInitialization.GetMTime()))
82 itkDebugMacro(<<
"GenerateOutputInformation()");
84 output->Initialize(input->GetPixelType(), *input->GetTimeGeometry());
86 output->SetPropertyList(input->GetPropertyList()->Clone());
88 m_TimeOfHeaderInitialization.Modified();
91 template <
typename TPixel,
unsigned int VImageDimension>
97 m_MaskTimeSelector->GetOutput()->GetImageDescriptor()->GetChannelDescriptor().
GetPixelType();
100 typedef itk::Image<TPixel, VImageDimension> ItkInputImageType;
101 typedef itk::Image<unsigned char, VImageDimension> ItkMaskImageType;
102 typedef itk::Image<TPixel, VImageDimension> ItkOutputImageType;
104 typedef itk::ImageRegionConstIterator<ItkInputImageType> ItkInputImageIteratorType;
105 typedef itk::ImageRegionConstIterator<ItkMaskImageType> ItkMaskImageIteratorType;
106 typedef itk::ImageRegionIteratorWithIndex<ItkOutputImageType> ItkOutputImageIteratorType;
109 maskimagetoitk->SetInput(m_MaskTimeSelector->GetOutput());
110 maskimagetoitk->Update();
115 outputimagetoitk->SetInput(m_OutputTimeSelector->GetOutput());
116 outputimagetoitk->Update();
120 typename ItkInputImageType::RegionType inputRegionOfInterest = inputItkImage->GetLargestPossibleRegion();
121 ItkInputImageIteratorType inputIt(inputItkImage, inputRegionOfInterest);
122 ItkMaskImageIteratorType maskIt(maskItkImage, inputRegionOfInterest);
123 ItkOutputImageIteratorType outputIt(outputItkImage, inputRegionOfInterest);
127 if (!m_OverrideOutsideValue)
133 for (inputIt.GoToBegin(), maskIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd() && !maskIt.IsAtEnd();
134 ++inputIt, ++maskIt, ++outputIt)
136 if (maskIt.Get() > itk::NumericTraits<typename ItkMaskImageType::PixelType>::Zero)
138 outputIt.Set(inputIt.Get());
139 m_MinValue = vnl_math_min((
float)inputIt.Get(), (float)m_MinValue);
140 m_MaxValue = vnl_math_max((
float)inputIt.Get(), (float)m_MaxValue);
144 outputIt.Set(m_OutsideValue);
151 typedef itk::Image<TPixel, VImageDimension> ItkInputImageType;
152 typedef itk::Image<unsigned short, VImageDimension> ItkMaskImageType;
153 typedef itk::Image<TPixel, VImageDimension> ItkOutputImageType;
155 typedef itk::ImageRegionConstIterator<ItkInputImageType> ItkInputImageIteratorType;
156 typedef itk::ImageRegionConstIterator<ItkMaskImageType> ItkMaskImageIteratorType;
157 typedef itk::ImageRegionIteratorWithIndex<ItkOutputImageType> ItkOutputImageIteratorType;
160 maskimagetoitk->SetInput(m_MaskTimeSelector->GetOutput());
161 maskimagetoitk->Update();
166 outputimagetoitk->SetInput(m_OutputTimeSelector->GetOutput());
167 outputimagetoitk->Update();
171 typename ItkInputImageType::RegionType inputRegionOfInterest = inputItkImage->GetLargestPossibleRegion();
172 ItkInputImageIteratorType inputIt(inputItkImage, inputRegionOfInterest);
173 ItkMaskImageIteratorType maskIt(maskItkImage, inputRegionOfInterest);
174 ItkOutputImageIteratorType outputIt(outputItkImage, inputRegionOfInterest);
178 if (!m_OverrideOutsideValue)
184 for (inputIt.GoToBegin(), maskIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd() && !maskIt.IsAtEnd();
185 ++inputIt, ++maskIt, ++outputIt)
187 if (maskIt.Get() > itk::NumericTraits<typename ItkMaskImageType::PixelType>::Zero)
189 outputIt.Set(inputIt.Get());
190 m_MinValue = vnl_math_min((
float)inputIt.Get(), (float)m_MinValue);
191 m_MaxValue = vnl_math_max((
float)inputIt.Get(), (float)m_MaxValue);
195 outputIt.Set(m_OutsideValue);
208 if ((output->IsInitialized() ==
false) || (mask.IsNull()) || (mask->GetTimeGeometry()->CountTimeSteps() == 0))
211 m_InputTimeSelector->SetInput(input);
212 m_MaskTimeSelector->SetInput(mask);
213 m_OutputTimeSelector->SetInput(this->GetOutput());
222 int tstart = outputRegion.GetIndex(3);
223 int tmax = tstart + outputRegion.GetSize(3);
226 for (t = tstart; t < tmax; ++t)
232 m_InputTimeSelector->SetTimeNr(timestep);
233 m_InputTimeSelector->UpdateLargestPossibleRegion();
234 m_OutputTimeSelector->SetTimeNr(t);
235 m_OutputTimeSelector->UpdateLargestPossibleRegion();
238 m_MaskTimeSelector->SetTimeNr(timestep);
239 m_MaskTimeSelector->UpdateLargestPossibleRegion();
241 AccessByItk(m_InputTimeSelector->GetOutput(), InternalComputeMask);
244 m_TimeOfHeaderInitialization.Modified();
virtual void SetRequestedRegionToLargestPossibleRegion() override
itk::SmartPointer< Self > Pointer
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
itk::ImageIOBase::IOPixelType GetPixelType() const
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
itk::ImageRegion< RegionDimension > RegionType
virtual TimeStepType TimePointToTimeStep(TimePointType timePoint) const =0
Converts a time point to the corresponding time step.
Image class for storing images.
virtual TimePointType TimeStepToTimePoint(TimeStepType timeStep) const =0
Converts a time step to a time point.
#define AccessByItk(mitkImage, itkImageTypeFunction)
Access a MITK image by an ITK image.
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
bool m_OverrideOutsideValue
const mitk::Image * GetMask() const
void GenerateTimeInInputRegion(const mitk::TimeGeometry *outputTimeGeometry, const TOutputRegion &outputRegion, const mitk::TimeGeometry *inputTimeGeometry, TInputRegion &inputRegion)
void SetMask(const mitk::Image *mask)
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
void InternalComputeMask(itk::Image< TPixel, VImageDimension > *itkImage)
virtual void GenerateOutputInformation() override
mitk::ImageTimeSelector::Pointer m_InputTimeSelector
mitk::ScalarType m_OutsideValue
mitk::ImageTimeSelector::Pointer m_MaskTimeSelector
virtual void GenerateInputRequestedRegion() override
Class for defining the data type of pixels.
mitk::ImageTimeSelector::Pointer m_OutputTimeSelector