23 #include <itkImageIOBase.h>
24 #include <itkImageRegionConstIterator.h>
25 #include <itkImageRegionIteratorWithIndex.h>
26 #include <itkRGBAPixel.h>
30 this->SetNumberOfIndexedInputs(1);
31 this->SetNumberOfRequiredInputs(1);
45 if ((inputPixelType.
GetPixelType() == itk::ImageIOBase::RGB) &&
59 Superclass::GenerateInputRequestedRegion();
78 if ((output->IsInitialized()) && (this->GetMTime() <= m_TimeOfHeaderInitialization.GetMTime()))
81 itkDebugMacro(<<
"GenerateOutputInformation()");
86 typedef itk::Image<UCRGBPixelType> UCRGBItkImageType;
87 typedef itk::Image<USRGBPixelType> USRGBItkImageType;
88 typedef itk::Image<FloatRGBPixelType> FloatCRGBItkImageType;
89 typedef itk::Image<DoubleRGBPixelType> DoubleRGBItkImageType;
91 if (inputPixelType == mitk::MakePixelType<UCRGBItkImageType>())
94 output->Initialize(refPtype, *input->GetTimeGeometry());
96 else if (inputPixelType == mitk::MakePixelType<USRGBItkImageType>())
99 output->Initialize(refPtype, *input->GetTimeGeometry());
101 else if (inputPixelType == mitk::MakePixelType<FloatCRGBItkImageType>())
103 const mitk::PixelType refPtype = MakePixelType<FloatCRGBItkImageType>();
104 output->Initialize(refPtype, *input->GetTimeGeometry());
106 else if (inputPixelType == mitk::MakePixelType<DoubleRGBItkImageType>())
108 const mitk::PixelType refPtype = MakePixelType<DoubleRGBItkImageType>();
109 output->Initialize(refPtype, *input->GetTimeGeometry());
112 output->SetPropertyList(input->GetPropertyList()->Clone());
114 m_TimeOfHeaderInitialization.Modified();
122 if (!output->IsInitialized())
127 m_InputTimeSelector->SetInput(input);
128 m_OutputTimeSelector->SetInput(this->GetOutput());
136 int tstart = outputRegion.GetIndex(3);
137 int tmax = tstart + outputRegion.GetSize(3);
140 for (t = tstart; t < tmax; ++t)
145 m_InputTimeSelector->SetTimeNr(timestep);
146 m_InputTimeSelector->UpdateLargestPossibleRegion();
147 m_OutputTimeSelector->SetTimeNr(t);
148 m_OutputTimeSelector->UpdateLargestPossibleRegion();
150 mitk::Image *image = m_InputTimeSelector->GetOutput();
155 if (pixelType ==
MakePixelType<itk::Image<UCRGBPixelType>>())
159 else if (pixelType ==
MakePixelType<itk::Image<USRGBPixelType>>())
163 else if (pixelType ==
MakePixelType<itk::Image<FloatRGBPixelType>>())
167 else if (pixelType ==
MakePixelType<itk::Image<DoubleRGBPixelType>>())
179 m_TimeOfHeaderInitialization.Modified();
182 template <
typename TPixel,
unsigned int VImageDimension>
185 typename TPixel::ComponentType defaultAlpha)
188 typedef itk::RGBAPixel<typename TPixel::ComponentType> OutputPixelType;
189 typedef itk::Image<InputPixelType, VImageDimension>
InputImageType;
192 typedef itk::ImageRegionConstIterator<InputImageType> InputImageIteratorType;
193 typedef itk::ImageRegionIteratorWithIndex<OutputImageType> OutputImageIteratorType;
197 outputimagetoitk->Update();
202 InputImageIteratorType inputIt(inputItkImage, inputRegionOfInterest);
203 OutputImageIteratorType outputIt(outputItkImage, inputRegionOfInterest);
205 for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt, ++outputIt)
207 typename InputPixelType::Iterator pixelInputIt = inputIt.Get().Begin();
208 typename OutputPixelType::Iterator pixelOutputIt = outputIt.Get().Begin();
210 *pixelOutputIt++ = *pixelInputIt++;
211 *pixelOutputIt++ = *pixelInputIt++;
212 *pixelOutputIt++ = *pixelInputIt++;
213 *pixelOutputIt = defaultAlpha;
virtual void SetRequestedRegionToLargestPossibleRegion() override
itk::RGBPixel< float > FloatRGBPixelType
itk::RGBPixel< unsigned char > UCRGBPixelType
virtual void GenerateData() override
A version of GenerateData() specific for image processing filters.
itk::RGBPixel< double > DoubleRGBPixelType
mitk::ImageTimeSelector::Pointer m_InputTimeSelector
itk::ImageIOBase::IOPixelType GetPixelType() const
mitk::ImageTimeSelector::Pointer m_OutputTimeSelector
virtual void GenerateInputRequestedRegion() override
MITKCORE_EXPORT mitk::PixelType MakePixelType(vtkImageData *vtkimagedata)
deduct the PixelType for a given vtk image
virtual void GenerateOutputInformation() override
itk::RGBPixel< unsigned short > USRGBPixelType
itk::Image< double, 3 > InputImageType
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.
~RGBToRGBACastImageFilter()
static bool IsRGBImage(const mitk::Image *image)
mitk::ScalarType TimePointType
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
#define AccessFixedPixelTypeByItk_2(mitkImage, itkImageTypeFunction, pixelTypeSeq, arg1, arg2)
RGBToRGBACastImageFilter()
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
void InternalCast(itk::Image< TPixel, VImageDimension > *itkImage, mitk::RGBToRGBACastImageFilter *addComponentFilter, typename TPixel::ComponentType defaultAlpha)
Class for defining the data type of pixels.