TuttleOFX
1
|
00001 #include <tuttle/plugin/exceptions.hpp> 00002 #include <tuttle/plugin/numeric/rectOp.hpp> 00003 #include <tuttle/plugin/ofxToGil/rect.hpp> 00004 #include <tuttle/plugin/memory/OfxAllocator.hpp> 00005 00006 #include <terry/globals.hpp> 00007 #include <terry/algorithm/transform_pixels_progress.hpp> 00008 #include <terry/filter/thinning.hpp> 00009 00010 #include <boost/mpl/if.hpp> 00011 00012 namespace tuttle { 00013 namespace plugin { 00014 namespace thinning { 00015 00016 template<class View> 00017 ThinningProcess<View>::ThinningProcess( ThinningPlugin &effect ) 00018 : ImageGilFilterProcessor<View>( effect, eImageOrientationIndependant ) 00019 , _plugin( effect ) 00020 { 00021 } 00022 00023 template<class View> 00024 void ThinningProcess<View>::setup( const OFX::RenderArguments& args ) 00025 { 00026 ImageGilFilterProcessor<View>::setup( args ); 00027 _params = _plugin.getProcessParams( args.renderScale ); 00028 } 00029 00030 /** 00031 * @brief Function called by rendering thread each time a process must be done. 00032 * @param[in] procWindowRoW Processing window 00033 */ 00034 template<class View> 00035 void ThinningProcess<View>::multiThreadProcessImages( const OfxRectI& procWindowRoW ) 00036 { 00037 using namespace boost; 00038 using namespace boost::gil; 00039 typedef typename View::point_t Point; 00040 typedef typename View::coord_t Coord; 00041 00042 // typedef typename mpl::if_c< num_channels<View>::value==1, 00043 // View, 00044 // typename kth_channel_view_type<0,View>::type >::type CView; 00045 typedef View CView; 00046 typedef typename terry::image_from_view<CView, OfxAllocator<unsigned char> >::type CImage; 00047 00048 static const std::size_t border = 1; 00049 const OfxRectI srcRodCrop1 = rectangleReduce( this->_srcPixelRod, border ); 00050 const OfxRectI srcRodCrop2 = rectangleReduce( srcRodCrop1, border ); 00051 const OfxRectI procWindowRoWCrop1 = rectanglesIntersection( rectangleGrow( procWindowRoW, border ), srcRodCrop1 ); 00052 const OfxRectI procWindowRoWCrop2 = rectanglesIntersection( procWindowRoW, srcRodCrop2 ); 00053 00054 // TUTTLE_LOG_WARNING("-----"); 00055 // TUTTLE_LOG_VAR( TUTTLE_INFO, this->_srcPixelRod ); 00056 // TUTTLE_LOG_VAR( TUTTLE_INFO, srcRodCrop1 ); 00057 // TUTTLE_LOG_INFO(""); 00058 // TUTTLE_LOG_VAR( TUTTLE_INFO, procWindowRoW ); 00059 // TUTTLE_LOG_VAR( TUTTLE_INFO, procWindowRoWCrop1 ); 00060 // TUTTLE_LOG_WARNING("-----"); 00061 00062 /// @todo use an allocator 00063 OfxPointI tmpSize; 00064 tmpSize.x = procWindowRoWCrop1.x2-procWindowRoWCrop1.x1; 00065 tmpSize.y = procWindowRoWCrop1.y2-procWindowRoWCrop1.y1; 00066 CImage image_tmp( tmpSize.x, tmpSize.y ); 00067 CView view_tmp = view( image_tmp ); 00068 00069 terry::algorithm::transform_pixels_locator_progress( 00070 this->_srcView, ofxToGil(this->_srcPixelRod), 00071 view_tmp, ofxToGil(procWindowRoWCrop1), 00072 ofxToGil(procWindowRoWCrop1), 00073 terry::filter::thinning::pixel_locator_thinning_t<View,CView>(this->_srcView, terry::filter::thinning::lutthin1), 00074 this->getOfxProgress() ); 00075 terry::algorithm::transform_pixels_locator_progress( 00076 view_tmp, ofxToGil(procWindowRoWCrop1), //srcRodCrop1, 00077 this->_dstView, ofxToGil(this->_dstPixelRod), 00078 ofxToGil(procWindowRoWCrop2), 00079 terry::filter::thinning::pixel_locator_thinning_t<CView,View>(view_tmp, terry::filter::thinning::lutthin2), 00080 this->getOfxProgress() ); 00081 } 00082 00083 } 00084 } 00085 }