19 #include <itkImageIOBase.h> 20 #include <itkImageRegionConstIterator.h> 21 #include <itkImageRegionIteratorWithIndex.h> 22 #include <itkRGBAPixel.h> 26 this->SetNumberOfIndexedInputs(1);
27 this->SetNumberOfRequiredInputs(1);
41 if ((inputPixelType.
GetPixelType() == itk::ImageIOBase::RGB) &&
77 itkDebugMacro(<<
"GenerateOutputInformation()");
82 typedef itk::Image<UCRGBPixelType> UCRGBItkImageType;
83 typedef itk::Image<USRGBPixelType> USRGBItkImageType;
84 typedef itk::Image<FloatRGBPixelType> FloatCRGBItkImageType;
85 typedef itk::Image<DoubleRGBPixelType> DoubleRGBItkImageType;
87 if (inputPixelType == mitk::MakePixelType<UCRGBItkImageType>())
90 output->Initialize(refPtype, *input->GetTimeGeometry());
92 else if (inputPixelType == mitk::MakePixelType<USRGBItkImageType>())
95 output->Initialize(refPtype, *input->GetTimeGeometry());
97 else if (inputPixelType == mitk::MakePixelType<FloatCRGBItkImageType>())
99 const mitk::PixelType refPtype = MakePixelType<FloatCRGBItkImageType>();
100 output->Initialize(refPtype, *input->GetTimeGeometry());
102 else if (inputPixelType == mitk::MakePixelType<DoubleRGBItkImageType>())
104 const mitk::PixelType refPtype = MakePixelType<DoubleRGBItkImageType>();
105 output->Initialize(refPtype, *input->GetTimeGeometry());
108 output->SetPropertyList(input->GetPropertyList()->Clone());
118 if (!output->IsInitialized())
132 int tstart = outputRegion.GetIndex(3);
133 int tmax = tstart + outputRegion.GetSize(3);
136 for (t = tstart; t < tmax; ++t)
151 if (pixelType ==
MakePixelType<itk::Image<UCRGBPixelType>>())
155 else if (pixelType ==
MakePixelType<itk::Image<USRGBPixelType>>())
159 else if (pixelType ==
MakePixelType<itk::Image<FloatRGBPixelType>>())
163 else if (pixelType ==
MakePixelType<itk::Image<DoubleRGBPixelType>>())
178 template <
typename TPixel,
unsigned int VImageDimension>
181 typename TPixel::ComponentType defaultAlpha)
183 typedef TPixel InputPixelType;
184 typedef itk::RGBAPixel<typename TPixel::ComponentType> OutputPixelType;
185 typedef itk::Image<InputPixelType, VImageDimension>
InputImageType;
188 typedef itk::ImageRegionConstIterator<InputImageType> InputImageIteratorType;
189 typedef itk::ImageRegionIteratorWithIndex<OutputImageType> OutputImageIteratorType;
193 outputimagetoitk->Update();
198 InputImageIteratorType inputIt(inputItkImage, inputRegionOfInterest);
199 OutputImageIteratorType outputIt(outputItkImage, inputRegionOfInterest);
201 for (inputIt.GoToBegin(), outputIt.GoToBegin(); !inputIt.IsAtEnd(); ++inputIt, ++outputIt)
203 typename InputPixelType::Iterator pixelInputIt = inputIt.Get().Begin();
204 typename OutputPixelType::Iterator pixelOutputIt = outputIt.Get().Begin();
206 *pixelOutputIt++ = *pixelInputIt++;
207 *pixelOutputIt++ = *pixelInputIt++;
208 *pixelOutputIt++ = *pixelInputIt++;
209 *pixelOutputIt = defaultAlpha;
void SetRequestedRegionToLargestPossibleRegion() override
itk::RGBPixel< float > FloatRGBPixelType
itk::RGBPixel< unsigned char > UCRGBPixelType
void GenerateData() override
const mitk::PixelType GetPixelType(int n=0) const
Returns the PixelType of channel n.
itk::RGBPixel< double > DoubleRGBPixelType
mitk::ImageTimeSelector::Pointer m_InputTimeSelector
mitk::ImageTimeSelector::Pointer m_OutputTimeSelector
int GetComponentType() const
Get the component type (the scalar (!) type). Each element may contain m_NumberOfComponents (more tha...
void GenerateInputRequestedRegion() override
MITKCORE_EXPORT mitk::PixelType MakePixelType(vtkImageData *vtkimagedata)
deduct the PixelType for a given vtk image
mitk::Image InputImageType
void GenerateOutputInformation() override
itk::RGBPixel< unsigned short > USRGBPixelType
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.
mitk::Image OutputImageType
Some convenient typedefs.
static bool IsRGBImage(const mitk::Image *image)
mitk::ScalarType TimePointType
itk::ImageIOBase::IOPixelType GetPixelType() const
mitk::Image::Pointer image
~RGBToRGBACastImageFilter() override
#define AccessFixedPixelTypeByItk_2(mitkImage, itkImageTypeFunction, pixelTypeSeq, arg1, arg2)
InputImageType * GetInput(void)
virtual bool IsInitialized() const
Check whether the data has been initialized, i.e., at least the Geometry and other header data has be...
RGBToRGBACastImageFilter()
OutputType * GetOutput()
Get the output data of this image source object.
void GenerateInputRequestedRegion() override
void InternalCast(itk::Image< TPixel, VImageDimension > *itkImage, mitk::RGBToRGBACastImageFilter *addComponentFilter, typename TPixel::ComponentType defaultAlpha)
Class for defining the data type of pixels.
itk::TimeStamp m_TimeOfHeaderInitialization