TuttleOFX
1
|
00001 #include "BlurPluginFactory.hpp" 00002 #include "BlurPlugin.hpp" 00003 #include "BlurDefinitions.hpp" 00004 00005 #include <tuttle/plugin/ImageGilProcessor.hpp> 00006 00007 #include <limits> 00008 00009 namespace tuttle { 00010 namespace plugin { 00011 namespace blur { 00012 00013 static const bool kSupportTiles = true; 00014 00015 /** 00016 * @brief Function called to describe the plugin main features. 00017 * @param[in, out] desc Effect descriptor 00018 */ 00019 void BlurPluginFactory::describe( OFX::ImageEffectDescriptor& desc ) 00020 { 00021 desc.setLabels( "TuttleBlur", "Blur", 00022 "Blur" ); 00023 desc.setPluginGrouping( "tuttle/image/process/filter" ); 00024 00025 desc.setDescription( 00026 "A Gaussian blur is the result of blurring an image by a Gaussian function." 00027 "\n" 00028 "\n" 00029 "It is a widely used effect in graphics software, typically to reduce image " 00030 "noise and reduce detail. The visual effect of this blurring technique is a " 00031 "smooth blur resembling that of viewing the image through a translucent " 00032 "screen, distinctly different from the bokeh effect produced by an " 00033 "out-of-focus lens or the shadow of an object under usual illumination. " 00034 "Gaussian smoothing is also used as a pre-processing stage in computer vision " 00035 "algorithms in order to enhance image structures at different scales—see " 00036 "scale-space representation and scale-space implementation." 00037 "\n" 00038 "Mathematically, applying a Gaussian blur to an image is the same as " 00039 "convolving the image with a Gaussian function; this is also known as a " 00040 "two-dimensional Weierstrass transform. Applying a Gaussian blur has the " 00041 "effect of reducing the image's high-frequency components; " 00042 "a Gaussian blur is thus a low pass filter." 00043 "\n" 00044 "\n" 00045 "http://en.wikipedia.org/wiki/Gaussian_blur" 00046 ); 00047 00048 // add the supported contexts, only filter at the moment 00049 desc.addSupportedContext( OFX::eContextFilter ); 00050 desc.addSupportedContext( OFX::eContextGeneral ); 00051 00052 // add supported pixel depths 00053 // desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00054 // desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00055 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00056 00057 // plugin flags 00058 desc.setSupportsTiles( kSupportTiles ); 00059 desc.setRenderThreadSafety( OFX::eRenderFullySafe ); 00060 } 00061 00062 /** 00063 * @brief Function called to describe the plugin controls and features. 00064 * @param[in, out] desc Effect descriptor 00065 * @param[in] context Application context 00066 */ 00067 void BlurPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc, 00068 OFX::EContext context ) 00069 { 00070 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00071 00072 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00073 srcClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00074 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00075 srcClip->setSupportsTiles( kSupportTiles ); 00076 00077 // Create the mandated output clip 00078 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00079 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00080 dstClip->addSupportedComponent( OFX::ePixelComponentRGB ); 00081 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00082 dstClip->setSupportsTiles( kSupportTiles ); 00083 00084 OFX::Double2DParamDescriptor* size = desc.defineDouble2DParam( kParamSize ); 00085 size->setLabel( "Size" ); 00086 size->setDefault( 3, 3 ); 00087 size->setRange( 0.0, 0.0, std::numeric_limits<double>::max(), std::numeric_limits<double>::max() ); 00088 size->setDisplayRange( 0, 0, 10, 10 ); 00089 size->setDoubleType( OFX::eDoubleTypeScale ); 00090 00091 OFX::ChoiceParamDescriptor* border = desc.defineChoiceParam( kParamBorder ); 00092 border->setLabel( "Border" ); 00093 border->appendOption( kParamBorderNo ); 00094 border->appendOption( kParamBorderMirror ); 00095 border->appendOption( kParamBorderConstant ); 00096 border->appendOption( kParamBorderBlack ); 00097 border->appendOption( kParamBorderPadded ); 00098 border->setDefault( eParamBorderMirror ); 00099 00100 OFX::GroupParamDescriptor* advanced = desc.defineGroupParam( kParamGroupAdvanced ); 00101 advanced->setLabel( "Advanced" ); 00102 advanced->setOpen( false ); 00103 00104 OFX::BooleanParamDescriptor* normalizedKernel = desc.defineBooleanParam( kParamNormalizedKernel ); 00105 normalizedKernel->setLabel( "Normalized kernel" ); 00106 normalizedKernel->setHint( "Use a normalized kernel to compute the gradient." ); 00107 normalizedKernel->setDefault( true ); 00108 normalizedKernel->setParent( advanced ); 00109 00110 OFX::DoubleParamDescriptor* kernelEpsilon = desc.defineDoubleParam( kParamKernelEpsilon ); 00111 kernelEpsilon->setLabel( "Kernel espilon value" ); 00112 kernelEpsilon->setHint( "Threshold at which we no longer consider the values of the function." ); 00113 kernelEpsilon->setDefault( 0.01 ); 00114 kernelEpsilon->setRange( std::numeric_limits<double>::epsilon(), 1.0 ); 00115 kernelEpsilon->setDisplayRange( 0, 0.01 ); 00116 kernelEpsilon->setParent( advanced ); 00117 } 00118 00119 /** 00120 * @brief Function called to create a plugin effect instance 00121 * @param[in] handle Effect handle 00122 * @param[in] context Application context 00123 * @return plugin instance 00124 */ 00125 OFX::ImageEffect* BlurPluginFactory::createInstance( OfxImageEffectHandle handle, 00126 OFX::EContext context ) 00127 { 00128 return new BlurPlugin( handle ); 00129 } 00130 00131 } 00132 } 00133 } 00134