TuttleOFX  1
SobelPlugin.hpp
Go to the documentation of this file.
00001 #ifndef _TUTTLE_PLUGIN_SOBEL_PLUGIN_HPP_
00002 #define _TUTTLE_PLUGIN_SOBEL_PLUGIN_HPP_
00003 
00004 #include "SobelDefinitions.hpp"
00005 
00006 #include <tuttle/plugin/ImageEffectGilPlugin.hpp>
00007 
00008 #include <terry/filter/convolve.hpp>
00009 
00010 #include <boost/gil/gil_all.hpp>
00011 
00012 namespace tuttle {
00013 namespace plugin {
00014 namespace sobel {
00015 
00016 template<typename Scalar>
00017 struct SobelProcessParams
00018 {
00019         boost::gil::point2<double> _size;
00020 
00021         EParamPass _pass;
00022         bool _unidimensional;
00023 
00024         bool _computeGradientNorm;
00025         bool _gradientNormManhattan;
00026         bool _computeGradientDirection;
00027         bool _gradientDirectionAbs;
00028 
00029         EParamBorder _border;
00030         terry::filter::convolve_boundary_option _boundary_option;
00031 
00032         terry::filter::kernel_1d<Scalar> _xKernelGaussianDerivative;
00033         terry::filter::kernel_1d<Scalar> _xKernelGaussian;
00034         terry::filter::kernel_1d<Scalar> _yKernelGaussianDerivative;
00035         terry::filter::kernel_1d<Scalar> _yKernelGaussian;
00036 };
00037 
00038 /**
00039  * @brief Sobel plugin
00040  */
00041 class SobelPlugin : public ImageEffectGilPlugin
00042 {
00043 public:
00044         typedef float Scalar;
00045 public:
00046     SobelPlugin( OfxImageEffectHandle handle );
00047 
00048 public:
00049         SobelProcessParams<Scalar> getProcessParams( const OfxPointD& renderScale = OFX::kNoRenderScale ) const;
00050 
00051     void changedParam( const OFX::InstanceChangedArgs &args, const std::string &paramName );
00052 
00053         void getClipPreferences( OFX::ClipPreferencesSetter& clipPreferences );
00054         bool getRegionOfDefinition( const OFX::RegionOfDefinitionArguments& args, OfxRectD& rod );
00055         void getRegionsOfInterest( const OFX::RegionsOfInterestArguments& args, OFX::RegionOfInterestSetter& rois );
00056         bool isIdentity( const OFX::RenderArguments& args, OFX::Clip*& identityClip, double& identityTime );
00057 
00058     void render( const OFX::RenderArguments &args );
00059         
00060 public:
00061         OFX::Double2DParam* _paramSize;
00062         OFX::BooleanParam* _paramNormalizedKernel;
00063         OFX::BooleanParam* _paramReverseKernel;
00064         OFX::ChoiceParam* _paramPass;
00065         OFX::DoubleParam* _paramKernelEpsilon;
00066         OFX::BooleanParam* _paramUnidimensional;
00067     OFX::ChoiceParam* _paramBorder;
00068         OFX::BooleanParam* _paramComputeGradientNorm;
00069         OFX::BooleanParam* _paramGradientNormManhattan;
00070         OFX::BooleanParam* _paramComputeGradientDirection;
00071         OFX::BooleanParam* _paramGradientDirectionAbs;
00072     OFX::ChoiceParam* _paramOutputComponent;
00073 };
00074 
00075 }
00076 }
00077 }
00078 
00079 #endif