TuttleOFX  1
GammaProcess.tcc
Go to the documentation of this file.
00001 #include <terry/globals.hpp>
00002 #include <tuttle/plugin/exceptions.hpp>
00003 
00004 #include "GammaPlugin.hpp"
00005 
00006 namespace tuttle {
00007 namespace plugin {
00008 namespace gamma {
00009 
00010 template<class View>
00011 GammaProcess<View>::GammaProcess( GammaPlugin& effect )
00012         : ImageGilFilterProcessor<View>( effect, eImageOrientationIndependant )
00013         , _plugin( effect )
00014 {}
00015 
00016 /**
00017  * @brief Function called by rendering thread each time a process must be done.
00018  * @param[in] procWindowRoW  Processing window
00019  */
00020 template<class View>
00021 void GammaProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW )
00022 {
00023         using namespace boost::gil;
00024         GammaProcessParams<GammaPlugin::Scalar> params = _plugin.getProcessParams();
00025         OfxRectI procWindowOutput                      = this->translateRoWToOutputClipCoordinates( procWindowRoW );
00026         const OfxPointI procWindowSize = {
00027                 procWindowRoW.x2 - procWindowRoW.x1,
00028                 procWindowRoW.y2 - procWindowRoW.y1 };
00029         
00030         rgba32f_pixel_t wpix;
00031 
00032         for( int y = procWindowOutput.y1;
00033              y < procWindowOutput.y2;
00034              ++y )
00035         {
00036                 typename View::x_iterator src_it = this->_srcView.x_at( procWindowOutput.x1, y );
00037                 typename View::x_iterator dst_it = this->_dstView.x_at( procWindowOutput.x1, y );
00038                 for( int x = procWindowOutput.x1;
00039                      x < procWindowOutput.x2;
00040                      ++x, ++src_it, ++dst_it )
00041                 {
00042                         //x^a = e^aln(x)
00043                         color_convert( *src_it, wpix );
00044                         if( wpix[ 0 ] > 0.0 )
00045                         {
00046                                 wpix[ 0 ] = exp( log( wpix[ 0 ] ) * params.iRGamma );
00047                         }
00048 
00049                         if( wpix[ 1 ] > 0.0 )
00050                         {
00051                                 wpix[ 1 ] = exp( log( wpix[ 1 ] ) * params.iGGamma );
00052                         }
00053 
00054                         if( wpix[ 2 ] > 0.0 )
00055                         {
00056                                 wpix[ 2 ] = exp( log( wpix[ 2 ] ) * params.iBGamma );
00057                         }
00058 
00059                         if( wpix[ 3 ] > 0.0 )
00060                         {
00061                                 wpix[ 3 ] = exp( log( wpix[ 3 ] ) * params.iAGamma );
00062                         }
00063                         color_convert( wpix, *dst_it );
00064                 }
00065                 if( this->progressForward( procWindowSize.x ) )
00066                         return;
00067         }
00068         /*
00069            const OfxRectI procWindowSrc = this->translateRegion( procWindowRoW, this->_srcPixelRod );
00070            OfxPointI procWindowSize = { procWindowRoW.x2 - procWindowRoW.x1,
00071                                      procWindowRoW.y2 - procWindowRoW.y1 };
00072            View src = subimage_view( this->_srcView, procWindowSrc.x1, procWindowSrc.y1,
00073                                   procWindowSize.x,
00074                                   procWindowSize.y );
00075            View dst = subimage_view( this->_dstView, procWindowOutput.x1, procWindowOutput.y1,
00076                                   procWindowSize.x,
00077                                   procWindowSize.y );
00078            copy_pixels( src, dst );
00079          */
00080 
00081 }
00082 
00083 }
00084 }
00085 }