TuttleOFX  1
AnisotropicDiffusionPlugin.cpp
Go to the documentation of this file.
00001 #include "AnisotropicDiffusionDefinition.hpp"
00002 #include "AnisotropicDiffusionPlugin.hpp"
00003 #include "AnisotropicDiffusionPluginFactory.hpp"
00004 #include "AnisotropicDiffusionProcess.hpp"
00005 
00006 #include <ofxsImageEffect.h>
00007 #include <ofxsMultiThread.h>
00008 
00009 #include <boost/gil/gil_all.hpp>
00010 
00011 namespace tuttle {
00012 namespace plugin {
00013 namespace anisotropicFilter {
00014 namespace diffusion {
00015 
00016 AnisotropicDiffusionPlugin::AnisotropicDiffusionPlugin( OfxImageEffectHandle handle )
00017 : ImageEffectGilPlugin( handle )
00018 {
00019     _clipSrcTensors = fetchClip( kClipInputTensors );
00020 
00021     _paramAmplitude = fetchRGBParam( kParamAmplitude );
00022 }
00023 
00024 int AnisotropicDiffusionPlugin::getMargin()
00025 {
00026         OfxRGBColourD color = _paramAmplitude->getValue();
00027     return (int)std::ceil(
00028                 std::sqrt( 2.0f ) * std::ceil(
00029                         std::max(
00030                                 std::max(
00031                                         std::sqrt( 2.0f * color.r ),
00032                                         std::sqrt( 2.0f * color.g ) ),
00033                                 std::sqrt( 2.0f * color.b )
00034                                 )
00035                         )
00036                 );
00037 }
00038 
00039 void AnisotropicDiffusionPlugin::getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois )
00040 {
00041         const double margin = (double)getMargin() * _clipSrc->getPixelAspectRatio();
00042 
00043         _overSizedRect.x1 = double(args.regionOfInterest.x1 - margin);
00044         _overSizedRect.y1 = double(args.regionOfInterest.y1 - margin);
00045         _overSizedRect.x2 = double(args.regionOfInterest.x2 + margin + 1);
00046         _overSizedRect.y2 = double(args.regionOfInterest.y2 + margin + 1);
00047 
00048         rois.setRegionOfInterest( *_clipSrc, _overSizedRect );
00049         rois.setRegionOfInterest( *_clipSrcTensors, _overSizedRect );
00050 }
00051 
00052 /**
00053  * @brief The overridden render function
00054  * @param[in]   args     Rendering parameters
00055  */
00056 void AnisotropicDiffusionPlugin::render( const OFX::RenderArguments &args )
00057 {
00058         doGilRender<AnisotropicDiffusionProcess>( *this, args );
00059 }
00060 
00061 }
00062 }
00063 }
00064 }