#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