From 6d38215f54bdde5e453297238c8a672e12f84b04 Mon Sep 17 00:00:00 2001 From: Leonardo Florez-Valencia Date: Mon, 27 Apr 2015 14:40:55 -0500 Subject: [PATCH] New filter added --- appli/examples/example_LightCompensation.cxx | 17 +++++++++++++++++ .../Algorithms/LightCompensationFilter.hxx | 14 +++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/appli/examples/example_LightCompensation.cxx b/appli/examples/example_LightCompensation.cxx index 44062ed..cb1a1d2 100644 --- a/appli/examples/example_LightCompensation.cxx +++ b/appli/examples/example_LightCompensation.cxx @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -51,6 +52,22 @@ int main( int argc, char* argv[] ) filter->SetInput( input_image ); filter->Update( ); + // Write image + itk::ImageFileWriter< TImage >::Pointer output_image_writer = + itk::ImageFileWriter< TImage >::New( ); + output_image_writer->SetInput( filter->GetOutput( ) ); + output_image_writer->SetFileName( output_image_fn ); + try + { + output_image_writer->Update( ); + } + catch( itk::ExceptionObject& err ) + { + std::cerr << "Error caught: " << err << std::endl; + return( 1 ); + + } // yrt + return( 0 ); } diff --git a/lib/cpPlugins/Extensions/Algorithms/LightCompensationFilter.hxx b/lib/cpPlugins/Extensions/Algorithms/LightCompensationFilter.hxx index 71dc0f6..fef98fd 100644 --- a/lib/cpPlugins/Extensions/Algorithms/LightCompensationFilter.hxx +++ b/lib/cpPlugins/Extensions/Algorithms/LightCompensationFilter.hxx @@ -31,6 +31,8 @@ template< class I > void cpPlugins::Extensions::Algorithms::LightCompensationFilter< I >:: BeforeThreadedGenerateData( ) { + this->Superclass::BeforeThreadedGenerateData( ); + I* input = const_cast< I* >( this->GetInput( ) ); typename TMeanCalculator::Pointer mc = TMeanCalculator::New( ); @@ -66,12 +68,17 @@ ThreadedGenerateData( const TRegion& region, itk::ThreadIdType id ) double r = double( iIt.Get( )[ 0 ] ) * this->m_Coefficient[ 0 ]; double g = double( iIt.Get( )[ 1 ] ) * this->m_Coefficient[ 1 ]; double b = double( iIt.Get( )[ 2 ] ) * this->m_Coefficient[ 2 ]; + if( r > max_value ) r = max_value; if( g > max_value ) g = max_value; if( b > max_value ) b = max_value; - oIt.Get( ).Set( - _TPixelChannel( r ), _TPixelChannel( g ), _TPixelChannel( b ) - ); + + typename I::PixelType pix; + pix.SetRed( _TPixelChannel( r ) ); + pix.SetGreen( _TPixelChannel( g ) ); + pix.SetBlue( _TPixelChannel( b ) ); + + oIt.Set( pix ); } // rof } @@ -81,6 +88,7 @@ template< class I > void cpPlugins::Extensions::Algorithms::LightCompensationFilter< I >:: AfterThreadedGenerateData( ) { + this->Superclass::AfterThreadedGenerateData( ); } #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__LIGHTCOMPENSATIONFILTER__HXX__ -- 2.45.1