TuttleOFX
1
|
00001 #include "AnisotropicDiffusionDefinition.hpp" 00002 #include "AnisotropicDiffusionPluginFactory.hpp" 00003 #include "AnisotropicDiffusionPlugin.hpp" 00004 00005 #include <tuttle/common/utils/global.hpp> 00006 #include <tuttle/plugin/ImageGilProcessor.hpp> 00007 00008 namespace tuttle { 00009 namespace plugin { 00010 namespace anisotropicFilter { 00011 namespace diffusion { 00012 00013 /** 00014 * @brief Function called to describe the plugin main features. 00015 * @param[in, out] desc Effect descriptor 00016 */ 00017 00018 void AnisotropicDiffusionPluginFactory::describe( OFX::ImageEffectDescriptor &desc ) 00019 { 00020 // basic labels 00021 desc.setLabels( 00022 "TuttleAnisotropicDiffusion", 00023 "AnisotropicDiffusion", 00024 "Anisotropic diffusion" ); 00025 desc.setPluginGrouping( "tuttle/image/process/filter" ); 00026 00027 desc.setDescription( 00028 "Anisotropic diffusion is the ability to blur along edges directions, thus it remove noise while preserving important details in the image.\n" 00029 "It's based on PDE (Partial Derivated Equations) and creates liquify effects.\n" 00030 "\n" 00031 "Inputs:\n" 00032 "- Source: Source image to denoise.\n" 00033 "- Input tensors: Needed to get edges directions and strengths.\n" 00034 "\n" 00035 "Parameters:\n" 00036 "- {Red, Green, Blue} amplitude: amplitude by channel." 00037 ); 00038 00039 // add the supported contexts, only filter at the moment 00040 desc.addSupportedContext( OFX::eContextFilter ); 00041 00042 // add supported pixel depths 00043 desc.addSupportedBitDepth( OFX::eBitDepthUByte ); 00044 desc.addSupportedBitDepth( OFX::eBitDepthUShort ); 00045 desc.addSupportedBitDepth( OFX::eBitDepthFloat ); 00046 00047 // set a few flags 00048 desc.setSingleInstance( false ); 00049 desc.setHostFrameThreading( false ); 00050 desc.setSupportsMultiResolution( true ); 00051 desc.setSupportsTiles( kSupportTiles ); 00052 desc.setTemporalClipAccess( false ); 00053 desc.setRenderTwiceAlways( false ); 00054 desc.setSupportsMultipleClipPARs( false ); 00055 } 00056 00057 /** 00058 * @brief Function called to describe the plugin controls and features. 00059 * @param[in, out] desc Effect descriptor 00060 * @param[in] context Application context 00061 */ 00062 void AnisotropicDiffusionPluginFactory::describeInContext( 00063 OFX::ImageEffectDescriptor &desc, 00064 OFX::EContext context ) 00065 { 00066 // Source clip only in the filter context 00067 // create the mandated source clip 00068 OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName ); 00069 srcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00070 srcClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00071 srcClip->setTemporalClipAccess( false ); 00072 srcClip->setSupportsTiles( kSupportTiles ); 00073 srcClip->setIsMask( false ); 00074 00075 // Create the tensors map input clip 00076 OFX::ClipDescriptor* tensorsDstClip = desc.defineClip( kClipInputTensors ); 00077 tensorsDstClip->setLabels( "Input tensors", "Input tensors", "User tensor image input." ); 00078 tensorsDstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00079 tensorsDstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00080 tensorsDstClip->setSupportsTiles( kSupportTiles ); 00081 tensorsDstClip->setOptional( false ); 00082 tensorsDstClip->setIsMask( false ); 00083 00084 // Create the mandated output clip 00085 OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName ); 00086 dstClip->addSupportedComponent( OFX::ePixelComponentRGBA ); 00087 dstClip->addSupportedComponent( OFX::ePixelComponentAlpha ); 00088 dstClip->setSupportsTiles( kSupportTiles ); 00089 00090 // Controls 00091 // Define PDE Based algorithm controls. 00092 OFX::GroupParamDescriptor* groupParamsPDE = desc.defineGroupParam( kParamGroupPDEAlgorithm ); 00093 groupParamsPDE->setLabel( "PDE Based Algorithm Parameters" ); 00094 00095 OFX::BooleanParamDescriptor* fast_approx = desc.defineBooleanParam( kParamFastApproximation ); 00096 fast_approx->setLabel( "Fast Approximation" ); 00097 fast_approx->setParent( *groupParamsPDE ); 00098 fast_approx->setDefault( true ); 00099 fast_approx->setIsSecret( true ); 00100 00101 OFX::RGBParamDescriptor* amplitude = desc.defineRGBParam( kParamAmplitude ); 00102 amplitude->setLabel( "Amplitude" ); 00103 amplitude->setParent( *groupParamsPDE ); 00104 amplitude->setDefault( kDefaultAmplitudeValue, kDefaultAmplitudeValue, kDefaultAmplitudeValue ); 00105 // amplitude->setRange( 0.0, 1000.0 ); 00106 // amplitude->setDisplayRange( 0.0, 10.0 ); 00107 amplitude->setHint( "Amplitude of the anisotropic blur" ); 00108 } 00109 00110 /** 00111 * @brief Function called to create a plugin effect instance 00112 * @param[in] handle effect handle 00113 * @param[in] context Application context 00114 * @return plugin instance 00115 */ 00116 OFX::ImageEffect* AnisotropicDiffusionPluginFactory::createInstance( 00117 OfxImageEffectHandle handle, 00118 OFX::EContext context ) 00119 { 00120 return new AnisotropicDiffusionPlugin( handle ); 00121 } 00122 00123 } 00124 } 00125 } 00126 }