From 917b7a8f776c11ee0fe8b1de601e3ca60fbc77fd Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Fri, 10 Jul 2015 08:52:12 -0500 Subject: [PATCH] New pixel converter --- .../Extensions/Algorithms/RGBToRGBFunction.h | 55 +++++++++++++++++++ .../DataStructures/ITKAndVTKImage.h | 12 ++++ 2 files changed, 67 insertions(+) create mode 100644 lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h diff --git a/lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h b/lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h new file mode 100644 index 0000000..177eee5 --- /dev/null +++ b/lib/cpPlugins/Extensions/Algorithms/RGBToRGBFunction.h @@ -0,0 +1,55 @@ +// ------------------------------------------------------------------------- +// @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) +// ------------------------------------------------------------------------- + +#ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ +#define __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ + +#include +#include +#include + +namespace cpPlugins +{ + namespace Extensions + { + namespace Algorithms + { + /** + */ + template< class O > + struct RGBToRGBFunction + { + typedef RGBToRGBFunction Self; + typedef itk::Vector< O, 3 > TOutPixel; + + template< class Tr, class Tg, class Tb > + TOutPixel operator()( const Tr& r, const Tg& g, const Tb& b ) const + { + TOutPixel rgb; + rgb[ 0 ] = O( r ); + rgb[ 1 ] = O( g ); + rgb[ 2 ] = O( b ); + return( rgb ); + } + + template< class C > + TOutPixel operator()( const itk::RGBPixel< C >& rgb ) const + { + return( + this->operator()( + rgb.GetRed( ), rgb.GetGreen( ), rgb.GetBlue( ) + ) + ); + } + }; + + } // ecapseman + + } // ecapseman + +} // ecapseman + +#endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__RGBTORGBFUNCTION__H__ + +// eof - $RCSfile$ diff --git a/lib/cpPlugins/Extensions/DataStructures/ITKAndVTKImage.h b/lib/cpPlugins/Extensions/DataStructures/ITKAndVTKImage.h index faab21b..8a29536 100644 --- a/lib/cpPlugins/Extensions/DataStructures/ITKAndVTKImage.h +++ b/lib/cpPlugins/Extensions/DataStructures/ITKAndVTKImage.h @@ -23,6 +23,18 @@ namespace cpPlugins typename TImage::Pointer ITK; typename TItk2Vtk::Pointer VTK; + void CopyInformation( const itk::ImageBase< D >* i ) + { + this->ITK = TImage::New( ); + this->ITK->SetLargestPossibleRegion( i->GetLargestPossibleRegion( ) ); + this->ITK->SetRequestedRegion( i->GetRequestedRegion( ) ); + this->ITK->SetBufferedRegion( i->GetBufferedRegion( ) ); + this->ITK->SetSpacing( i->GetSpacing( ) ); + this->ITK->SetOrigin( i->GetOrigin( ) ); + this->ITK->SetDirection( i->GetDirection( ) ); + this->ITK->Allocate( ); + } + void SetItkImage( TImage* image ) { this->ITK = image; -- 2.47.1