TuttleOFX  1
ImageStatisticsPluginFactory.cpp
Go to the documentation of this file.
00001 #include "ImageStatisticsPluginFactory.hpp"
00002 #include "ImageStatisticsPlugin.hpp"
00003 #include "ImageStatisticsDefinitions.hpp"
00004 #include "ImageStatisticsOverlayInteract.hpp"
00005 
00006 #include <tuttle/plugin/ImageGilProcessor.hpp>
00007 
00008 namespace tuttle {
00009 namespace plugin {
00010 namespace imageStatistics {
00011 
00012 /**
00013  * @brief Function called to describe the plugin main features.
00014  * @param[in, out]   desc     Effect descriptor
00015  */
00016 void ImageStatisticsPluginFactory::describe( OFX::ImageEffectDescriptor& desc )
00017 {
00018         desc.setLabels( "TuttleImageStatistics", "ImageStatistics",
00019                         "Image statistics" );
00020         desc.setPluginGrouping( "tuttle/param/analysis" );
00021 
00022         // add the supported contexts
00023         desc.addSupportedContext( OFX::eContextGeneral );
00024         desc.addSupportedContext( OFX::eContextFilter );
00025 
00026         // add supported pixel depths
00027         desc.addSupportedBitDepth( OFX::eBitDepthUByte );
00028         desc.addSupportedBitDepth( OFX::eBitDepthUShort );
00029         desc.addSupportedBitDepth( OFX::eBitDepthFloat );
00030 
00031         // plugin flags
00032         desc.setSupportsMultiResolution( false );
00033         desc.setSupportsTiles( kSupportTiles );
00034 
00035         desc.setOverlayInteractDescriptor( new OFX::DefaultEffectOverlayWrap<ImageStatisticsEffectOverlayDescriptor>() );
00036 }
00037 
00038 /**
00039  * @brief Function called to describe the plugin controls and features.
00040  * @param[in, out]   desc       Effect descriptor
00041  * @param[in]        context    Application context
00042  */
00043 void ImageStatisticsPluginFactory::describeInContext( OFX::ImageEffectDescriptor& desc,
00044                                                       OFX::EContext               context )
00045 {
00046         OFX::ClipDescriptor* srcClip = desc.defineClip( kOfxImageEffectSimpleSourceClipName );
00047 
00048         srcClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00049         srcClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00050         srcClip->setSupportsTiles( kSupportTiles );
00051 
00052         // Create the mandated output clip
00053         OFX::ClipDescriptor* dstClip = desc.defineClip( kOfxImageEffectOutputClipName );
00054         dstClip->addSupportedComponent( OFX::ePixelComponentRGBA );
00055         dstClip->addSupportedComponent( OFX::ePixelComponentAlpha );
00056         dstClip->setSupportsTiles( kSupportTiles );
00057 
00058         OFX::ChoiceParamDescriptor* coordSystem = desc.defineChoiceParam( kParamCoordinateSystem );
00059         coordSystem->setLabel( "Coordinate system" );
00060         coordSystem->appendOption( kParamCoordinateSystemNormalized );
00061         coordSystem->appendOption( kParamCoordinateSystemCanonical );
00062         coordSystem->setDefault( 0 );
00063 
00064         OFX::Double2DParamDescriptor* rectCenter = desc.defineDouble2DParam( kParamRectCenter );
00065         rectCenter->setLabel( "Center" );
00066         rectCenter->setDoubleType( OFX::eDoubleTypePlain );
00067         //      rectCenter->setDoubleType( OFX::eDoubleTypeNormalisedXYAbsolute );
00068         rectCenter->setDefault( 0.5, 0.5 );
00069 
00070         OFX::Double2DParamDescriptor* rectSize = desc.defineDouble2DParam( kParamRectSize );
00071         rectSize->setLabel( "Size" );
00072         rectSize->setDoubleType( OFX::eDoubleTypePlain );
00073         //      rectSize->setDoubleType( OFX::eDoubleTypeNormalisedXYAbsolute );
00074         rectSize->setDefault( 0.5, 0.5 );
00075 
00076         OFX::ChoiceParamDescriptor* chooseOutput = desc.defineChoiceParam( kParamChooseOutput );
00077         chooseOutput->setLabel( "Choose output" );
00078         chooseOutput->appendOption( kParamChooseOutputSource );
00079         chooseOutput->appendOption( kParamChooseOutputAverage );
00080         chooseOutput->appendOption( kParamChooseOutputVariance );
00081         chooseOutput->appendOption( kParamChooseOutputChannelMin );
00082         chooseOutput->appendOption( kParamChooseOutputChannelMax );
00083         chooseOutput->appendOption( kParamChooseOutputLuminosityMin );
00084         chooseOutput->appendOption( kParamChooseOutputLuminosityMax );
00085         chooseOutput->setDefault( 0 );
00086 
00087         OFX::GroupParamDescriptor* outputGroup = desc.defineGroupParam( kParamOutputGroup );
00088         outputGroup->setLabel( "Output" );
00089         outputGroup->setAsTab();
00090         
00091         // -----------------------------------------------------------------------------
00092 
00093         OFX::GroupParamDescriptor* rgbaGroup = desc.defineGroupParam( kParamOutputGroupRGBA );
00094         rgbaGroup->setLabel( "RGBA" );
00095         rgbaGroup->setParent( outputGroup );
00096         rgbaGroup->setAsTab();
00097 
00098         OFX::RGBAParamDescriptor* outputAverage = desc.defineRGBAParam( kParamOutputAverage );
00099         outputAverage->setLabel( "Average" );
00100         outputAverage->setParent( rgbaGroup );
00101         outputAverage->setEvaluateOnChange( false );
00102         
00103         OFX::RGBAParamDescriptor* outputVariance = desc.defineRGBAParam( kParamOutputVariance );
00104         outputVariance->setLabel( "Variance" );
00105         outputVariance->setParent( rgbaGroup );
00106         outputVariance->setEvaluateOnChange( false );
00107         
00108         OFX::RGBAParamDescriptor* outputChannelMin = desc.defineRGBAParam( kParamOutputChannelMin );
00109         outputChannelMin->setLabel( "Channels' min" );
00110         outputChannelMin->setHint( "Minimum value per channel" );
00111         outputChannelMin->setParent( rgbaGroup );
00112         outputChannelMin->setEvaluateOnChange( false );
00113 
00114         OFX::RGBAParamDescriptor* outputChannelMax = desc.defineRGBAParam( kParamOutputChannelMax );
00115         outputChannelMax->setLabel( "Channels' max" );
00116         outputChannelMax->setParent( rgbaGroup );
00117         outputChannelMax->setEvaluateOnChange( false );
00118 
00119         OFX::RGBAParamDescriptor* outputLuminosityMin = desc.defineRGBAParam( kParamOutputLuminosityMin );
00120         outputLuminosityMin->setLabel( "Luminosity min" );
00121         outputLuminosityMin->setParent( rgbaGroup );
00122         outputLuminosityMin->setEvaluateOnChange( false );
00123 
00124         OFX::RGBAParamDescriptor* outputLuminosityMax = desc.defineRGBAParam( kParamOutputLuminosityMax );
00125         outputLuminosityMax->setLabel( "Luminosity max" );
00126         outputLuminosityMax->setParent( rgbaGroup );
00127         outputLuminosityMax->setEvaluateOnChange( false );
00128 
00129         OFX::RGBAParamDescriptor* outputKurtosis = desc.defineRGBAParam( kParamOutputKurtosis );
00130         outputKurtosis->setLabel( "Kurtosis" );
00131         outputKurtosis->setParent( rgbaGroup );
00132         outputKurtosis->setEvaluateOnChange( false );
00133 
00134         OFX::RGBAParamDescriptor* outputSkewness = desc.defineRGBAParam( kParamOutputSkewness );
00135         outputSkewness->setLabel( "Skewness" );
00136         outputSkewness->setParent( rgbaGroup );
00137         outputSkewness->setEvaluateOnChange( false );
00138 
00139         // -----------------------------------------------------------------------------
00140 
00141         OFX::GroupParamDescriptor* hslGroup = desc.defineGroupParam( kParamOutputGroupHSL );
00142         hslGroup->setLabel( "HSL" );
00143         hslGroup->setParent( outputGroup );
00144         hslGroup->setAsTab();
00145 
00146         OFX::Double3DParamDescriptor* outputAverageHSL = desc.defineDouble3DParam( kParamOutputAverageHSL );
00147         outputAverageHSL->setLabel( "Average" );
00148         outputAverageHSL->setDoubleType( OFX::eDoubleTypePlain );
00149         outputAverageHSL->setDimensionLabels( "h", "s", "l" );
00150         outputAverageHSL->setParent( hslGroup );
00151         outputAverageHSL->setEvaluateOnChange( false );
00152 
00153         OFX::Double3DParamDescriptor* outputChannelMinHSL = desc.defineDouble3DParam( kParamOutputChannelMinHSL );
00154         outputChannelMinHSL->setLabel( "Channels' min" );
00155         outputChannelMinHSL->setHint( "Minimum value per channel" );
00156         outputChannelMinHSL->setDoubleType( OFX::eDoubleTypePlain );
00157         outputChannelMinHSL->setDimensionLabels( "h", "s", "l" );
00158         outputChannelMinHSL->setParent( hslGroup );
00159         outputChannelMinHSL->setEvaluateOnChange( false );
00160 
00161         OFX::Double3DParamDescriptor* outputChannelMaxHSL = desc.defineDouble3DParam( kParamOutputChannelMaxHSL );
00162         outputChannelMaxHSL->setLabel( "Channels' max" );
00163         outputChannelMaxHSL->setDoubleType( OFX::eDoubleTypePlain );
00164         outputChannelMaxHSL->setDimensionLabels( "h", "s", "l" );
00165         outputChannelMaxHSL->setParent( hslGroup );
00166         outputChannelMaxHSL->setEvaluateOnChange( false );
00167 
00168         OFX::Double3DParamDescriptor* outputLuminosityMinHSL = desc.defineDouble3DParam( kParamOutputLuminosityMinHSL );
00169         outputLuminosityMinHSL->setLabel( "Luminosity min" );
00170         outputLuminosityMinHSL->setDoubleType( OFX::eDoubleTypePlain );
00171         outputLuminosityMinHSL->setDimensionLabels( "h", "s", "l" );
00172         outputLuminosityMinHSL->setParent( hslGroup );
00173         outputLuminosityMinHSL->setEvaluateOnChange( false );
00174 
00175         OFX::Double3DParamDescriptor* outputLuminosityMaxHSL = desc.defineDouble3DParam( kParamOutputLuminosityMaxHSL );
00176         outputLuminosityMaxHSL->setLabel( "Luminosity max" );
00177         outputLuminosityMaxHSL->setDoubleType( OFX::eDoubleTypePlain );
00178         outputLuminosityMaxHSL->setDimensionLabels( "h", "s", "l" );
00179         outputLuminosityMaxHSL->setParent( hslGroup );
00180         outputLuminosityMaxHSL->setEvaluateOnChange( false );
00181 
00182         OFX::Double3DParamDescriptor* outputKurtosisHSL = desc.defineDouble3DParam( kParamOutputKurtosisHSL );
00183         outputKurtosisHSL->setLabel( "Kurtosis" );
00184         outputKurtosisHSL->setDoubleType( OFX::eDoubleTypePlain );
00185         outputKurtosisHSL->setDimensionLabels( "h", "s", "l" );
00186         outputKurtosisHSL->setParent( hslGroup );
00187         outputKurtosisHSL->setEvaluateOnChange( false );
00188 
00189         OFX::Double3DParamDescriptor* outputSkewnessHSL = desc.defineDouble3DParam( kParamOutputSkewnessHSL );
00190         outputSkewnessHSL->setLabel( "Skewness" );
00191         outputSkewnessHSL->setDoubleType( OFX::eDoubleTypePlain );
00192         outputSkewnessHSL->setDimensionLabels( "h", "s", "l" );
00193         outputSkewnessHSL->setParent( hslGroup );
00194         outputSkewnessHSL->setEvaluateOnChange( false );
00195 }
00196 
00197 /**
00198  * @brief Function called to create a plugin effect instance
00199  * @param[in] handle  effect handle
00200  * @param[in] context    Application context
00201  * @return  plugin instance
00202  */
00203 OFX::ImageEffect* ImageStatisticsPluginFactory::createInstance( OfxImageEffectHandle handle,
00204                                                                 OFX::EContext        context )
00205 {
00206         return new ImageStatisticsPlugin( handle );
00207 }
00208 
00209 }
00210 }
00211 }