X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2FKernel%2FITKVTK%2Fitkvtkcolortransferfunction.txx;fp=lib%2FKernel%2FITKVTK%2Fitkvtkcolortransferfunction.txx;h=e3e044e6fa45bfeff8f77968d661f425ae73e7e3;hb=0d47d470f614b02b3fb6d06b7688585bf535b6a7;hp=0000000000000000000000000000000000000000;hpb=aa3ed5b53d8c30782368846b90e1b3df057e1648;p=creaMaracasVisu.git diff --git a/lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx b/lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx new file mode 100644 index 0000000..e3e044e --- /dev/null +++ b/lib/Kernel/ITKVTK/itkvtkcolortransferfunction.txx @@ -0,0 +1,71 @@ +#ifndef ITKVTKCOLORTRANSFERFUNCTION_TXX +#define ITKVTKCOLORTRANSFERFUNCTION_TXX + +namespace itk{ + + +template< class TypeImage> +VTKColorTransferFunction::VTKColorTransferFunction() +{ + +} + +template< class TypeImage> +VTKColorTransferFunction::~VTKColorTransferFunction() +{ + m_Output->Delete(); +} + +template< class TypeImage> +void VTKColorTransferFunction::Update(){ + GenerateOutputInformation(); + GenerateData(); +} + +template< class TypeImage> +void VTKColorTransferFunction::GenerateOutputInformation(){ + m_Output = vtkColorTransferFunction::New(); +} + + + +template< class TypeImage> +void VTKColorTransferFunction::GenerateData(){ + + + + InputImagePointerType imagergb = this->GetInput(); + + if(!imagergb){ + itkExceptionMacro(<<"Set the image first!"); + } + + + typedef itk::ImageRegionConstIterator< InputImageType > rgbiteratorType; + rgbiteratorType rgbit(imagergb, imagergb->GetLargestPossibleRegion()); + + + rgbit.GoToBegin(); + + + m_Output->RemoveAllPoints (); + + + while(!rgbit.IsAtEnd()){ + + + typename InputImageType::PixelType::ComponentType lum = 0.299*rgbit.Get()[0] + 0.587*rgbit.Get()[1] + 0.114*rgbit.Get()[2]; + + m_Output->AddRGBPoint(lum, rgbit.Get()[0]/255.0, rgbit.Get()[1]/255.0, rgbit.Get()[2]/255.0); + + ++rgbit; + + } + + + + +} + +} +#endif