FANDOM


< Code

Code of 'FiltersTest' Edit

-> the most inportant is the procedure Test()

unit test;

(* ***** BEGIN LICENSE BLOCK *****
 * Copyright (C) 2004-2007 Durand Emmanuel
 * Copyright (C) 2004-2007 Burgel Eric
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Contact :
 *   filters@edurand.com
 *   filters@burgel.com
 * Site :
 *   http://filters.sourceforge.net/
 *
 * ***** END LICENSE BLOCK ***** *)

{
 edurand (filters@edurand.com)
 eburgel (filters@burgel.com)
}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Types,
  Dialogs, StdCtrls, image, ExtCtrls, imageIO, imageIOVideo, ExtDlgs,
  ComCtrls,
  filter, AppEvnts, GLScene,
  GLWin32Viewer, Buttons, GLObjects, GLMisc, GLGraph,
  application1,
  application2,
  VectorTypes,
  VectorGeometry, GLTexture,
  wrapper_filtersdll, Grids
  ;

type

  TMainForm = class(TForm)
    TimerAutoProcess: TTimer;
    DlgOpenFilm: TOpenDialog;
    dlgSave: TSaveDialog;
    dlgOpen: TOpenPictureDialog;
    GLScene1: TGLScene;
    HeightField1: TGLHeightField;
    GLLightSource1: TGLLightSource;
    GLCamera1: TGLCamera;
    pnlMain: TPanel;
    cmdCopyImageOut2: TButton;
    cmdCopyImageOut: TBitBtn;
    splMidle: TSplitter;
    pnlBottom: TPanel;
    ViewerImageOut: TImage;
    lblImageOut: TLabel;
    shpROIout: TShape;
    ViewerImageOut2: TImage;
    lblImageOut2: TLabel;
    shpViewerToolROI: TShape;
    pnlDivers: TPanel;
    rbgViewerTools: TRadioGroup;
    pnlBottomCenter: TPanel;
    pnlViewerTools: TPanel;
    ViewerToolImage: TImage;
    ViewerToolGLScene: TGLSceneViewer;
    pnlTop: TPanel;
    splTop: TSplitter;
    pnlTopRight: TPanel;
    ViewerImageIn: TImage;
    Label1: TLabel;
    shpROI: TShape;
    imageInSize: TLabel;
    lineY: TShape;
    lineX: TShape;
    pnlTopLeft: TPanel;
    pnlFilters: TPanel;
    pPyramid: TPanel;
    LblPyramid: TLabel;
    lblPyramideNormalisation: TLabel;
    sbPyramid: TScrollBar;
    lstPyramidFilter: TRadioGroup;
    chkPyramidSmasher: TCheckBox;
    sbPyramidNormalisation: TScrollBar;
    pCellOnOff: TPanel;
    Label27: TLabel;
    pInvert: TPanel;
    Label4: TLabel;
    pWavelets: TPanel;
    lblWavelets: TLabel;
    pSubstract: TPanel;
    Label34: TLabel;
    pAdd: TPanel;
    Label50: TLabel;
    pBlur: TPanel;
    Label6: TLabel;
    sbBlurRadius: TScrollBar;
    pExplorer: TPanel;
    Label15: TLabel;
    Label16: TLabel;
    Label7: TLabel;
    sbExplorerX: TScrollBar;
    sbExplorerY: TScrollBar;
    pHistogramContrast: TPanel;
    Label36: TLabel;
    Label37: TLabel;
    Label38: TLabel;
    Label39: TLabel;
    Label40: TLabel;
    Label41: TLabel;
    Label42: TLabel;
    Label43: TLabel;
    Label44: TLabel;
    Label48: TLabel;
    sbHistogramContrastRectangleWidth: TScrollBar;
    sbHistogramContrastRectangleHeight: TScrollBar;
    txtHistogramContrastRectangleWidth: TEdit;
    txtHistogramContrastRectangleHeight: TEdit;
    sbHistogramContrastPrecision: TScrollBar;
    txtHistogramContrastPrecision: TEdit;
    cbHistogramContrastMode: TComboBox;
    sbHistogramContrastGridSpacingWidth: TScrollBar;
    sbHistogramContrastGridSpacingHeight: TScrollBar;
    txtHistogramContrastGridSpacingWidth: TEdit;
    txtHistogramContrastGridSpacingHeight: TEdit;
    sbHistogramContrastBlur: TScrollBar;
    txtHistogramContrastBlur: TEdit;
    pContrastExplorer: TPanel;
    Label19: TLabel;
    Label28: TLabel;
    sbContrastExplorerPrecision: TScrollBar;
    txtContrastExplorerPrecision: TEdit;
    pGranularityExplorer: TPanel;
    Label45: TLabel;
    Label46: TLabel;
    Label49: TLabel;
    sbGranularityExplorerPrecision: TScrollBar;
    txtGranularityExplorerPrecision: TEdit;
    sbGranularityExplorerSensibility: TScrollBar;
    txtGranularityExplorerSensibility: TEdit;
    pApplication2: TPanel;
    LblSurfaceInspection2: TLabel;
    Label53: TLabel;
    rtfInspection2: TRichEdit;
    txtApplication2DefectAreaMin: TEdit;
    sbApplication2DefectAreaMin: TScrollBar;
    pConvolutions: TPanel;
    ViewerImageConv: TImage;
    Label5: TLabel;
    lstConvType: TListBox;
    pLocalDeviation: TPanel;
    Label79: TLabel;
    LblLocalDeviation: TLabel;
    sbPercentLocalDeviation: TScrollBar;
    txtPercentLocalDeviation: TEdit;
    sbLocalDeviationSize: TScrollBar;
    txtLocalDeviationSize: TEdit;
    pApplication1: TPanel;
    Label62: TLabel;
    Label52: TLabel;
    Label54: TLabel;
    shapeApplication1Decision: TShape;
    Label57: TLabel;
    Label63: TLabel;
    Label64: TLabel;
    txtApplication1DefectAreaMin: TEdit;
    sbApplication1DefectAreaMin: TScrollBar;
    RichEdit1: TRichEdit;
    txtApplication1NumberOfDefects: TEdit;
    txtApplication1MinNumberOfDefectsForOK: TEdit;
    sbApplication1MinNumberOfDefectsForOK: TScrollBar;
    txtApplication1MaxNumberOfDefectsForNG: TEdit;
    sbApplication1MaxNumberOfDefectsForNG: TScrollBar;
    pConstantAdd: TPanel;
    Label8: TLabel;
    Label9: TLabel;
    Label10: TLabel;
    sbConstantAdd: TScrollBar;
    txtConstantAddValue: TEdit;
    cbConstantAddOverflowingMode: TComboBox;
    pCopy: TPanel;
    Label75: TLabel;
    Label89: TLabel;
    pHistogram: TPanel;
    Label31: TLabel;
    Label32: TLabel;
    Label33: TLabel;
    Label90: TLabel;
    cbHistogramNormalize: TComboBox;
    sbHistogramPrecision: TScrollBar;
    txtHistogramPrecision: TEdit;
    pMorphology: TPanel;
    Label22: TLabel;
    Label23: TLabel;
    Label24: TLabel;
    Label29: TLabel;
    sbMorphologySE_size: TScrollBar;
    txtMorphologySE_size: TEdit;
    sbMorphologyIteration: TScrollBar;
    txtMorphologyIteration: TEdit;
    pSobel: TPanel;
    Label17: TLabel;
    Label18: TLabel;
    Label20: TLabel;
    Label21: TLabel;
    Label26: TLabel;
    Label65: TLabel;
    sbSobelBlurIteration: TScrollBar;
    txtSobelBlurIteration: TEdit;
    sbSobelGain: TScrollBar;
    txtSobelGain: TEdit;
    sbSobelThresholdLower: TScrollBar;
    txtSobelThresholdLower: TEdit;
    sbSobelThresholdUpper: TScrollBar;
    txtSobelThresholdUpper: TEdit;
    cbSobelModeFast: TComboBox;
    pSUSAN: TPanel;
    Label66: TLabel;
    Label67: TLabel;
    Label68: TLabel;
    Label69: TLabel;
    Label71: TLabel;
    Label72: TLabel;
    sbSUSANprecision: TScrollBar;
    txtSUSANprecision: TEdit;
    txtSUSANpixelBrightnessDifferenceThreshold: TEdit;
    sbSUSANpixelBrightnessDifferenceThreshold: TScrollBar;
    cbSUSANmode: TComboBox;
    sbSUSANpixelCentroidDifferenceThreshold: TScrollBar;
    txtSUSANpixelCentroidDifferenceThreshold: TEdit;
    cbSUSANmasktype: TComboBox;
    pDistancesMap: TPanel;
    lblDistanceMap: TLabel;
    lblMaxEDM: TLabeledEdit;
    gBeforeDistanceMap: TGroupBox;
    chkDistanceMapPreInvert: TCheckBox;
    gAfterDistanceMap: TGroupBox;
    sbDistanceMapScale: TScrollBar;
    pNonMaximaSuppression: TPanel;
    Label74: TLabel;
    Label91: TLabel;
    cbNonMaximaSuppressionOutputColor: TComboBox;
    pThresholdBinary: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Label14: TLabel;
    sbThresholdBinaryLower: TScrollBar;
    txtThresholdBinaryLowerValue: TEdit;
    sbThresholdBinaryUpper: TScrollBar;
    txtThresholdBinaryUpperValue: TEdit;
    rdgLow: TRadioGroup;
    rdgMiddle: TRadioGroup;
    rdgHigh: TRadioGroup;
    pSPV: TPanel;
    Label76: TLabel;
    Label70: TLabel;
    Label78: TLabel;
    Label80: TLabel;
    Label81: TLabel;
    Label82: TLabel;
    Label77: TLabel;
    Label85: TLabel;
    Label86: TLabel;
    Label87: TLabel;
    Label88: TLabel;
    txtSPVScanLineIncrement: TEdit;
    sbSPVScanLineIncrement: TScrollBar;
    txtSPVmaximalTrackingStep: TEdit;
    sbSPVmaximalTrackingStep: TScrollBar;
    txtSPVmaximalTrackingCycles: TEdit;
    sbSPVmaximalTrackingCycles: TScrollBar;
    cbSPVmonitoring: TComboBox;
    txtSPVpolygonalApproximationEpsilone: TEdit;
    sbSPVpolygonalApproximationEpsilone: TScrollBar;
    txtSPVBackground: TEdit;
    sbSPVBackground: TScrollBar;
    cbSPVShowVectorWidth: TComboBox;
    cbSPVShowConnectedVector: TComboBox;
    pBlobExplorer: TPanel;
    Label56: TLabel;
    Label58: TLabel;
    Label60: TLabel;
    Label55: TLabel;
    Label83: TLabel;
    Label84: TLabel;
    Label105: TLabel;
    Label106: TLabel;
    sbBlobExplorerAreaMin: TScrollBar;
    txtBlobExplorerAreaMin: TEdit;
    txtBlobExplorerAreaMax: TEdit;
    sbBlobExplorerAreaMax: TScrollBar;
    cbBlobExplorerEnableBlobArea: TComboBox;
    txtBlobExplorerNumberOfBlobs: TEdit;
    txtBlobExplorerIntensityBackground: TEdit;
    sbBlobExplorerIntensityBackground: TScrollBar;
    txtBlobExplorerIntensityPrecision: TEdit;
    sbBlobExplorerIntensityPrecision: TScrollBar;
    chkBlobExplorerContour: TCheckBox;
    chkBlobExplorerCriticalPoints: TCheckBox;
    txtBlobExplorerCriticalPointsAppoximationAccuracy: TEdit;
    sbBlobExplorerCriticalPointsAppoximationAccuracy: TScrollBar;
    cbBlobExplorerApproximationMethod: TComboBox;
    pContour: TPanel;
    Label103: TLabel;
    Label104: TLabel;
    Label59: TLabel;
    Label61: TLabel;
    txtContourThreshold: TEdit;
    sbContourThreshold: TScrollBar;
    chkContourFill: TCheckBox;
    chkContourCriticalPoints: TCheckBox;
    txtContourApproximationaccuracy: TEdit;
    sbContourApproximationaccuracy: TScrollBar;
    pCanny: TPanel;
    Label95: TLabel;
    Label98: TLabel;
    Label99: TLabel;
    txtCannyThreshold1: TEdit;
    sbCannyThreshold1: TScrollBar;
    txtCannyThreshold2: TEdit;
    sbCannyThreshold2: TScrollBar;
    pLogPolar: TPanel;
    Label94: TLabel;
    Label93: TLabel;
    txtLogpolarMagnitude: TEdit;
    sbLogpolarMagnitude: TScrollBar;
    chkLogpolarReinversetransformation: TCheckBox;
    pCutter: TPanel;
    Label97: TLabel;
    Label102: TLabel;
    Label108: TLabel;
    cbCutterType: TComboBox;
    chkCutterMonitoring: TCheckBox;
    sbCutterOutImages: TScrollBar;
    pCutterTiles: TPanel;
    Label107: TLabel;
    Label101: TLabel;
    txtCutterRectHeight: TEdit;
    sbCutterRectHeight: TScrollBar;
    txtCutterRectWidth: TEdit;
    sbCutterRectWidth: TScrollBar;
    pAdjust: TPanel;
    lblAdjust: TLabel;
    Label109: TLabel;
    lblBrightness: TLabel;
    sbConstrast: TScrollBar;
    sbBrightness: TScrollBar;
    pStandardDeviation: TPanel;
    Label25: TLabel;
    Label30: TLabel;
    Label47: TLabel;
    sbPercentStandardDeviation: TScrollBar;
    txtPercentStandardDeviation: TEdit;
    cbStandardDeviationOutputColor: TComboBox;
    pnlControl: TPanel;
    Label11: TLabel;
    Label12: TLabel;
    Label13: TLabel;
    cmdProcess: TButton;
    txtProcessCount: TEdit;
    txtProcessTime: TEdit;
    chkShowRoi: TCheckBox;
    chkUseROI: TCheckBox;
    pnlRight: TPanel;
    lbFiltersClassic: TListBox;
    lbFiltersOther: TListBox;
    lbApplications: TListBox;
    pMedian: TPanel;
    Label110: TLabel;
    Label111: TLabel;
    sbMedian: TScrollBar;
    txtMedian: TEdit;
    pnlRightTop: TPanel;
    cbFilterType: TComboBox;
    cmdCopyImageOut1ToImageOut2: TButton;
    chkWaveletsInverse: TCheckBox;
    Label92: TLabel;
    cbSubstractMode: TComboBox;
    Label51: TLabel;
    Label96: TLabel;
    Label35: TLabel;
    pCutterBlob: TPanel;
    Label100: TLabel;
    txtCutterBlobBackground: TEdit;
    sbCutterBlobBackground: TScrollBar;
    Label113: TLabel;
    txtCutterBlobAreaMin: TEdit;
    sbCutterBlobAreaMin: TScrollBar;
    txtCutterBlobAreaMax: TEdit;
    sbCutterBlobAreaMax: TScrollBar;
    txtCutterOutimageIndex: TEdit;
    chkBlobExplorerSurfaceInfo: TCheckBox;
    pRotation: TPanel;
    lblRotation: TLabel;
    sbRotationAngle: TScrollBar;
    txtRotationAngle: TEdit;
    sbRotationCenterX: TScrollBar;
    sbRotationCenterY: TScrollBar;
    rdgRotationInterpolation: TRadioGroup;
    Label114: TLabel;
    Label115: TLabel;
    Label116: TLabel;
    Label117: TLabel;
    txtCutterMargin: TEdit;
    sbCutterMargin: TScrollBar;
    Label118: TLabel;
    cbRotationMissingpixelcolormode: TComboBox;
    Label119: TLabel;
    chkRotationMonitoring: TCheckBox;
    chkRotationAutoadjustsize: TCheckBox;
    pIntegration: TPanel;
    lblIntegration: TLabel;
    sbIntegrationScale: TScrollBar;
    sbIntegrationOffset: TScrollBar;
    rdgBlurMode: TRadioGroup;
    pBlobRepositioning: TPanel;
    Label120: TLabel;
    chkBlobRepositioningMonitoring: TCheckBox;
    cbBlobRepositioningMonitoringView: TComboBox;
    txtBlobRepositioningComputedAngle: TEdit;
    lblBlobRepositioningMonitoringView: TLabel;
    Label130: TLabel;
    pVectorHistogram: TPanel;
    Label125: TLabel;
    Label133: TLabel;
    sbVectorHistogramSmooth: TScrollBar;
    Panel2: TPanel;
    Label129: TLabel;
    Label134: TLabel;
    Label135: TLabel;
    Label136: TLabel;
    Label137: TLabel;
    txtVectorHistogramBlobNumero: TEdit;
    sbVectorHistogramBlobNumero: TScrollBar;
    Label139: TLabel;
    txtSubstractDeltaTotal: TEdit;
    chkCutterBlobUseblobrepositioning: TCheckBox;
    pCorrelation: TPanel;
    Label141: TLabel;
    Label145: TLabel;
    txtCorrelationCorrelation: TEdit;
    Label142: TLabel;
    txtVectorHistogramSmooth: TEdit;
    cbVectorHistogramAngleprecision: TComboBox;
    PageControl1: TPageControl;
    tabBlobRepositioningPreprocessing: TTabSheet;
    tabBlobRepositioningMethodVectorhistogram: TTabSheet;
    Label127: TLabel;
    Label128: TLabel;
    txtBlobRepositioningSimulateAngle: TEdit;
    sbBlobRepositioningSimulateAngle: TScrollBar;
    Label131: TLabel;
    sbBlobRepositioningSmooth: TScrollBar;
    Label143: TLabel;
    cbBlobRepositioningVectorhistogramAngleprecision: TComboBox;
    pResize: TPanel;
    lblResize: TLabel;
    sbResizeScale: TScrollBar;
    cbResizeMode: TComboBox;
    txtResizeScale: TEdit;
    Label144: TLabel;
    Label146: TLabel;
    TabSheet1: TTabSheet;
    Label147: TLabel;
    txtBlobRepositioningAutomatictestAngleFrom: TEdit;
    txtBlobRepositioningAutomatictestAngleTo: TEdit;
    Label148: TLabel;
    Label149: TLabel;
    cmdBlobRepositioningAutomatictest: TButton;
    txtBlobRepositioningAutomatictestAngleInc: TEdit;
    txtBlobRepositioningAutomatictestAverageError: TEdit;
    Label150: TLabel;
    Label151: TLabel;
    pbBlobRepositioningAutomatictest: TProgressBar;
    Label155: TLabel;
    txtBlobRepositioningAutomatictestMaxError: TEdit;
    Label156: TLabel;
    cmdBlobRepositioningAutomatictestStop: TButton;
    pGradientAnisotropicDiffusion: TPanel;
    Label153: TLabel;
    Label154: TLabel;
    txtGradientAnisotropicDiffusionConductance: TEdit;
    sbGradientAnisotropicDiffusionConductance: TScrollBar;
    Label157: TLabel;
    txtGradientAnisotropicDiffusionIteration: TEdit;
    sbGradientAnisotropicDiffusionIteration: TScrollBar;
    pRescaleIntensity: TPanel;
    Label158: TLabel;
    Label159: TLabel;
    Label160: TLabel;
    txtRescaleIntensityMinimum: TEdit;
    sbRescaleIntensityMinimum: TScrollBar;
    txtRescaleIntensityMaximum: TEdit;
    sbRescaleIntensityMaximum: TScrollBar;
    pWaves: TPanel;
    lblWaves: TLabel;
    cmdWavesStep: TButton;
    Label161: TLabel;
    cbGradientAnisotropicDiffusionMethod: TComboBox;
    pSigmoid: TPanel;
    Label162: TLabel;
    Label163: TLabel;
    Label164: TLabel;
    txtSigmoidMinimum: TEdit;
    sbSigmoidMinimum: TScrollBar;
    txtSigmoidMaximum: TEdit;
    sbSigmoidMaximum: TScrollBar;
    Label165: TLabel;
    txtSigmoidAlpha: TEdit;
    sbSigmoidAlpha: TScrollBar;
    Label166: TLabel;
    txtSigmoidBeta: TEdit;
    sbSigmoidBeta: TScrollBar;
    pBilateral: TPanel;
    Label167: TLabel;
    Label168: TLabel;
    Label169: TLabel;
    txtBilateralDomainsigma: TEdit;
    sbBilateralDomainsigma: TScrollBar;
    txtBilateralRangesigma: TEdit;
    sbBilateralRangeSigma: TScrollBar;
    ApplicationEvents: TApplicationEvents;
    chkWavesContinue: TCheckBox;
    Label170: TLabel;
    txtCorrelationRangeMin: TEdit;
    sbCorrelationRangeMin: TScrollBar;
    Label171: TLabel;
    txtCorrelationRangeMax: TEdit;
    sbCorrelationRangeMax: TScrollBar;
    chkCorrelationMonitoring: TCheckBox;
    txtBlobRepositioningAutomatictestAngle: TEdit;
    Label172: TLabel;
    Label173: TLabel;
    cbHistogramFeature: TComboBox;
    pImageLoader: TPanel;
    Label174: TLabel;
    Label176: TLabel;
    cmdImageLoaderLoad: TButton;
    lstImageLoaderViewImage: TListBox;
    Label175: TLabel;
    cmdImageLoaderOpen: TButton;
    txtImageLoaderFiles: TMemo;
    dlgImageLoaderOpen: TOpenDialog;
    pImageSaver: TPanel;
    Label177: TLabel;
    Label178: TLabel;
    cmdImageSaverSave: TButton;
    cmdImageSaverSelect: TButton;
    txtImageSaverFilename: TMemo;
    rgImageSaverImage: TRadioGroup;
    dlgImageSaverSelect: TSaveDialog;
    pProjectionLine: TPanel;
    Label179: TLabel;
    Label180: TLabel;
    sbProjectionLineSmooth: TScrollBar;
    Panel3: TPanel;
    Label182: TLabel;
    Label183: TLabel;
    Label184: TLabel;
    Label185: TLabel;
    txtProjectionLinePreprocessingBlobIndex: TEdit;
    sbProjectionLinePreprocessingBlobIndex: TScrollBar;
    txtProjectionLineSmooth: TEdit;
    Label181: TLabel;
    Label186: TLabel;
    txtProjectionLinePreprocessingSimulateAngle: TEdit;
    sbProjectionLinePreprocessingSimulateAngle: TScrollBar;
    Label187: TLabel;
    rgProjectionLineInput: TRadioGroup;
    Label195: TLabel;
    Label196: TLabel;
    txtVectorHistogramPreprocessingAngle: TEdit;
    sbVectorHistogramPreprocessingAngle: TScrollBar;
    pBlobBalance: TPanel;
    Label188: TLabel;
    Panel4: TPanel;
    Label190: TLabel;
    Label191: TLabel;
    Label192: TLabel;
    Label193: TLabel;
    Label194: TLabel;
    Label197: TLabel;
    Label198: TLabel;
    txtBlobBalancePreprocessingBlobIndex: TEdit;
    sbBlobBalancePreprocessingBlobIndex: TScrollBar;
    txtBlobBalancePreprocessingAngle: TEdit;
    sbBlobBalancePreprocessingAngle: TScrollBar;
    chkBlobBalanceMonitoring: TCheckBox;
    Label189: TLabel;
    txtProjectionLineMaximum: TEdit;
    Label199: TLabel;
    txtBlobBalanceAngle: TEdit;
    cmdBlobBalanceSetAngleToZero: TButton;
    Label200: TLabel;
    cmdBlobRepositioningLearn: TButton;
    Label140: TLabel;
    txtBlobRepositioningMargin: TEdit;
    sbBlobRepositioningMargin: TScrollBar;
    txtBlobRepositioningBlobThreshold: TEdit;
    Label123: TLabel;
    sbBlobRepositioningBlobThreshold: TScrollBar;
    Label122: TLabel;
    txtBlobRepositioningBlobAreaMin: TEdit;
    sbBlobRepositioningBlobAreaMin: TScrollBar;
    txtBlobRepositioningBlobAreaMax: TEdit;
    sbBlobRepositioningBlobAreaMax: TScrollBar;
    pBlobRepositioning2: TPanel;
    Label124: TLabel;
    Label132: TLabel;
    Label138: TLabel;
    chkBlobRepositioning2Monitoring: TCheckBox;
    txtBlobRepositioning2ComputedAngle: TEdit;
    PageControl2: TPageControl;
    TabSheet2: TTabSheet;
    Label152: TLabel;
    Label201: TLabel;
    txtBlobRepositioning2SimulateAngle: TEdit;
    sbBlobRepositioning2SimulateAngle: TScrollBar;
    TabSheet3: TTabSheet;
    Label205: TLabel;
    Label206: TLabel;
    Label207: TLabel;
    cmdBlobRepositioning2Learn: TButton;
    txtBlobRepositioning2Margin: TEdit;
    sbBlobRepositioning2Margin: TScrollBar;
    txtBlobRepositioning2BlobThreshold: TEdit;
    sbBlobRepositioning2BlobThreshold: TScrollBar;
    txtBlobRepositioning2BlobAreaMin: TEdit;
    sbBlobRepositioning2BlobAreaMin: TScrollBar;
    txtBlobRepositioning2BlobAreaMax: TEdit;
    sbBlobRepositioning2BlobAreaMax: TScrollBar;
    TabSheet4: TTabSheet;
    Label208: TLabel;
    Label209: TLabel;
    Label210: TLabel;
    Label211: TLabel;
    Label212: TLabel;
    Label213: TLabel;
    Label214: TLabel;
    Label215: TLabel;
    Label216: TLabel;
    txtBlobRepositioning2AutomatictestAngleFrom: TEdit;
    txtBlobRepositioning2AutomatictestAngleTo: TEdit;
    cmdBlobRepositioning2Automatictest: TButton;
    txtBlobRepositioning2AutomatictestAngleInc: TEdit;
    txtBlobRepositioning2AutomatictestAverageError: TEdit;
    pbBlobRepositioning2Automatictest: TProgressBar;
    txtBlobRepositioning2AutomatictestMaxError: TEdit;
    cmdBlobRepositioning2AutomatictestStop: TButton;
    txtBlobRepositioning2AutomatictestAngle: TEdit;
    cbBlobRepositioning2MonitoringView: TComboBox;
    Label126: TLabel;
    Label121: TLabel;
    Label202: TLabel;
    txtBlobRepositioning2Error: TEdit;
    Label203: TLabel;
    txtBlobRepositioningError: TEdit;
    sbHelp: TSpeedButton;
    chkCutterBlobClean: TCheckBox;
    chkPyramidNormalize: TCheckBox;
    MemoHelp: TMemo;
    lstMorphologyType: TListBox;
    pBlobGrouping: TPanel;
    Label204: TLabel;
    Label217: TLabel;
    txtBlobGroupingIntensityPrecision: TEdit;
    sbBlobGroupingIntensityPrecision: TScrollBar;
    chkStandardDeviationShowOnlyROI: TCheckBox;
    Label218: TLabel;
    txtExplorerPrecision: TEdit;
    sbExplorerPrecision: TScrollBar;
    txtExplorerX: TEdit;
    txtExplorerY: TEdit;
    chkBlobExplorerIgnoreBlobsOnImageEdges: TCheckBox;
    chkBlobRepositioning2BackgroundColor: TCheckBox;
    txtBlurRadius: TEdit;
    Label219: TLabel;
    pImageCreator: TPanel;
    Label220: TLabel;
    Label221: TLabel;
    txtImageCreatorHelp: TMemo;
    Label222: TLabel;
    txtImageCreatorCommand: TEdit;
    rgrpMorphoSE: TRadioGroup;
    gridMorphologySE: TStringGrid;
    cbContrastExplorerMode: TComboBox;
    Label223: TLabel;
    txtViewerToolText1: TEdit;
    txtViewerToolText2: TEdit;
    pCoOccurrenceMatrix: TPanel;
    lblCooccurenceMatrix: TLabel;
    sbCooccurenceHorSize: TScrollBar;
    lblHorCoSize: TLabel;
    txtHorCoSize: TEdit;
    cbCopyOutputColor: TComboBox;
    Label73: TLabel;
    txtVerCoSize: TEdit;
    sbCooccurenceVerSize: TScrollBar;
    Label224: TLabel;
    sbCoOccurenceScale: TScrollBar;
    txtCoocurrenceScale: TEdit;
    rdCoocurenceX: TRadioGroup;
    rdCoocurenceY: TRadioGroup;
    chkSobelAngleCalculation: TCheckBox;
    chkCoocurenceResultROI: TCheckBox;
    txtNonMaximaSuppressionGain: TEdit;
    Label225: TLabel;
    sbNonMaximaSuppressionGain: TScrollBar;
    chkSusanAngleCalculation: TCheckBox;
    txtSusanGain: TEdit;
    sbSusanGain: TScrollBar;
    Label226: TLabel;
    chkCoocurenceShift45: TCheckBox;
    Label227: TLabel;
    txtSubstractDeltaTotalNormalized: TEdit;
    sbGranularityExplorerDifferenceThreshold: TScrollBar;
    txtGranularityExplorerDifferenceThreshold: TEdit;
    Label228: TLabel;
    pStackAnalyser: TPanel;
    Label229: TLabel;
    lstStackAnalyserAnalyse: TListBox;
    Analyse: TLabel;
    sbStackAnalyserInImages: TScrollBar;
    Label230: TLabel;
    chkMask: TCheckBox;
    pStackCreator: TPanel;
    Label231: TLabel;
    sbStackCreatorImageIndex: TScrollBar;
    Label232: TLabel;
    txtStackCreatorImageIndex: TEdit;
    sbStackCreatorStackSize: TScrollBar;
    txtStackCreatorStackSize: TEdit;
    Label233: TLabel;
    chkStackCreatorDemoStackAnalyser: TCheckBox;
    pEnvelope: TPanel;
    Label234: TLabel;
    Label235: TLabel;
    lstEnvelopeOutputs: TListBox;
    Label236: TLabel;
    txtEnvelopeSmooth: TEdit;
    sbEnvelopeSmooth: TScrollBar;
    Label237: TLabel;
    pMeans: TPanel;
    Label238: TLabel;
    Label239: TLabel;
    sbMeansPrecision: TScrollBar;
    txtMeansPrecision: TEdit;
    pImageInfo: TPanel;
    Label240: TLabel;
    Label112: TLabel;
    txtImageInfoPixelMin: TEdit;
    Label241: TLabel;
    txtImageInfoPixelMax: TEdit;
    Label242: TLabel;
    txtImageInfoPixelMaxSubMin: TEdit;
    Label243: TLabel;
    cbAddMode: TComboBox;
    Label244: TLabel;
    GroupBox1: TGroupBox;
    Label245: TLabel;
    txtCoOccurrenceMatrixFeaturesEnergy: TEdit;
    Label246: TLabel;
    txtCoOccurrenceMatrixFeaturesEntropy: TEdit;
    Label247: TLabel;
    txtCoOccurrenceMatrixFeaturesContrast: TEdit;
    Label248: TLabel;
    txtCoOccurrenceMatrixFeaturesInversedifferencemoment: TEdit;
    Label249: TLabel;
    txtCoOccurrenceMatrixFeaturesAngularSecondMoment: TEdit;
    pLog: TPanel;
    Label250: TLabel;
    chkAdjustAuto: TCheckBox;
    chkLogAdjustAuto: TCheckBox;
    Label251: TLabel;
    txtLogIntensityMax: TEdit;
    sbLogIntensityMax: TScrollBar;
    Label252: TLabel;
    txtCoOccurrenceMatrixFeaturesDissimilarity: TEdit;
    Label253: TLabel;
    txtCoOccurrenceMatrixFeaturesMeanI: TEdit;
    Label254: TLabel;
    txtCoOccurrenceMatrixFeaturesMeanJ: TEdit;
    Label255: TLabel;
    Label256: TLabel;
    txtCoOccurrenceMatrixFeaturesVarianceI: TEdit;
    Label257: TLabel;
    txtCoOccurrenceMatrixFeaturesVarianceJ: TEdit;
    Label258: TLabel;
    txtCoOccurrenceMatrixFeaturesCorrelation: TEdit;
    rdgBlobRepositioning2RotationInterpolation: TRadioGroup;
    pCompare: TPanel;
    Label259: TLabel;
    Label260: TLabel;
    Label261: TLabel;
    Label262: TLabel;
    cbCompareMode: TComboBox;
    Label265: TLabel;
    Label263: TLabel;
    Label264: TLabel;
    pRGB: TPanel;
    sbRGBConstantR: TScrollBar;
    txtRGBConstantR: TEdit;
    cbRGBOverflowingMode: TComboBox;
    sbRGBConstantG: TScrollBar;
    txtRGBConstantG: TEdit;
    sbRGBConstantB: TScrollBar;
    txtRGBConstantB: TEdit;
    Label266: TLabel;
    Label267: TLabel;
    Label268: TLabel;
    Label269: TLabel;
    Label270: TLabel;
    chkBlobExplorerIntensityInvert: TCheckBox;
    pFiltersPlugin_TestDelphi: TPanel;
    Label271: TLabel;
    lbFiltersPlugins: TListBox;
    Label272: TLabel;
    pHoughTransform: TPanel;
    Label273: TLabel;
    Label274: TLabel;
    txtHoughTransformThreshold: TEdit;
    sbHoughTransformThreshold: TScrollBar;
    cbHoughTransformPreprocessor: TComboBox;
    Label275: TLabel;
    cbBlobExplorerImageToShow: TComboBox;
    Label276: TLabel;
    GroupBox2: TGroupBox;
    Label277: TLabel;
    txtPluginSampleOutputInteger: TEdit;
    Label278: TLabel;
    Label280: TLabel;
    Label281: TLabel;
    txtPluginSampleOutputFloat: TEdit;
    Label282: TLabel;
    testImageOutput: TLabel;
    Label283: TLabel;
    cbPluginSampleOutputImages: TComboBox;
    Label284: TLabel;
    txtPluginOutputArrayPointers: TMemo;
    Label285: TLabel;
    GroupBox3: TGroupBox;
    Label286: TLabel;
    txtPluginSampleParameterInteger: TEdit;
    Label279: TLabel;
    txtPluginSampleParameterFloat: TEdit;
    chkPluginSampleParameterBoolean: TCheckBox;
    Label287: TLabel;
    txtPluginSampleParameterString: TEdit;
    Label288: TLabel;
    Label289: TLabel;
    pFiltersPlugin_TestC: TPanel;
    Label290: TLabel;
    Label291: TLabel;
    GroupBox4: TGroupBox;
    Label292: TLabel;
    Label293: TLabel;
    Label294: TLabel;
    Label295: TLabel;
    Label296: TLabel;
    Label297: TLabel;
    Label298: TLabel;
    Label299: TLabel;
    txtPluginTestC_OutputInteger: TEdit;
    txtPluginTestC_OutputFloat: TEdit;
    cbPluginTestC_OutputImages: TComboBox;
    txtPluginTestC_OutputArrayPointers: TMemo;
    GroupBox5: TGroupBox;
    Label300: TLabel;
    Label301: TLabel;
    Label302: TLabel;
    Label303: TLabel;
    Label304: TLabel;
    txtPluginTestC_ParameterInteger: TEdit;
    txtPluginTestC_ParameterFloat: TEdit;
    chkPluginTestC_ParameterBoolean: TCheckBox;
    txtPluginTestC_ParameterString: TEdit;
    pFiltersPlugin_Video: TPanel;
    Label305: TLabel;
    chkPluginVideoShowViewer: TCheckBox;
    cmdPluginVideoFileName: TButton;
    dlgPluginVideoOpen: TOpenDialog;
    txtPluginVideoFileName: TEdit;
    cmdPluginVideoLoad: TButton;
    cmdPluginVideoPlay: TButton;
    cmdPluginVideoStop: TButton;
    Label306: TLabel;
    cmdPluginVideoPause: TButton;
    pFiltersPlugin_WebCam: TPanel;
    Label307: TLabel;
    Label308: TLabel;
    chkPluginWebCamShowViewer: TCheckBox;
    btnPluginWebCamGetDevices: TButton;
    lbPluginWebCamDevices: TListBox;
    btnPluginWebCamGetFormats: TButton;
    lbPluginWebCamDeviceFormats: TListBox;
    txtPluginWebCamDeviceIndex: TEdit;
    chkPluginWebCamDeviceOpenClose: TCheckBox;
    txtPluginWebCamFormatIndex: TEdit;
    PageControlSource: TPageControl;
    tabImage: TTabSheet;
    tabVideo: TTabSheet;
    tabWebCam: TTabSheet;
    cmdLoadImage: TButton;
    cmdSave: TButton;
    btnWebCamLive: TButton;
    cbWebCamDevice: TComboBox;
    cbWebCamFormat: TComboBox;
    lblROI: TLabel;
    cmdLoadVideo: TButton;
    cmdPlay: TBitBtn;
    cmdPause: TBitBtn;
    cmdStop: TBitBtn;
    btnVideoCapture: TButton;
    chkVideoAutoCaptureRun: TCheckBox;
    btnWebCamCapture: TButton;
    chkWebCamAutoCaptureRun: TCheckBox;
    pFiltersPlugin_Viewer: TPanel;
    Label309: TLabel;
    Label310: TLabel;
    chkPluginViewerShowViewer: TCheckBox;
    pFiltersPlugin_Resonator: TPanel;
    lblResonator: TLabel;
    lblOmega: TLabel;
    scrOmega: TScrollBar;
    txtViewerToolText3: TEdit;
    pFiltersPlugin_SnapShot: TPanel;
    Label311: TLabel;
    Label312: TLabel;
    btnPluginSnapShotGetWindowsTitle: TButton;
    lbPluginSnapShotWindowsTitle: TListBox;
    txtPluginSnapShotWindowTitle: TEdit;
    btnPluginSnapShotApplication: TButton;
    txtPluginSnapShotApplication: TEdit;
    Label313: TLabel;
    txtPluginSnapShotWindowHandle: TEdit;
    Label314: TLabel;
    Label315: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure readCommandLine();
    procedure AcceptFiles( var msg : TMessage ); message WM_DROPFILES;
    procedure cmdLoadImageClick(Sender: TObject);
    procedure btnCloseClick(Sender: TObject);
    procedure sbConstantAddChange(Sender: TObject);
    procedure cbConstantAddOverflowingModeChange(Sender: TObject);
    procedure lstConvTypeClick(Sender: TObject);
    procedure sbThresholdBinaryLowerChange(Sender: TObject);
    procedure sbThresholdBinaryUpperChange(Sender: TObject);
    procedure sbExplorerXChange(Sender: TObject);
    procedure splMidleMoved(Sender: TObject);
    procedure pcTestChange(Sender: TObject);
    procedure sbSobelChange(Sender: TObject);
    procedure sbContrastExplorerPrecisionChange(Sender: TObject);
    procedure sbMorphologySE_sizeChange(Sender: TObject);
    procedure cbMorphologyTypeChange(Sender: TObject);
    procedure sbMorphologyIterationChange(Sender: TObject);
    procedure sbPercentStandardDeviationChange(Sender: TObject);
    procedure shpROIMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure shpROIMouseMove(Sender: TObject; Shift: TShiftState; X,
      Y: Integer);
    procedure ViewerImageInMouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    procedure lbFiltersClassicClick(Sender: TObject);
    procedure FormResize(Sender: TObject);
    procedure cmdProcessClick(Sender: TObject);
    procedure chkUseROIClick(Sender: TObject);
    procedure ViewerImageInMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure ViewerImageInMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure cbHistogramNormalizeChange(Sender: TObject);
    procedure sbHistogramPrecisionChange(Sender: TObject);
    procedure cbFilterTypeChange(Sender: TObject);
    procedure lbFiltersOtherClick(Sender: TObject);
    procedure sbBlurRadiusChange(Sender: TObject);
    procedure splTopMoved(Sender: TObject);
    procedure sbHistogramContrastRectangleWidthChange(Sender: TObject);
    procedure sbHistogramContrastRectangleHeightChange(Sender: TObject);
    procedure sbHistogramContrastPrecisionChange(Sender: TObject);
    procedure sbPyramidChange(Sender: TObject);
    procedure cbHistogramContrastModeChange(Sender: TObject);
    procedure sbHistogramContrastGridSpacingWidthChange(Sender: TObject);
    procedure sbHistogramContrastGridSpacingHeightChange(Sender: TObject);
    procedure btnWebCamLiveClick(Sender: TObject);
    procedure cbWebCamDeviceChange(Sender: TObject);
    procedure cmdCopyImageOut2Click(Sender: TObject);
    procedure btnVideoCaptureClick(Sender: TObject);
    procedure chkVideoAutoCaptureRunClick(Sender: TObject);
    procedure sbGranularityExplorerPrecisionChange(Sender: TObject);
    procedure cbStandardDeviationOutputColorChange(Sender: TObject);
    procedure sbHistogramContrastBlurChange(Sender: TObject);
    procedure sbGranularityExplorerSensibilityChange(Sender: TObject);
    procedure lstPyramidFilterClick(Sender: TObject);
    procedure cmdCopyImageOut1ToImageOut2Click(Sender: TObject);
    procedure sbBlobExplorerChange(Sender: TObject);
    procedure cbBlobExplorerEnableBlobSizeChange(Sender: TObject);
    procedure sbPyramidNormalisationChange(Sender: TObject);
    procedure lbApplicationsClick(Sender: TObject);
    procedure sbApplication1DefectAreaMinChange(Sender: TObject);
    procedure sbApplication2DefectAreaMinChange(Sender: TObject);
    procedure sbApplication1MinMaxNumberOfDefectsChange(Sender: TObject);
    procedure cbSobelModeFastChange(Sender: TObject);
    procedure sbSUSANprecisionChange(Sender: TObject);
    procedure sbSUSANpixelBrightnessDifferenceThresholdChange(
      Sender: TObject);
    procedure cbSUSANmodeChange(Sender: TObject);
    procedure sbSUSANpixelCentroidDifferenceThresholdChange(
      Sender: TObject);
    procedure sbSPVScanLineIncrementChange(Sender: TObject);
    procedure cbSPVbackgroundColorChange(Sender: TObject);
    procedure lbFiltersClassicDblClick(Sender: TObject);
    procedure sbLocalDeviationSizeChange(Sender: TObject);
    procedure chkShowRoiClick(Sender: TObject);
    procedure sbBlobExplorerIntensityBackgroundChange(Sender: TObject);
    procedure pnlFiltersDblClick(Sender: TObject);
    procedure ViewerImageOut2Click(Sender: TObject);
    procedure sbDistanceMapScaleChange(Sender: TObject);
    procedure chkDistanceMapPreInvertClick(Sender: TObject);
    procedure TimerAutoProcessTimer(Sender: TObject);
    procedure rdgThresholdClick(Sender: TObject);
    procedure cbNonMaximaSuppressionOutputColorChange(Sender: TObject);
    procedure lbFiltersOtherDblClick(Sender: TObject);
    procedure lbApplicationsDblClick(Sender: TObject);
    procedure lbFiltersOpencvDblClick(Sender: TObject);
    procedure sbContourThresholdChange(Sender: TObject);
    procedure chkContourFillClick(Sender: TObject);
    procedure cmdLoadVideoClick(Sender: TObject);
    procedure cmdCopyImageOutClick(Sender: TObject);
    procedure cmdSaveClick(Sender: TObject);
    procedure cmdPauseClick(Sender: TObject);
    procedure cmdStopClick(Sender: TObject);
    procedure cmdPlayClick(Sender: TObject);
    procedure chkBlobExplorerCriticalPointsClick(Sender: TObject);
    procedure sbBlobExplorerCriticalPointsAppoximationAccuracyChange(
      Sender: TObject);
    procedure shpViewerToolROIMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure shpViewerToolROIMouseMove(Sender: TObject;
      Shift: TShiftState; X, Y: Integer);
    procedure ViewerImageOutMouseMove(Sender: TObject; Shift: TShiftState;
      X, Y: Integer);
    procedure ViewerImageOutMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure rbgViewerToolsClick(Sender: TObject);
    procedure HeightField1GetHeight(const x, y: Single; var z: Single;
      var color: TVector4f; var texPoint: TTexPoint);
    procedure ViewerToolGLSceneMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure ViewerToolGLSceneMouseMove(Sender: TObject;
      Shift: TShiftState; X, Y: Integer);
    procedure shpViewerToolROIMouseUp(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure sbLogpolarMagnitudeChange(Sender: TObject);
    procedure chkLogpolarReinversetransformationClick(Sender: TObject);
    procedure FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
      MousePos: Types.TPoint; var Handled: Boolean);
    procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
      MousePos: Types.TPoint; var Handled: Boolean);
    procedure sbCutterRectWidthChange(Sender: TObject);
    procedure sbCutterRectHeightChange(Sender: TObject);
    procedure chkCutterMonitoringClick(Sender: TObject);
    procedure sbCutterOutImagesChange(Sender: TObject);
    procedure sbConstrastChange(Sender: TObject);
    procedure sbBrightnessChange(Sender: TObject);
    procedure sbMedianChange(Sender: TObject);
    procedure sbCannyThresholdChange(Sender: TObject);
    procedure chkWaveletsInverseClick(Sender: TObject);
    procedure cbSubstractModeChange(Sender: TObject);
    procedure cbCutterTypeChange(Sender: TObject);
    procedure sbCutterBlobBackgroundChange(Sender: TObject);
    procedure sbCutterBlobAreaChange(Sender: TObject);
    procedure sbRotationAngleChange(Sender: TObject);
    procedure sbRotationCenterXChange(Sender: TObject);
    procedure rdgRotationInterpolationClick(Sender: TObject);
    procedure sbCutterMarginChange(Sender: TObject);
    procedure cbRotationMissingpixelcolormodeChange(Sender: TObject);
    procedure chkRotationMonitoringClick(Sender: TObject);
    procedure sbIntegrationScaleChange(Sender: TObject);
    procedure sbIntegrationOffsetChange(Sender: TObject);
    procedure rdgBlurModeClick(Sender: TObject);
    procedure sbBlobRepositioningBlobNumeroChange(Sender: TObject);
    procedure sbBlobRepositioningSimulateAngleChange(Sender: TObject);
    procedure cbBlobRepositioningMonitoringViewChange(Sender: TObject);
    procedure sbBlobRepositioningSmoothChange(Sender: TObject);
    procedure cmdBlobRepositioningLearnClick(Sender: TObject);
    procedure sbVectorHistogramSmoothChange(Sender: TObject);
    procedure sbVectorHistogramBlobNumeroChange(Sender: TObject);
    procedure sbBlobRepositioningMarginChange(Sender: TObject);
    procedure chkCutterBlobUseblobrepositioningClick(Sender: TObject);
    procedure cbVectorHistogramAngleprecisionChange(Sender: TObject);
    procedure chkBlobRepositioningMonitoringClick(Sender: TObject);
    procedure cbBlobRepositioningMethodChange(Sender: TObject);
    procedure cbBlobRepositioningVectorhistogramAngleprecisionChange(
      Sender: TObject);
    procedure sbResizeScaleChange(Sender: TObject);
    procedure cbResizeModeChange(Sender: TObject);
    procedure cmdBlobRepositioningAutomatictestClick(Sender: TObject);
    procedure cmdBlobRepositioning2AutomatictestClick(Sender: TObject);
    procedure cmdBlobRepositioningAutomatictestStopClick(Sender: TObject);
    procedure sbGradientAnisotropicDiffusionConductanceChange(
      Sender: TObject);
    procedure sbRescaleIntensityChange(Sender: TObject);
    procedure cmdWavesStepClick(Sender: TObject);
    procedure cbGradientAnisotropicDiffusionMethodChange(Sender: TObject);
    procedure sbSigmoidMinimumChange(Sender: TObject);
    procedure sbBilateralDomainsigmaChange(Sender: TObject);
    procedure ApplicationEventsIdle(Sender: TObject; var Done: Boolean);
    procedure sbCorrelationRangeMinChange(Sender: TObject);
    procedure chkCorrelationMonitoringClick(Sender: TObject);
    procedure cbHistogramFeatureChange(Sender: TObject);
    procedure shpROIMouseUp(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure cmdImageLoaderLoadClick(Sender: TObject);
    procedure cmdImageLoaderOpenClick(Sender: TObject);
    procedure lstImageLoaderViewImageClick(Sender: TObject);
    procedure cmdImageSaverSaveClick(Sender: TObject);
    procedure cmdImageSaverSelectClick(Sender: TObject);
    procedure sbProjectionLinePreprocessingBlobIndexChange(
      Sender: TObject);
    procedure sbProjectionLineSmoothChange(Sender: TObject);
    procedure sbProjectionLinePreprocessingSimulateAngleChange(
      Sender: TObject);
    procedure rgProjectionLineInputClick(Sender: TObject);
    procedure sbVectorHistogramPreprocessingAngleChange(Sender: TObject);
    procedure sbBlobBalancePreprocessingAngleChange(Sender: TObject);
    procedure sbBlobBalancePreprocessingBlobIndexChange(Sender: TObject);
    procedure chkBlobBalanceMonitoringClick(Sender: TObject);
    procedure cmdBlobBalanceSetAngleToZeroClick(Sender: TObject);
    procedure txtBlobRepositioningBlobThresholdChange(Sender: TObject);
    procedure sbBlobRepositioningBlobChange(Sender: TObject);
    procedure cmdBlobRepositioning2LearnClick(Sender: TObject);
    procedure sbHelpClick(Sender: TObject);
    procedure MemoHelpMouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure chkPyramidSmasherClick(Sender: TObject);
    procedure lbFiltersClassicMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure lstMorphologyTypeClick(Sender: TObject);
    procedure sbBlobGroupingIntensityPrecisionChange(Sender: TObject);
    procedure chkStandardDeviationShowOnlyROIClick(Sender: TObject);
    procedure sbExplorerPrecisionChange(Sender: TObject);
    procedure chkBlobRepositioning2BackgroundColorClick(Sender: TObject);
    procedure txtImageCreatorCommandKeyPress(Sender: TObject;
      var Key: Char);
    procedure rgrpMorphoSEClick(Sender: TObject);
    procedure gridMorphologySEMouseDown(Sender: TObject;
      Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure gridMorphologySEMouseMove(Sender: TObject;
      Shift: TShiftState; X, Y: Integer);
    procedure cbContrastExplorerModeChange(Sender: TObject);
    procedure sbCooccurenceHorSizeChange(Sender: TObject);
    procedure cbCopyOutputColorChange(Sender: TObject);
    procedure rdCoocurenceClick(Sender: TObject);
    procedure chkSobelAngleCalculationClick(Sender: TObject);
    procedure chkCoocurenceResultROIClik(Sender: TObject);
    procedure sbNonMaximaSuppressionGainChange(Sender: TObject);
    procedure chkSusanAngleCalculationClick(Sender: TObject);
    procedure sbSusanGainChange(Sender: TObject);
    procedure ViewerImageOutDblClick(Sender: TObject);
    procedure chkCoocurenceShift45Click(Sender: TObject);
    procedure sbGranularityExplorerDifferenceThresholdChange(
      Sender: TObject);
    procedure lstStackAnalyserAnalyseClick(Sender: TObject);
    procedure sbStackAnalyserInImagesChange(Sender: TObject);
    procedure chkMaskClick(Sender: TObject);
    procedure sbStackCreatorImageIndexChange(Sender: TObject);
    procedure chkStackCreatorDemoStackAnalyserClick(Sender: TObject);
    procedure lstEnvelopeOutputsClick(Sender: TObject);
    procedure sbEnvelopeSmoothChange(Sender: TObject);
    procedure sbMeansPrecisionChange(Sender: TObject);
    procedure cbAddModeChange(Sender: TObject);
    procedure chkAdjustAutoClick(Sender: TObject);
    procedure sbLogIntensityMaxChange(Sender: TObject);
    procedure sbRGBConstantRChange(Sender: TObject);
    procedure chkBlobExplorerIntensityInvertClick(Sender: TObject);
    procedure lbFiltersPluginsClick(Sender: TObject);
    procedure lbFiltersPluginsDblClick(Sender: TObject);
    procedure sbHoughTransformThresholdChange(Sender: TObject);
    procedure cbHoughTransformPreprocessorChange(Sender: TObject);
    procedure cbBlobExplorerImageToShowChange(Sender: TObject);
    procedure cbPluginSampleOutputImagesChange(Sender: TObject);
    procedure txtPluginSampleParameterIntegerChange(Sender: TObject);
    procedure chkPluginSampleParameterBooleanClick(Sender: TObject);
    procedure txtImageCreatorHelpDblClick(Sender: TObject);
    procedure chkPluginVideoShowViewerClick(Sender: TObject);
    procedure cmdPluginVideoFileNameClick(Sender: TObject);
    procedure lstPluginVideoCommandClick(Sender: TObject);
    procedure cmdPluginVideoLoadClick(Sender: TObject);
    procedure cmdPluginVideoPlayClick(Sender: TObject);
    procedure cmdPluginVideoStopClick(Sender: TObject);
    procedure cmdPluginVideoPauseClick(Sender: TObject);
    procedure btnPluginWebCamGetDevicesClick(Sender: TObject);
    procedure lbPluginWebCamDevicesClick(Sender: TObject);
    procedure btnPluginWebCamGetFormatsClick(Sender: TObject);
    procedure lbPluginWebCamDevicesDblClick(Sender: TObject);
    procedure chkPluginWebCamDeviceOpenCloseClick(Sender: TObject);
    procedure lbPluginWebCamDeviceFormatsClick(Sender: TObject);
    procedure lbPluginWebCamDeviceFormatsDblClick(Sender: TObject);
    procedure btnWebCamCaptureClick(Sender: TObject);
    procedure chkWebCamAutoCaptureRunClick(Sender: TObject);
    procedure cbWebCamFormatChange(Sender: TObject);
    procedure chkPluginViewerShowViewerClick(Sender: TObject);
    procedure chkBlobExplorerContourClick(Sender: TObject);
    procedure btnPluginSnapShotGetWindowsTitleClick(Sender: TObject);
    procedure lbPluginSnapShotWindowsTitleDblClick(Sender: TObject);
    procedure lbPluginSnapShotWindowsTitleClick(Sender: TObject);
    procedure btnPluginSnapShotApplicationClick(Sender: TObject);
  private
    filterArithmeticAdd : Integer;
    filterArithmeticConstantAdd : Integer;
    filterRGB : Integer;
    filterArithmeticSubstract : Integer;
    filterBlobExplorer : Integer;
    filterBlobRepositioning : Integer;
    filterBlobRepositioning2 : Integer;
    fRotationForSimulateAngle : Integer;
    fBlobExplorerForBlob : Integer;
    filterBlur : Integer;
    filterContrastExplorer : Integer;
    filterConvolution : Integer;
    filterCoOccurrenceMatrix : Integer;
    filterCopy : Integer;
    filterDistancesMap : Integer;
    filterExplorer : Integer;
    filterGranularityExplorer : Integer;
    filterHistogram : Integer;
    filterHistogramContrast : Integer;
    filterInvert : Integer;
    filterResize : Integer;
    filterLocalDeviation : Integer;
    filterMorphology : Integer;
    filterNonMaximaSuppression : Integer;
    filterMeans : Integer;
    filterImageInfo : Integer;
    filterMedian : Integer;
    filterNormalize : Integer;
    filterOnOffCell : Integer;
    filterPyramid : Integer;
    filterCutter : Integer;
    filterSobel : Integer;
    filterSPV : Integer;
    filterStackAnalyser : Integer;
    filterEnvelope : Integer;
    filterStackCreator : Integer;
    filterStackProcessor : Integer;
    filterStackSmasher : Integer;
    filterStandardDeviation : Integer;
    filterSUSAN : Integer;
    filterThresholdBinary : Integer;
    filterWavelet : Integer;
    filterAdjust : Integer;
    filterCanny : Integer;
    filterCompare : Integer;
    filterContour : Integer;
    filterLog : Integer;
    filterLogPolar : Integer;
    filterHoughTransform : Integer;
    filterRotation : Integer;
    filterViewerToolCopy : Integer;
    filterViewerToolExplorer : Integer;
    filterIntegration : Integer;
    filterVectorHistogram : Integer;
    filterCorrelation : Integer;
    filterGradientAnisotropicDiffusion : Integer;
    filterRescaleIntensity : Integer;
    filterWaves : Integer;
    filterSigmoid : Integer;
    filterSmoothBilateral : Integer;
    filterImageCreator : Integer;
    filterImageLoader : Integer;
    filterImageSaver : Integer;
    filterProjectionLine : Integer;
    filterBlobBalance : Integer;
    filterBlobGrouping : Integer;
    filtersPlugin_Resonator : Integer;
    filtersPlugin_TestDelphi : Integer;
    filtersPlugin_TestC : Integer;
    filtersPlugin_Video : Integer;
    filtersPlugin_Video2 : Integer;
    filtersPlugin_WebCam : Integer;
    filtersPlugin_WebCam2 : Integer;
    filtersPlugin_Viewer : Integer;
    filtersPlugin_SnapShot : Integer;

    testing : boolean;
    isWavesSimpleRun : Boolean ;
    convImage : PBitmap32;
    imageIn, imageOut, imageOut2 : PBitmap32;
    imageSimulateAngle : PBitmap32;
    imageBlob : PBitmap32;
    imagesInStackAnalyser : ArrayOfPBitmap32;
    imageMask : PBitmap32;
    viewertoolImageOut : PBitmap32;
    moveROI, resizeROI : boolean;
    mouseDownX : Integer ;
    mouseDownY : Integer ;
    cameraDownX, cameraDownY, cameraDownZ : Single ;
    cameraDownRollAngle : Single ;
    moveViewerToolROI, resizeViewerToolROI : boolean;
    poi : TPoint;
    roi : TRect;
    roiViewerTool : TRect;
    panelActif : TPanel;
    image1, image2 : PBitmap32;
    application1 : TApplication1;
    application2 : TApplication2;
    bCapture : TBitmap;
    bAutotestStop : boolean;
    selectedPoint : TFPoint;
    viewertoolGlscene_mx, viewertoolGlscene_my : Integer;
    blobRepositioningLearnedAngle,blobRepositioning2LearnedAngle : Single;
    morphoSE : PBitmap32;
    _runCommand : String;
    _videoPlaying : Boolean;

    procedure setModeProd(b:boolean);
    procedure Test();
    procedure preprocessSimulateAngle( img : PBitmap32; angle : Single );
    procedure preprocessBlob( img : PBitmap32 );
    procedure preprocessStackAnalyser();
    procedure preprocessMask();
    procedure changeFilter(lb: TListBox);
    procedure setImageIn(aImage:PBitmap32);
    procedure setROI(X,Y,W,H:Integer);
    procedure setViewerToolROI(X,Y,W,H:Integer);
    procedure setLineXY(aLine:TShape;aLeft,aTop,aWidth,aHeight:Integer);
    procedure initLive;
    procedure processViewerTool;
    procedure processViewerToolPixelinfo( mouseX, mouseY : Integer );
    function calculAngleError(angleCurrent,angleOnLearn,computedAngle:Single) : Single;
    procedure updateMorphologySE();
    procedure initPanelImageCreator;
  end;

var
  MainForm: TMainForm;

implementation
uses
  Math, Chronometer, Jpeg, ShellAPI, fmask;

var
  _PROD : boolean;

{$R *.dfm}

procedure TMainForm.setModeProd(b:boolean);
begin
  _PROD:=b;
  if _PROD=true then begin
    cbFilterType.Items.Add('applications');
  end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  initialize();

  DecimalSeparator := '.';

  testing := false;
  moveROI := false;
  resizeROI := false;
  moveViewerToolROI := false;
  resizeViewerToolROI := false;

  bCapture := TBitmap.Create ;
  //bCapture.PixelFormat := pf24bit;
  bAutotestStop := false;

  Caption := 'FiltersTest '+StrPas( getVersion() )+'  -  http://filters.sourceforge.net             by filters@edurand.com and filters@burgel.com';

  // create imageIn
  setImageIn( image.createImageTest(512,512) );

  // create imageOut
  image.freeImage(imageOut);
  imageOut:=image.createImageLike(imageIn);
  image.freeImage(imageOut2);
  imageOut2:=image.createImageLike(imageIn);

  filterThresholdBinary:=createFilter('filterThresholdBinary');
  filterInvert :=  createFilter('filterInvert');
  filterResize := createFilter('filterResize');
  filterBlur :=  createFilter('filterBlur');
  filterExplorer := createFilter('filterExplorer');
  filterSobel := createFilter('filterSobel');
  filterOnOffCell := createFilter('filterOnOffCell');
  filterArithmeticConstantAdd := createFilter('filterArithmeticConstantAdd');
  filterRGB := createFilter('filterRGB');
  filterArithmeticAdd := createFilter('filterArithmeticAdd');;
  filterArithmeticSubstract := createFilter('filterArithmeticSubstract');
  filterContrastExplorer := createFilter('filterContrastExplorer');
  filterCoOccurrenceMatrix := createFilter('filterCoOccurrenceMatrix');
  filterGranularityExplorer := createFilter('filterGranularityExplorer');
  filterMorphology := createFilter('filterMorphology');
  filterStandardDeviation := createFilter('filterStandardDeviation');
  filterHistogram := createFilter('filterHistogram');
  filterWavelet := createFilter('filterHaar');
  filterPyramid := createFilter('filterPyramid');
  filterEnvelope := createFilter('filterEnvelope');
  filterStackAnalyser := createFilter('filterStackAnalyser');
  filterStackCreator := createFilter('filterStackCreator');
  filterStackProcessor := createFilter('filterStackProcessor');
  filterHistogramContrast:=createFilter('filterHistogramContrast');
  filterStackSmasher := createFilter('filterStackSmasher');
  filterBlobExplorer := createFilter('filterBlobExplorer');
  filterBlobRepositioning := createFilter('filterBlobRepositioning');
  filterBlobRepositioning2 := createFilter('filterBlobRepositioning2');;
  fRotationForSimulateAngle:=createFilter('filterRotation');
  fBlobExplorerForBlob := createFilter('filterBlobExplorer');
  filterNormalize := createFilter('filterNormalize');
  filterSUSAN := createFilter('filterSUSAN');
  filterNonMaximaSuppression := createFilter('filterNonMaximaSuppression');
  filterMeans := createFilter('filterMeans');
  filterImageInfo := createFilter('filterImageInfo');
  filterMedian := createFilter('filterMedian');
  filterCopy := createFilter('filterCopy');
  filterSPV := createFilter('filterSPV');
  filterLocalDeviation := createFilter('filterLocalDeviation');
  filterDistancesMap := createFilter('filterDistancesMap');
  filterCutter := createFilter('filterCutter');
  filterAdjust := createFilter('filterAdjust');
  filterCanny := createFilter('filterCanny');
  filterCompare := createFilter('filterCompare');
  filterContour := createFilter('filterContour');
  filterLog := createFilter('filterLog');
  filterLogPolar := createFilter('filterLogPolar');
  filterHoughTransform := createFilter('filterHoughTransform');
  filterRotation := createFilter('filterRotation');
  filterIntegration := createFilter('filterIntegration');
  filterVectorHistogram := createFilter('filterVectorHistogram');
  filterCorrelation := createFilter('filterCorrelation');
  filterGradientAnisotropicDiffusion := createFilter('filterGradientAnisotropicDiffusion');
  filterRescaleIntensity := createFilter('filterRescaleIntensity');
  filterWaves := createFilter('filterWaves');
  filterSigmoid :=createFilter('filterSigmoid');
  filterSmoothBilateral := createFilter('filterSmoothBilateral');
  filterImageCreator := createFilter('filterImageCreator');
  filterImageLoader := createFilter('filterImageLoader');
  filterImageSaver := createFilter('filterImageSaver');
  filterProjectionLine := createFilter('filterProjectionLine');
  filterBlobBalance := createFilter('filterBlobBalance');
  filterBlobGrouping := createFilter('filterBlobGrouping');

  filtersPlugin_Resonator := createFilter('filtersPlugin_Resonator');
  filtersPlugin_TestDelphi := createFilter('filtersPlugin_TestDelphi');
  filtersPlugin_TestC := createFilter('filtersPlugin_TestC');
  filtersPlugin_Video := createFilter('filtersPlugin_Video');
  filtersPlugin_Video2 := createFilter('filtersPlugin_Video');
  _videoPlaying := False;
  filtersPlugin_WebCam := createFilter('filtersPlugin_WebCam');
  filtersPlugin_WebCam2 := createFilter('filtersPlugin_WebCam');
  filtersPlugin_Viewer := createFilter('filtersPlugin_Viewer');
  filtersPlugin_SnapShot := createFilter('filtersPlugin_SnapShot');

  filterViewerToolCopy := createFilter('filterCopy');
  filterViewerToolExplorer := createFilter('filterExplorer');

  filterConvolution := createFilter('filterConvolution');
  convImage := image.createImage(3, 3) ;
  setWeight(convImage, 0, 0, -16) ;
  setWeight(convImage, 1, 0, -16) ;
  setWeight(convImage, 2, 0, -16) ;
  setWeight(convImage, 0, 1, -16) ;
  setWeight(convImage, 1, 1, 127) ;
  setWeight(convImage, 2, 1, -16) ;
  setWeight(convImage, 0, 2, -16) ;
  setWeight(convImage, 1, 2, -16) ;
  setWeight(convImage, 2, 2, -16) ;
  setParameterImage(filterConvolution,'imageConv',convImage);
  setParameterInteger(filterConvolution,'z', $1);

  isWavesSimpleRun := false ;

  imageIOVideo.showImage(convImage,ViewerImageConv);

  cbFilterTypeChange(Self);
  initLive() ;

  application1 := TApplication1.Create();
  application2 := TApplication2.Create();
  eraseImage( imageOut );
  eraseImage( imageOut2 );

  blobRepositioningLearnedAngle := 0;
  blobRepositioning2LearnedAngle := 0;

  sbHelpClick( Self );

  // tell Windows that you're accepting drag and drop files
  DragAcceptFiles( Handle, True );

  initPanelImageCreator();

  rgrpMorphoSEClick( Self );

  readCommandLine();
end;

procedure TMainForm.FormDestroy(Sender: TObject);
begin
  application1.Free();
  application2.Free();

  deleteFilter(filterBlobGrouping);
  deleteFilter(filterBlobBalance);
  deleteFilter(filterProjectionLine);
  deleteFilter(filterImageSaver);
  deleteFilter(filterImageLoader);
  deleteFilter(filterImageCreator);
  deleteFilter(filterSmoothBilateral);
  deleteFilter(filterSigmoid);
  deleteFilter(filterRescaleIntensity);
  deleteFilter(filterGradientAnisotropicDiffusion);
  deleteFilter(filterCorrelation);
  deleteFilter(filterVectorHistogram);
  deleteFilter(fBlobExplorerForBlob);
  deleteFilter(fRotationForSimulateAngle);
  deleteFilter(filterBlobRepositioning2);
  deleteFilter(filterBlobRepositioning);
  deleteFilter(filterBlobExplorer);
  deleteFilter(filterHistogramContrast);
  deleteFilter(filterHistogram);
  deleteFilter(filterStandardDeviation);
  deleteFilter(filterMorphology);
  deleteFilter(filterContrastExplorer);
  deleteFilter(filterGranularityExplorer);
  deleteFilter(filterOnOffCell);
  deleteFilter(filterSobel);
  deleteFilter(filterExplorer);
  deleteFilter(filterBlur);
  deleteFilter(filterArithmeticAdd);
  deleteFilter(filterArithmeticSubstract);
  deleteFilter(filterArithmeticConstantAdd);
  deleteFilter(filterRGB);
  deleteFilter(filterThresholdBinary);
  deleteFilter(filterInvert);
  deleteFilter(filterResize);
  deleteFilter(filterConvolution);
  deleteFilter(filterWavelet);
  deleteFilter(filterPyramid);
  deleteFilter(filterEnvelope);
  deleteFilter(filterStackAnalyser);
  deleteFilter(filterStackCreator);
  deleteFilter(filterStackProcessor);
  deleteFilter(filterStackSmasher);
  deleteFilter(filterNormalize);
  deleteFilter(filterSUSAN);
  deleteFilter(filterNonMaximaSuppression);
  deleteFilter(filterMeans);
  deleteFilter(filterImageInfo);
  deleteFilter(filterMedian);
  deleteFilter(filterCopy);
  deleteFilter(filterSPV);
  deleteFilter(filterLocalDeviation);
  deleteFilter(filterDistancesMap);
  deleteFilter(filterCutter);
  deleteFilter(filterAdjust);
  deleteFilter(filterCanny);
  deleteFilter(filterContour);
  deleteFilter(filterCompare);
  deleteFilter(filterLog);
  deleteFilter(filterLogPolar);
  deleteFilter(filterHoughTransform);
  deleteFilter(filterRotation);
  deleteFilter(filterIntegration);
  deleteFilter(filterWaves);
  deleteFilter(filterCoOccurrenceMatrix) ;
  deleteFilter(filtersPlugin_Resonator) ;
  deleteFilter(filtersPlugin_TestDelphi);
  deleteFilter(filtersPlugin_TestC);
  deleteFilter(filtersPlugin_Video);
  deleteFilter(filtersPlugin_Video2);
  deleteFilter(filtersPlugin_WebCam);
  deleteFilter(filtersPlugin_WebCam2);
  deleteFilter(filtersPlugin_Viewer);
  deleteFilter(filtersPlugin_SnapShot);

  deleteFilter(filterViewerToolCopy);
  deleteFilter(filterViewerToolExplorer);

  image.freeImage( morphoSE );
  image.freeImage( imageIn );
  image.freeImage( imageOut );
  image.freeImage( imageOut2 );
  image.freeImage( convImage );
  image.freeImage( imageSimulateAngle );
  image.freeImage( imageBlob );
  image.freeImages( @imagesInStackAnalyser );
  image.freeImage( imageMask );
  bCapture.Free;

  unInitialize();
end;

procedure TMainForm.readCommandLine();
var
  i, tmpI : integer;
begin
  if ParamCount>=1 then begin
    // we will use the ImageLoader panel
    tmpI := lbFiltersClassic.Items.IndexOf('ImageLoader');
    lbFiltersClassic.Selected[tmpI] := True;
    txtImageLoaderFiles.Text := '';
    changeFilter(lbFiltersClassic);
    for i:=1 to ParamCount do begin
      txtImageLoaderFiles.Text := txtImageLoaderFiles.Text + ParamStr(i) + ';';
    end;
    cmdImageLoaderLoad.Click();
  end;
end;

// code inspired from : http://www.chami.com/tips/delphi/111196D.html
procedure TMainForm.AcceptFiles( var msg : TMessage );
const
  cnMaxFileNameLen = 255;
var
  i,
  nCount     : integer;
  acFileName : array [0..cnMaxFileNameLen] of char;
  tmpI : Integer;
begin
  // find out how many files we're accepting
  nCount := DragQueryFile( msg.WParam, $FFFFFFFF, acFileName, cnMaxFileNameLen );
  if nCount>0 then begin
    // we will use the ImageLoader panel
    tmpI := lbFiltersClassic.Items.IndexOf('ImageLoader');
    lbFiltersClassic.Selected[tmpI] := True;
    txtImageLoaderFiles.Text := '';
    changeFilter(lbFiltersClassic);
    // query Windows one at a time for the file name
    for i := 0 to nCount-1 do begin
      DragQueryFile( msg.WParam, i, acFileName, cnMaxFileNameLen );
      // do your thing with the acFileName
      //MessageBox( Handle, acFileName, '', MB_OK );
      txtImageLoaderFiles.Text := txtImageLoaderFiles.Text + acFileName + ';';
    end;
    cmdImageLoaderLoad.Click();
  end;
  // let Windows know that you're done
  DragFinish( msg.WParam );
end;

procedure TMainForm.pnlFiltersDblClick(Sender: TObject);
begin
  setModeProd( true );
  cmdLoadVideo.Visible := True;
end;

procedure TMainForm.initLive();
var
  tmpI : integer;
  pointers : PArrayOfPointers;
  tmpStr : String;
begin
  setParameterBoolean( filtersPlugin_WebCam2, 'showViewer', False );
  runCommand( filtersPlugin_WebCam2, 'READ_DEVICES' );
  // get devices list
  pointers := getOutputArrayPointers( filtersPlugin_WebCam2, 'devices' );
  // we know that it is pointers on C string
  cbWebCamDevice.Clear();
  for tmpI:=0 to Length(pointers^)-1 do begin
    tmpStr := StrPas( pointers^[tmpI] );
    cbWebCamDevice.Items.Add( tmpStr );
  end;
end;

procedure TMainForm.setImageIn(aImage:PBitmap32);
begin
  image.freeImage( imageIn );
  imageIn := aImage;
  // show imageIn
  imageIOVideo.showImage( imageIn, ViewerImageIn );
  // show imageOut
  //imageIOVideo.showImage(imageOut,ViewerImageOut);
  //imageIOVideo.showImage(imageOut2,ViewerImageOut2);
  // show imageIn size
  imageInSize.Caption:=IntToStr(imageIn.Width)+'*'+IntToStr(imageIn.Height);
  selectedPoint.x:=imageIn.Width div 2;
  selectedPoint.y:=imageIn.Height div 2;
  // specific test
  sbExplorerX.Max := imageIn.Width-1;
  sbExplorerX.Position := Floor(selectedPoint.x);
  sbExplorerY.Max := imageIn.Height-1;
  sbExplorerY.Position := Floor(selectedPoint.y);
  sbRotationCenterX.Max:=imageIn.Width;
  sbRotationCenterX.Position:=sbRotationCenterX.Max div 2;
  sbRotationCenterY.Max:=imageIn.Height;
  sbRotationCenterY.Position:=sbRotationCenterY.Max div 2;
  // reset lineX/Y
  setLineXY(lineX,lineX.Left,0,lineX.Width,ViewerImageIn.Height);
  setLineXY(lineY,0,lineY.Top,ViewerImageIn.Width,LineY.Height);
  // image shown is set to nil
  image1 := nil;
  image2 := nil;
  //
  image.freeImages( @imagesInStackAnalyser );
  image.freeImage( imageMask );
end;

{procedure TMainForm.setImageOut(aImage:PBitmap32);
begin
  freeBitmap(imageOut);
  imageOut:=image.createImageFromImage(image);
end;}

procedure TMainForm.setLineXY(aLine:TShape;aLeft,aTop,aWidth,aHeight:Integer);
begin
  with aLine do begin
    Left:=aLeft;
    Top:=aTop;
    Width:=aWidth;
    Height:=aHeight;
    Refresh;
  end;
  poi.X := LineX.Left * imageIn.Width div ViewerImageIn.Width;
  poi.Y := LineY.Top * imageIn.Height div ViewerImageIn.Height;
end;

procedure TMainForm.cmdLoadImageClick(Sender: TObject);
Var
  fileName : String ;
begin
  if dlgOpen.Execute then Begin
    fileName := dlgOpen.FileName ;
    if extractFileExt(fileName) = '.avi' Then Begin

    end else Begin
      setImageIn(imageio.createImageFromFile(fileName));
    end ;
  end;
end;

procedure TMainForm.cmdSaveClick(Sender: TObject);
var
  fileName : String ;
  tmpImageIn : PBitmap32;
begin
  tmpImageIn:=image1;
  if tmpImageIn=nil then begin
    tmpImageIn:=imageIn;
  end;
  if dlgSave.Execute then begin
    fileName := dlgSave.FileName ;
    copyImageToFile(tmpImageIn,fileName);
  end;
end;

procedure TMainForm.cmdCopyImageOutClick(Sender: TObject);
var
  copyImage : PBitmap32;
begin
  if image1<>nil then begin
    copyImage:=image.createImageFromImage(image1);
    setImageIn(copyImage);
  end;
end;

procedure TMainForm.cmdCopyImageOut2Click(Sender: TObject);
begin
  if image2<>nil then begin
    setImageIn(image.createImageFromImage(image2));
  end;
end;

procedure TMainForm.btnVideoCaptureClick(Sender: TObject);
var
  imageOutput, aImage : PBitmap32;
begin
  run( filtersPlugin_Video2 );
  imageOutput := getOutputImage( filtersPlugin_Video2, 'outImage' );
  if imageOutput<>nil then begin
    aImage := image.createImageFromImage( imageOutput );
    setImageIn( aImage );
    Test();
  end;
end;

procedure TMainForm.btnWebCamCaptureClick(Sender: TObject);
var
  imageOutput, aImage : PBitmap32;
begin
  run( filtersPlugin_WebCam2 );
  imageOutput := getOutputImage( filtersPlugin_WebCam2, 'outImage' );
  if imageOutput<>nil then begin
    aImage := image.createImageFromImage( imageOutput );
    setImageIn( aImage );
    Test();
  end;
end;

procedure TMainForm.btnCloseClick(Sender: TObject);
begin
  Close();
end;

procedure TMainForm.Test();
var
  chrono : TChronometer;
  i, count : Integer;
  timePerRun : Integer;
  images : PArrayOfPBitmap32;
  pointers : PArrayOfPointers;
  decision : Integer;
  tmpPointer : Pointer;
  tmpI : Integer;
  tmpBlob : PBlob;
  tmpSingle : Single;
  tmpBoolean : boolean;
  tmpImage : PBitmap32;
  tmpImages : ArrayOfPBitmap32;
  tmpStr : String;
  tmpStrC : array[0..1024] of Char;
  x1, y1, x2, y2 : Integer ;
begin
 if testing=false then begin
  testing := true;
  image1:=imageOut; image2:=imageOut2;
  images:=nil;
  count:=StrToInt(txtProcessCount.Text);
  chrono:=TChronometer.Create;
  timePerRun:=0;
  for i:=1 to count do begin
    if panelActif=pAdd then begin
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,imageIn);
        image2:=imageOut2;
        chrono.Start;
        setParameterImage( filterArithmeticAdd, 'inImage1', imageIn );
        setParameterImage( filterArithmeticAdd, 'inImage2', imageOut );
        setParameterImage( filterArithmeticAdd, 'outImage', imageOut2 );
        setParameterString( filterArithmeticAdd, 'mode', cbAddMode.Text );
        run( filterArithmeticAdd );
        chrono.Stop;
    end else
    if panelActif=pBlobExplorer then begin
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterBlobExplorer, 'inImage', imageIn );
        setParameterImage( filterBlobExplorer, 'outImage', imageOut );
        setParameterBoolean( filterBlobExplorer, 'intensityInvert', chkBlobExplorerIntensityInvert.Checked );
        setParameterInteger( filterBlobExplorer, 'intensityBackground', sbBlobExplorerIntensityBackground.Position );
        setParameterInteger( filterBlobExplorer, 'intensityPrecision', sbBlobExplorerIntensityPrecision.Position );
        setParameterString( filterBlobExplorer, 'enableBlobArea', cbBlobExplorerEnableBlobArea.Text );
        setParameterInteger( filterBlobExplorer, 'blobAreaMin', StrToInt(txtBlobExplorerAreaMin.Text) );
        setParameterInteger( filterBlobExplorer, 'blobAreaMax', StrToInt(txtBlobExplorerAreaMax.Text) );
        setParameterBoolean( filterBlobExplorer, 'contour', chkBlobExplorerContour.Checked );
        setParameterBoolean( filterBlobExplorer, 'criticalPoints', chkBlobExplorerCriticalPoints.Checked );
        setParameterInteger( filterBlobExplorer, 'contourCriticalPointsAppoximationAccuracy', sbBlobExplorerCriticalPointsAppoximationAccuracy.Position );
        setParameterString( filterBlobExplorer, 'approximationMethod', cbBlobExplorerApproximationMethod.Text );
        setParameterBoolean( filterBlobExplorer, 'blobSurfaceInfo', chkBlobExplorerSurfaceInfo.Checked );
        setParameterBoolean( filterBlobExplorer, 'ignoreBlobsOnImageEdges', chkBlobExplorerIgnoreBlobsOnImageEdges.Checked );
        if cbBlobExplorerImageToShow.Text='blobs' then begin
          setParameterBoolean( filterBlobExplorer, 'monitoring', False );
        end else begin
          setParameterBoolean( filterBlobExplorer, 'monitoring', True );
        end;
        run( filterBlobExplorer);
        chrono.Stop;
        pointers := getOutputArrayPointers( filterBlobExplorer, 'blobs' );
        txtBlobExplorerNumberOfBlobs.Text := IntToStr( Length(pointers^) );
    end else
    if panelActif=pBlobRepositioning then begin
        // to test this filter, we need to do somethings
        preprocessSimulateAngle(imageIn,StrToFloat(txtBlobRepositioningSimulateAngle.Text)); // this function set 'imageSimulateAngle'
        chrono.Start;
          setParameterImage(filterBlobRepositioning,'inImage',imageSimulateAngle);
          setParameterBoolean(filterBlobRepositioning,'monitoring',chkBlobRepositioningMonitoring.Checked);
          setParameterInteger(filterBlobRepositioning,'margin', sbBlobRepositioningMargin.Position);
          tmpI:=360;
          if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=1 then tmpI:=720
          else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=2 then tmpI:=3600
          else if cbBlobRepositioningVectorhistogramAngleprecision.ItemIndex=3 then tmpI:=36000;
          setParameterInteger(filterBlobRepositioning,'blob_ThresholdBackground',sbBlobRepositioningBlobThreshold.Position);
          setParameterInteger(filterBlobRepositioning,'blob_AreaMin',StrToInt(txtBlobRepositioningBlobAreaMin.Text));
          setParameterInteger(filterBlobRepositioning,'blob_AreaMax',StrToInt(txtBlobRepositioningBlobAreaMax.Text));
          setParameterInteger(filterBlobRepositioning,'vectorHistogram_anglePrecision', tmpI);
          setParameterInteger(filterBlobRepositioning,'vectorHistogram_smooth', sbBlobRepositioningSmooth.Position);
          run(filterBlobRepositioning);
          chrono.Stop;
          image1 := getOutputImage(filterBlobRepositioning,'outImage');
          imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
          image.copyImageToImage(image1,imageOut);
          if chkBlobRepositioningMonitoring.Checked=true then begin
            images := getOutputImages(filterBlobRepositioning,'outImagesMonitoring');
            if (images<>nil) and (Length(images^)>0) then begin
              image2 := images^[cbBlobRepositioningMonitoringView.ItemIndex];
              imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
              image.copyImageToImage(image2,imageOut2);
            end;
          end;
          tmpSingle:=getOutputFloat(filterBlobRepositioning,'angleToRestorOrientation');
          txtBlobRepositioningComputedAngle.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
          tmpSingle:=calculAngleError(StrToFloat(txtBlobRepositioningSimulateAngle.Text),blobRepositioningLearnedAngle,getOutputFloat(filterBlobRepositioning,'angleToRestorOrientation'));
          txtBlobRepositioningError.Text := FloatToStrF(tmpSingle,ffFixed,4,1);
    end else
    if panelActif=pBlobRepositioning2 then begin
        // to test this filter, we need to do somethings
        preprocessSimulateAngle( imageIn, StrToFloat(txtBlobRepositioning2SimulateAngle.Text) ); // this function set 'imageSimulateAngle'
        chrono.Start;
          setParameterImage( filterBlobRepositioning2, 'inImage', imageSimulateAngle );
          setParameterBoolean( filterBlobRepositioning2, 'monitoring', chkBlobRepositioningMonitoring.Checked );
          setParameterInteger( filterBlobRepositioning2, 'margin', sbBlobRepositioning2Margin.Position );
          setParameterInteger( filterBlobRepositioning2, 'blob_ThresholdBackground', sbBlobRepositioning2BlobThreshold.Position );
          setParameterInteger( filterBlobRepositioning2, 'blob_AreaMin', StrToInt(txtBlobRepositioning2BlobAreaMin.Text) );
          setParameterInteger( filterBlobRepositioning2, 'blob_AreaMax', StrToInt(txtBlobRepositioning2BlobAreaMax.Text) );
          setParameterBoolean( filterBlobRepositioning2, 'backgroundColorBlack', chkBlobRepositioning2BackgroundColor.Checked );
          setParameterInteger( filterBlobRepositioning2, 'rotation_InterpolationMode', rdgBlobRepositioning2RotationInterpolation.ItemIndex );
          run( filterBlobRepositioning2 );
          chrono.Stop;
          image1 := getOutputImage( filterBlobRepositioning2, 'outImage' );
          imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
          image.copyImageToImage( image1, imageOut );
          if chkBlobRepositioning2Monitoring.Checked=true then begin
            images := getOutputImages( filterBlobRepositioning2, 'outImagesMonitoring' );
            if (images<>nil) and (Length(images^)>0) then begin
              image2 := images^[cbBlobRepositioning2MonitoringView.ItemIndex];
              if image2<>nil then begin
                imageOut2 := image.eraseOrCreateImageLike( imageOut2, image2 );
                image.copyImageToImage( image2, imageOut2 );
              end;
            end;
          end;
          tmpSingle := getOutputFloat( filterBlobRepositioning2, 'angleToRestorOrientation' );
          txtBlobRepositioning2ComputedAngle.Text := FloatToStrF( tmpSingle, ffFixed, 4, 1 );
          tmpSingle := calculAngleError( StrToFloat(txtBlobRepositioning2SimulateAngle.Text), blobRepositioning2LearnedAngle, getOutputFloat(filterBlobRepositioning2, 'angleToRestorOrientation') );
          txtBlobRepositioning2Error.Text := FloatToStrF( tmpSingle, ffFixed, 6, 3 );
    end else
    if panelActif=pBlur then begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterBlur, 'inImage', imageIn );
        setParameterImage( filterBlur, 'outImage', imageOut );
        setParameterInteger( filterBlur, 'mode', rdgBlurMode.ItemIndex );
        setParameterInteger( filterBlur, 'radius', sbBlurRadius.position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterBlur, @roi );
        end else begin
          unsetRegionOfInterest( filterBlur );
        end;
        run( filterBlur );
        chrono.Stop;
    end else
    if panelActif=pCellOnOff then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,imageIn);
        image2:=imageOut2;
        chrono.Start;
        setParameterImage(filterOnOffCell,'inImage',imageIn);
        setParameterImage(filterOnOffCell,'outImageON',imageOut);
        setParameterImage(filterOnOffCell,'outImageOFF',imageOut2);
        run(filterOnOffCell);
        chrono.Stop;
    end else
    if panelActif=pConstantAdd then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterArithmeticConstantAdd, 'inImage', imageIn );
        setParameterImage( filterArithmeticConstantAdd, 'outImage', imageOut );
        setParameterInteger( filterArithmeticConstantAdd, 'constant', sbConstantAdd.Position );
        setParameterString( filterArithmeticConstantAdd, 'overflowingMode', cbConstantAddOverflowingMode.Text );
        setParameterImage( filterArithmeticConstantAdd, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterArithmeticConstantAdd, @roi );
        end else begin
          unsetRegionOfInterest( filterArithmeticConstantAdd );
        end;
        run( filterArithmeticConstantAdd );
        chrono.Stop;
    end else
    if panelActif=pRGB then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterRGB, 'inImage', imageIn );
        setParameterImage( filterRGB, 'outImage', imageOut );
        setParameterInteger( filterRGB, 'constant_R', sbRGBConstantR.Position );
        setParameterInteger( filterRGB, 'constant_G', sbRGBConstantG.Position );
        setParameterInteger( filterRGB, 'constant_B', sbRGBConstantB.Position );
        setParameterString( filterRGB, 'overflowingMode', cbRGBOverflowingMode.Text );
        setParameterImage( filterRGB, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterRGB, @roi );
        end else begin
          unsetRegionOfInterest( filterRGB );
        end;
        run( filterRGB );
        chrono.Stop;
    end else
    if panelActif=pCorrelation then begin
        chrono.Start;
        setParameterImage(filterCorrelation,'inImage1',imageIn);
        setParameterImage(filterCorrelation,'inImage2',imageOut);
        setParameterInteger(filterCorrelation,'X',Floor(selectedPoint.x));
        setParameterInteger(filterCorrelation,'Y',Floor(selectedPoint.y));
        setParameterInteger(filterCorrelation,'rangeMin',sbCorrelationRangeMin.Position);
        setParameterInteger(filterCorrelation,'rangeMax',sbCorrelationRangeMax.Position);
        setParameterBoolean(filterCorrelation,'monitoring',chkCorrelationMonitoring.Checked);
        run(filterCorrelation);
        chrono.Stop;
        txtCorrelationCorrelation.Text:=FloatToStr(getOutputFloat(filterCorrelation,'correlation'));
        image2:=getOutputImage(filterCorrelation,'outImageMonitoring');
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
        image.copyImageToImage(image2,imageOut2);
    end else
    if panelActif=pContrastExplorer then begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterContrastExplorer, 'inImage', imageIn );
        setParameterImage( filterContrastExplorer, 'outImage', imageOut );
        setParameterInteger( filterContrastExplorer, 'precision', sbContrastExplorerPrecision.Position );
        setParameterString( filterContrastExplorer, 'mode', cbContrastExplorerMode.Text );
        run( filterContrastExplorer );
        chrono.Stop;
    end else
    if panelActif=pConvolutions then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterConvolution,'inImage',imageIn);
        setParameterImage(filterConvolution,'outImage',imageOut);
        if lstConvType.ItemIndex>=0 then begin
          setParameterString(filterConvolution,'convType',lstConvType.items[lstConvType.ItemIndex]);
        end;
        run(filterConvolution);
        chrono.Stop;
    end else
    if panelActif=pCopy then begin
        preprocessMask(); // for imageMask
        chrono.Start;
        setParameterImage( filterCopy, 'inImage', imageIn );
        setParameterString( filterCopy, 'outputColor', cbCopyOutputColor.Text );
        setParameterImage( filterCopy, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterCopy, @roi );
        end else begin
          unsetRegionOfInterest( filterCopy );
        end;
        run( filterCopy );
        chrono.Stop;
        image1 := getOutputImage( filterCopy, 'outImage' );
        imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
    end else
    if panelActif=pCutter then begin
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,imageIn);
        image2:=imageOut2;
        chrono.Start;
        txtCutterOutimageIndex.Text:='';
        setParameterImage(filterCutter,'inImage',imageIn);
        setParameterImage(filterCutter,'outImageMonitoring',imageOut2);
        setParameterString(filterCutter,'type', cbCutterType.Text);
        setParameterInteger(filterCutter,'margin',sbCutterMargin.Position);
        if cbCutterType.Text='TILES' then begin
          setParameterInteger(filterCutter,'cutterTiles_RectWidth', sbCutterRectWidth.Position) ;
          setParameterInteger(filterCutter,'cutterTiles_RectHeight', sbCutterRectHeight.Position) ;
        end else
        if cbCutterType.Text='BLOB' then begin
          setParameterInteger(filterCutter,'cutterBlob_ThresholdBackground', sbCutterBlobBackground.Position);
          setParameterInteger(filterCutter,'cutterBlob_AreaMin', StrToInt(txtCutterBlobAreaMin.Text));
          setParameterInteger(filterCutter,'cutterBlob_AreaMax', StrToInt(txtCutterBlobAreaMax.Text));
          setParameterBoolean(filterCutter,'cutterBlob_Clean', chkCutterBlobClean.Checked);
          setParameterBoolean(filterCutter,'cutterBlob_UseBlobRepositioning', chkCutterBlobUseblobrepositioning.Checked);
        end;
        setParameterBoolean(filterCutter,'monitoring',chkCutterMonitoring.Checked);
        run(filterCutter);
        chrono.Stop;
        images := getOutputImages(filterCutter,'outImages');
        if images<>nil then begin
          if Length(images^)>0 then begin
            sbCutterOutImages.Max := Length(images^)-1 ;
          end else begin
            sbCutterOutImages.Max := 0;
          end;
          if sbCutterOutImages.position>=length(images^) then begin
            sbCutterOutImages.position:=0;
          end;
          if Length(images^)>0 then begin
            image1 := images^[sbCutterOutImages.position];
            imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
            image.copyImageToImage(image1,imageOut);
            sbCutterOutImagesChange(Self);
          end;
        end;
    end else
    if panelActif=pDistancesMap then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterDistancesMap,'inImage',imageIn);
        setParameterImage(filterDistancesMap,'outImage',imageOut);
        setParameterBoolean(filterDistancesMap,'preprocessInvert', chkDistanceMapPreInvert.Checked);
        setParameterInteger(filterDistancesMap,'scale', sbDistanceMapScale.Position) ;
        run(filterDistancesMap);
        chrono.Stop;
        lblMaxEDM.Text := IntToStr(getOutputInteger(filterDistancesMap,'maxEDM')) ;
    end else
    if panelActif=pExplorer then begin
        chrono.Start;
        setParameterImage( filterExplorer, 'inImage', imageIn );
        setParameterInteger( filterExplorer, 'X', Round(poi.x) );
        setParameterInteger( filterExplorer, 'Y', Round(poi.y) );
        setParameterInteger( filterExplorer, 'precision', sbExplorerPrecision.Position );
        run( filterExplorer );
        chrono.Stop;
        images := getOutputImages( filterExplorer, 'outImages' );
        image1 := images^[0];
        imageOut:=image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
        image2 := images^[1];
        imageOut2:=image.eraseOrCreateImageLike( imageOut2, image2 );
        image.copyImageToImage( image2, imageOut2 );
    end else
    if panelActif=pGranularityExplorer then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterGranularityExplorer, 'inImage', imageIn );
        setParameterImage( filterGranularityExplorer, 'outImage', imageOut );
        setParameterImage( filterGranularityExplorer, 'mask', imageMask );
        setParameterInteger( filterGranularityExplorer, 'precision', sbGranularityExplorerPrecision.Position );
        setParameterInteger( filterGranularityExplorer, 'sensibility', sbGranularityExplorerSensibility.Position );
        setParameterInteger( filterGranularityExplorer, 'differenceThreshold', sbGranularityExplorerDifferenceThreshold.Position );
        run( filterGranularityExplorer );
        chrono.Stop;
    end else
    if panelActif=pHistogram then begin
        chrono.Start;
        setParameterImage(filterHistogram,'inImage',imageIn);
        setParameterString(filterHistogram,'normalize',cbHistogramNormalize.Text);
        setParameterString(filterHistogram,'show','TRUE');
        setParameterInteger(filterHistogram,'precision',sbHistogramPrecision.Position);
        setParameterInteger(filterHistogram,'feature', cbHistogramFeature.ItemIndex);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterHistogram, @roi );
        end else begin
          unsetRegionOfInterest(filterHistogram);
        end;
        run(filterHistogram);
        chrono.Stop;
        images := getOutputImages(filterHistogram,'outImages');
        image1 := images^[0];
        imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
        image.copyImageToImage(image1,imageOut);
    end else
    if panelActif=pHistogramContrast then begin
        chrono.Start;
        setParameterImage(filterHistogramContrast,'inImage',imageIn);
        setParameterString(filterHistogramContrast,'mode',cbHistogramContrastMode.Text);
        setParameterInteger(filterHistogramContrast,'rectangleWidth',sbHistogramContrastRectangleWidth.Position);
        setParameterInteger(filterHistogramContrast,'rectangleHeight',sbHistogramContrastRectangleHeight.Position);
        setParameterInteger(filterHistogramContrast,'gridSpacingWidth',sbHistogramContrastGridSpacingWidth.Position);
        setParameterInteger(filterHistogramContrast,'gridSpacingHeight',sbHistogramContrastGridSpacingHeight.Position);
        setParameterInteger(filterHistogramContrast,'precision',sbHistogramContrastPrecision.Position);
        setParameterInteger(filterHistogramContrast,'blurIteration',sbHistogramContrastBlur.Position);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest(filterHistogramContrast,@roi);
        end else begin
          unsetRegionOfInterest(filterHistogramContrast);
        end;
        run(filterHistogramContrast);
        chrono.Stop;
        images := getOutputImages(filterHistogramContrast,'outImages');
        image1 := images^[0];
        imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
        image.copyImageToImage(image1,imageOut);
        image2 := images^[1];
        if image2<>nil then begin
          imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
          image.copyImageToImage(image2,imageOut2);
        end;
    end else
    if panelActif=pInvert then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterInvert,'inImage',imageIn);
        setParameterImage(filterInvert,'outImage',imageOut);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest(filterInvert,@roi);
        end else begin
          unsetRegionOfInterest(filterInvert);
        end;
        run(filterInvert);
        chrono.Stop;
    end else
    if panelActif=pMeans then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterMeans, 'inImage', imageIn );
        setParameterImage( filterMeans, 'outImage', imageOut );
        setParameterImage( filterMeans, 'mask', imageMask );
        setParameterInteger( filterMeans, 'precision', sbMeansPrecision.Position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterMeans, @roi );
        end else begin
          unsetRegionOfInterest( filterMeans );
        end;
        run( filterMeans );
        chrono.Stop;
    end else
    if panelActif=pMedian then begin
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterMedian, 'inImage', imageIn );
        setParameterImage( filterMedian, 'outImage', imageOut );
        setParameterInteger( filterMedian, 'precision', sbMedian.Position );
        run( filterMedian );
        chrono.Stop;
    end else
    if panelActif=pMorphology then begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterMorphology, 'inImage', imageIn );
        setParameterImage( filterMorphology, 'outImage', imageOut );
        setParameterImage( filterMorphology, 'structuredElementImage', morphoSE );
        setParameterInteger( filterMorphology, 'iteration', sbMorphologyIteration.Position );
        if lstMorphologyType.ItemIndex>=0 then begin
          setParameterString( filterMorphology, 'type', lstMorphologyType.Items[lstMorphologyType.ItemIndex] );
        end;
        run( filterMorphology );
        chrono.Stop;
    end else
    if panelActif=pNonMaximaSuppression then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterNonMaximaSuppression, 'inImage', imageIn );
        setParameterImage( filterNonMaximaSuppression, 'outImage', imageOut );
        setParameterString( filterNonMaximaSuppression, 'outputColor', cbNonMaximaSuppressionOutputColor.Text );
        setParameterInteger( filterNonMaximaSuppression, 'gain', sbNonMaximaSuppressionGain.Position );
        setParameterImage( filterNonMaximaSuppression, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterNonMaximaSuppression, @roi );
        end else begin
          unsetRegionOfInterest( filterNonMaximaSuppression );
        end;
        run( filterNonMaximaSuppression );
        chrono.Stop;
    end else
    if panelActif=pPyramid then begin
        chrono.Start;
        setParameterImage( filterPyramid, 'inImage', imageIn );
        run( filterPyramid );
        images := getOutputImages( filterPyramid, 'outImages' );

        if (images<>nil) and (Length(images^)>0) then begin
          sbPyramidNormalisation.Max := Length(images^);
          // Normalize ?
          if chkPyramidNormalize.Checked=true then Begin
            imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
            setParameterImage( filterNormalize, 'inImage', imageIn );
            image2 := images^[sbPyramidNormalisation.Max-sbPyramidNormalisation.Position];
            imageOut2 := image.eraseOrCreateImageLike( imageOut2, image2 );
            image.copyImageToImage( image2, imageOut2 );
            setParameterImage( filterNormalize, 'refImage', image2 );
            setParameterImage( filterNormalize, 'outImage', imageOut );
            run( filterNormalize );
            setParameterImage( filterPyramid, 'inImage', imageOut );
            run( filterPyramid );
            images := getOutputImages( filterPyramid, 'outImages' );
          end;
        end;

        // StackProcessor ?
        tmpStr := lstPyramidFilter.Items[lstPyramidFilter.ItemIndex] ;
        if tmpStr = 'ContrastExplorer' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterContrastExplorer) );
        end else if tmpStr = 'Blur' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterBlur) );
        end else if tmpStr = 'StandardDeviation' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterStandardDeviation) );
        end else if tmpStr = 'Convolution' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterConvolution) );
        end else if tmpStr = 'GranularityExplorer' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterGranularityExplorer) );
        end else if tmpStr = 'Sobel' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterSobel) );
        end else if tmpStr = 'Susan' then begin
          setParameterPointer( filterStackProcessor, 'filter', Pointer(filterSusan) );
        end else begin
          setParameterPointer( filterStackProcessor, 'filter',nil);
        end;
        setParameterImages( filterStackProcessor, 'inImages', images );
        run( filterStackProcessor );
        images := getOutputImages( filterStackProcessor, 'outImages' );

        if (images<>nil) and (Length(images^)>0) then begin
          sbPyramidNormalisation.Max := Length(images^)-1 ;
          // StackSmasher ?
          if chkPyramidSmasher.Checked Then Begin
            setParameterImages( filterStackSmasher, 'inImages', images );
            run( filterStackSmasher );
            image1 := getOutputImage( filterStackSmasher, 'outImage' );
            sbPyramid.Enabled := false;
          end else Begin
            sbPyramid.Max := Length(images^)-1 ;
            image1 := images^[sbPyramid.position];
            sbPyramid.Enabled := true ;
          End ;
        end;

        chrono.Stop;
        imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
        image.copyImageToImage(image1,imageOut);
    end else
    if panelActif=pEnvelope then begin
        preprocessMask(); // for imageMask
        chrono.Start;
        setParameterImage( filterEnvelope, 'inImage', imageIn );
        setParameterImage( filterEnvelope, 'mask', imageMask );
        setParameterInteger( filterEnvelope, 'smooth', sbEnvelopeSmooth.Position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterEnvelope, @roi );
        end else begin
          unsetRegionOfInterest( filterEnvelope );
        end;
        run( filterEnvelope );
        chrono.Stop;
        if lstEnvelopeOutputs.ItemIndex<0 then lstEnvelopeOutputs.ItemIndex := 0;
        lstEnvelopeOutputsClick( Self );
    end else
    if panelActif=pStackAnalyser then begin
        preprocessStackAnalyser();
        chrono.Start;
        setParameterImages( filterStackAnalyser, 'inImages', @imagesInStackAnalyser );
        setParameterImage( filterStackAnalyser, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterStackAnalyser, @roi );
        end else begin
          unsetRegionOfInterest( filterStackAnalyser );
        end;
        run( filterStackAnalyser );
        chrono.Stop;
        if lstStackAnalyserAnalyse.ItemIndex<0 then lstStackAnalyserAnalyse.ItemIndex := 0;
        lstStackAnalyserAnalyseClick( Self );
        sbStackAnalyserInImagesChange( Self );
    end else
    if panelActif=pStackCreator then begin
        chrono.Start;
        setParameterImage( filterStackCreator, 'inImage', imageIn );
        setParameterInteger( filterStackCreator, 'count', sbStackCreatorStackSize.Position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterStackCreator, @roi );
        end else begin
          unsetRegionOfInterest( filterStackCreator );
        end;
        run( filterStackCreator );
        chrono.Stop;
        sbStackCreatorImageIndexChange( Self );
        // and we use stackAnalyser for the demo
        if chkStackCreatorDemoStackAnalyser.Checked=True then begin
          images := getOutputImages( filterStackCreator, 'outImages' );
          setParameterImages( filterStackAnalyser, 'inImages', images );
          setParameterImage( filterStackAnalyser, 'mask', imageMask );
          if chkUseROI.Checked=true then begin
            setRegionOfInterest( filterStackAnalyser, @roi );
          end else begin
            unsetRegionOfInterest( filterStackAnalyser );
          end;
          run( filterStackAnalyser );
          images := getOutputImages( filterStackAnalyser, 'outImages' );
          if (images<>nil) then begin
            tmpI := lstStackAnalyserAnalyse.ItemIndex;
            if tmpI<0 then tmpI := 0;
            image2 := images^[tmpI];
            if image2 <> nil Then Begin
              imageOut2 := image.eraseOrCreateImageLike( imageOut2, image2 );
              image.copyImageToImage( image2, imageOut2 );
            end;
          end;
        end;
    end else
    if panelActif=pResize then begin
        tmpSingle:=sbResizeScale.Position/100;
        image.freeImage(imageOut);
        imageOut:=image.createImage(round(imageIn.Width * tmpSingle), round(imageIn.Height * tmpSingle));
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterResize,'inImage',imageIn);
        setParameterImage(filterResize,'outImage',imageOut);
        setParameterInteger(filterResize,'mode', cbResizeMode.ItemIndex);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest(filterResize,@roi);
        end else begin
          unsetRegionOfInterest(filterResize,);
        end;
        run(filterResize);
        chrono.Stop;
    end else
    if panelActif=pSobel then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        imageOut2 := image.eraseOrCreateImageLike( imageOut2, imageIn );
        image2 := imageOut2;
        chrono.Start;
        setParameterImage( filterSobel, 'inImage', imageIn );
        setParameterImage( filterSobel, 'outImage', imageOut );
        setParameterImage( filterSobel, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterSobel, @roi );
        end else begin
          unsetRegionOfInterest( filterSobel );
        end;
        if chkSobelAngleCalculation.Checked=True then begin
          tmpImage := image.eraseOrCreateImageLike( tmpImage, imageIn );
          setParameterImage( filterSobel, 'outImageAngle', tmpImage );
          setParameterImage( filterSobel, 'outImageAngleMonitoring', imageOut2 );
        end else begin
          tmpImage := nil;
          setParameterImage( filterSobel, 'outImageAngle', nil );
          setParameterImage( filterSobel, 'outImageAngleMonitoring', nil );
        end;
        setParameterInteger( filterSobel, 'blurIteration', sbSobelBlurIteration.Position );
        setParameterInteger( filterSobel, 'gain', sbSobelGain.Position );
        setParameterInteger( filterSobel, 'thresholdLower', sbSobelThresholdLower.Position );
        setParameterInteger( filterSobel, 'thresholdUpper', sbSobelThresholdUpper.Position );
        setParameterString( filterSobel, 'modeFast', cbSobelModeFast.Text );
        run( filterSobel );
        chrono.Stop;
        if tmpImage<>nil then begin
          image.freeImage( tmpImage );
        end;
    end else
    if panelActif=pSPV then begin
        chrono.Start;
        setParameterImage(filterSPV,'inImage',imageIn);
        setParameterInteger(filterSPV,'backgroundThreshold',sbSPVBackground.Position);
        setParameterInteger(filterSPV,'scanLineIncrement',sbSPVScanLineIncrement.Position);
        setParameterInteger(filterSPV,'maximalTrackingStep',sbSPVmaximalTrackingStep.Position);
        setParameterInteger(filterSPV,'maximalTrackingCycles',sbSPVmaximalTrackingCycles.Position);
        setParameterString(filterSPV,'monitoring',cbSPVmonitoring.Text);
        setParameterString(filterSPV,'showVectorWidth',cbSPVShowVectorWidth.Text);
        setParameterString(filterSPV,'showConnectedVector',cbSPVShowConnectedVector.Text);
        setParameterInteger(filterSPV,'polygonalApproximationEpsilone',sbSPVpolygonalApproximationEpsilone.Position);
        run(filterSPV);
        chrono.Stop;
        images := getOutputImages(filterSPV,'outImages');
        image1 := images^[0];
        imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
        image.copyImageToImage(image1,imageOut);
        image2 := images^[1];
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
        image.copyImageToImage(image2,imageOut2);
    end else
    if panelActif=pStandardDeviation then begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterStandardDeviation, 'inImage', imageIn );
        setParameterImage( filterStandardDeviation, 'outImage', imageOut );
        setParameterInteger( filterStandardDeviation, 'percentStandardDeviation', sbPercentStandardDeviation.Position );
        setParameterString( filterStandardDeviation, 'outputColor', cbStandardDeviationOutputColor.Text );
        setParameterBoolean( filterStandardDeviation, 'showOnlyROI', chkStandardDeviationShowOnlyROI.Checked );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterStandardDeviation, @roi );
        end else begin
          unsetRegionOfInterest( filterStandardDeviation );
        end;
        run( filterStandardDeviation );
        chrono.Stop;
    end else
    if panelActif=pSubstract then begin
        preprocessMask(); // for imageMask
        imageOut2 := image.eraseOrCreateImageLike( imageOut2, imageIn );
        image2 := imageOut2;
        chrono.Start;
        setParameterImage( filterArithmeticSubstract, 'inImage1', imageIn );
        setParameterImage( filterArithmeticSubstract, 'inImage2', imageOut );
        setParameterImage( filterArithmeticSubstract, 'outImage', imageOut2 );
        setParameterImage( filterArithmeticSubstract, 'mask', imageMask );
        setParameterString( filterArithmeticSubstract, 'mode', cbSubstractMode.Text );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterArithmeticSubstract, @roi );
        end else begin
          unsetRegionOfInterest( filterArithmeticSubstract );
        end;
        run( filterArithmeticSubstract );
        chrono.Stop;
        txtSubstractDeltaTotal.Text := IntToStr( getOutputInteger( filterArithmeticSubstract, 'deltaTotal' ) );
        txtSubstractDeltaTotalNormalized.Text := FloatToStrF( getOutputFloat( filterArithmeticSubstract, 'deltaTotalNormalized' ),ffFixed,5,2 );
    end else
    if panelActif=pSUSAN then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        imageOut2 := image.eraseOrCreateImageLike( imageOut2, imageIn );
        image2 := imageOut2;
        chrono.Start;
        setParameterImage( filterSusan, 'inImage', imageIn );
        setParameterImage( filterSusan, 'outImage', imageOut );
        setParameterImage( filterSusan, 'mask', imageMask );
        if chkSusanAngleCalculation.Checked=True then begin
          tmpImage := image.eraseOrCreateImageLike( tmpImage, imageIn );
          setParameterImage( filterSusan, 'outImageAngle', tmpImage );
          setParameterImage( filterSusan, 'outImageAngleMonitoring', imageOut2 );
        end else begin
          tmpImage := nil;
          setParameterImage( filterSusan, 'outImageAngle', nil );
          setParameterImage( filterSusan, 'outImageAngleMonitoring', nil );
        end;
        setParameterString( filterSusan, 'mode', cbSUSANmode.Text );
        setParameterString( filterSusan, 'maskType', cbSUSANmasktype.Text );
        setParameterInteger( filterSusan, 'precision', sbSUSANprecision.Position );
        setParameterInteger( filterSusan, 'pixelBrightnessDifferenceThreshold', sbSUSANpixelBrightnessDifferenceThreshold.Position);
        setParameterInteger( filterSusan, 'pixelCentroidDifferenceThreshold', sbSUSANpixelCentroidDifferenceThreshold.Position );
        setParameterInteger( filterSusan, 'gain', sbSusanGain.Position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterSusan, @roi );
        end else begin
          unsetRegionOfInterest( filterSusan );
        end;
        run( filterSusan );
        chrono.Stop;
        if tmpImage<>nil then begin
          image.freeImage( tmpImage );
        end;
    end else
    if panelActif=pThresholdBinary then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterThresholdBinary, 'inImage', imageIn );
        setParameterImage( filterThresholdBinary, 'outImage', imageOut );
        setParameterInteger( filterThresholdBinary, 'thresholdLower', sbThresholdBinaryLower.Position );
        setParameterInteger( filterThresholdBinary, 'thresholdUpper', sbThresholdBinaryUpper.Position );
        setParameterInteger( filterThresholdBinary, 'lowcolor', rdgLow.ItemIndex );
        setParameterInteger( filterThresholdBinary, 'middlecolor', rdgMiddle.ItemIndex );
        setParameterInteger( filterThresholdBinary, 'highcolor', rdgHigh.ItemIndex );
        setParameterImage( filterThresholdBinary, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterThresholdBinary, @roi );
        end else begin
          unsetRegionOfInterest( filterThresholdBinary );
        end;
        run( filterThresholdBinary );
        chrono.Stop;
    end else
    if panelActif=pVectorHistogram then begin
        preprocessSimulateAngle(imageIn,StrToFloat(txtVectorHistogramPreprocessingAngle.Text)); // this function set 'imageSimulateAngle'
        preprocessBlob(imageSimulateAngle); // this function set 'imageBlob'
        // monitoring
        image2 := imageBlob;
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
        image.copyImageToImage(image2,imageOut2);
        pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
        tmpI:=Length(pointers^)-1;
        if tmpI>=0 then begin
          sbVectorHistogramBlobNumero.Max:=tmpI;
          sbVectorHistogramBlobNumero.Visible:=True;
          txtVectorHistogramBlobNumero.Text:=IntToStr(sbVectorHistogramBlobNumero.position+1)+'/'+IntToStr(sbVectorHistogramBlobNumero.Max+1);
        end else begin
          sbVectorHistogramBlobNumero.Visible:=False;
          txtVectorHistogramBlobNumero.Text:='';
          Application.MessageBox('Before using this filter, you must use filter BlobExplorer to obtain a blob', 'Information', MB_OK);
        end;
        chrono.Start;
        if sbVectorHistogramBlobNumero.Visible=True then begin
          tmpI:=sbVectorHistogramBlobNumero.Position;
          pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
          tmpBlob:=pointers^[tmpI];
          tmpPointer:=tmpBlob.vectorChain;
          setParameterPointer(filterVectorHistogram,'vectorArray',tmpPointer);
          tmpI:=360;
          if cbVectorHistogramAngleprecision.ItemIndex=1 then tmpI:=720
          else if cbVectorHistogramAngleprecision.ItemIndex=2 then tmpI:=3600
          else if cbVectorHistogramAngleprecision.ItemIndex=3 then tmpI:=36000;
          setParameterInteger(filterVectorHistogram,'anglePrecision', tmpI);
          setParameterInteger(filterVectorHistogram,'smooth', sbVectorHistogramSmooth.Position);
          run(filterVectorHistogram);
          chrono.Stop;
          image1 := getOutputImage(filterVectorHistogram,'outImage');
          imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
          image.copyImageToImage(image1,imageOut);
        end;
    end else
    if panelActif=pProjectionLine then begin
        tmpBoolean:=false;
        preprocessSimulateAngle(imageIn,StrToFloat(txtProjectionLinePreprocessingSimulateAngle.Text)); // this function set 'imageSimulateAngle'
        if rgProjectionLineInput.ItemIndex=1 then begin
          setParameterString(filterProjectionLine,'inputType','SEGMENTS');
          preprocessBlob(imageSimulateAngle); // this function set 'imageBlob'
          pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
          tmpI:=Length(pointers^)-1;
          if tmpI>=0 then begin
            sbProjectionLinePreprocessingBlobIndex.Max:=tmpI;
            sbProjectionLinePreprocessingBlobIndex.Visible:=True;
            txtProjectionLinePreprocessingBlobIndex.Text:=IntToStr(sbProjectionLinePreprocessingBlobIndex.position+1)+'/'+IntToStr(sbProjectionLinePreprocessingBlobIndex.Max+1);
          end else begin
            sbProjectionLinePreprocessingBlobIndex.Visible:=False;
            txtProjectionLinePreprocessingBlobIndex.Text:='';
            Application.MessageBox('Before using this filter, you must use filter BlobExplorer to obtain a blob', 'Information', MB_OK);
          end;
          if sbProjectionLinePreprocessingBlobIndex.Visible=True then begin
            tmpBoolean:=true;
            tmpI:=sbProjectionLinePreprocessingBlobIndex.Position;
            pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
            tmpBlob := pointers^[tmpI];
            tmpPointer:=tmpBlob.segmentList;
            setParameterPointer(filterProjectionLine,'segmentArray',tmpPointer);
            // monitoring
            image2:=imageBlob;
            imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
            image.copyImageToImage(image2,imageOut2);
          end;
        end else begin
          setParameterString(filterProjectionLine,'inputType','IMAGE');
          setParameterImage(filterProjectionLine,'inImage',imageSimulateAngle);
          tmpBoolean:=true;
          // monitoring
          image2:=imageSimulateAngle;
          imageOut2:=image.eraseOrCreateImageLike(imageOut2,image2);
          image.copyImageToImage(image2,imageOut2);
        end;
        chrono.Start;
        if tmpBoolean=true then begin
          setParameterInteger(filterProjectionLine,'smooth', sbProjectionLineSmooth.Position);
          run(filterProjectionLine);
          chrono.Stop;
          txtProjectionLineMaximum.Text:=FloatToStrF(getOutputFloat(filterProjectionLine,'maximum'),ffFixed,6,3);
          image1 := getOutputImage(filterProjectionLine,'outImage');
          imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
          image.copyImageToImage(image1,imageOut);
        end;
    end else
    if panelActif=pBlobBalance then begin
        preprocessSimulateAngle(imageIn,StrToFloat(txtBlobBalancePreprocessingAngle.Text)); // this function set 'imageSimulateAngle'
        preprocessBlob(imageSimulateAngle); // this function set 'imageBlob'
        pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
        tmpI:=Length(pointers^)-1;
        if tmpI>=0 then begin
          sbBlobBalancePreprocessingBlobIndex.Max:=tmpI;
          sbBlobBalancePreprocessingBlobIndex.Visible:=True;
          txtBlobBalancePreprocessingBlobIndex.Text:=IntToStr(sbBlobBalancePreprocessingBlobIndex.position+1)+'/'+IntToStr(sbBlobBalancePreprocessingBlobIndex.Max+1);
        end else begin
          sbBlobBalancePreprocessingBlobIndex.Visible:=False;
          txtBlobBalancePreprocessingBlobIndex.Text:='';
          Application.MessageBox('Before using this filter, you must use filter BlobExplorer to obtain a blob', 'Information', MB_OK);
        end;
        if sbBlobBalancePreprocessingBlobIndex.Visible=True then begin
          tmpI:=sbBlobBalancePreprocessingBlobIndex.Position;
          pointers := getOutputArrayPointers(fBlobExplorerForBlob,'blobs');
          tmpBlob := pointers^[tmpI];
          tmpPointer:=tmpBlob;
          setParameterPointer(filterBlobBalance,'blob',tmpPointer);
          // monitoring
          imageOut:=image.eraseOrCreateImageLike(imageOut,imageBlob);
          image1:=imageOut;
          setParameterImage(filterBlobBalance,'outImageMonitoring',imageOut);
          setParameterImage(filterBlobBalance,'blobImage',imageBlob);
          setParameterBoolean(filterBlobBalance,'monitoring',chkBlobBalanceMonitoring.Checked);
          chrono.Start;
          run(filterBlobBalance);
          txtBlobBalanceAngle.Text:=FloatToStrF(getOutputFloat(filterBlobBalance,'angle'),ffFixed,5,2);
          chrono.Stop;
        end;
    end else
    if panelActif=pBlobGrouping then begin
        pointers := getOutputArrayPointers(filterBlobExplorer,'blobs');
        tmpI:=Length(pointers^)-1;
        if tmpI>=0 then begin
          imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
          image1 := imageOut;
          setParameterImage( filterBlobGrouping,'inImage', imageIn);
          setParameterImage( filterBlobGrouping,'outImage', imageOut) ;
          setParameterPointer( filterBlobGrouping,'filterBlobExplorer', Pointer(filterBlobExplorer));
          setParameterInteger( filterBlobGrouping, 'intensityPrecision', sbBlobGroupingIntensityPrecision.Position );
          chrono.Start;
          run( filterBlobGrouping );
          chrono.Stop;
        end else begin
          Application.MessageBox('Before using this filter, you must use filter BlobExplorer to obtain some blobs', 'Information', MB_OK);
        end;
    end else
    if panelActif=pWavelets then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterWavelet,'inImage', imageIn);
        setParameterImage(filterWavelet,'outImage', imageOut) ;
        setParameterBoolean(filterWavelet,'invert', chkWaveletsInverse.Checked);
        run(filterWavelet);
        chrono.Stop;
    end else
    if panelActif=pWaves then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        if not isWavesSimpleRun then begin
          setParameterImage(filterWaves,'inImage', imageIn);
        end;
        setParameterImage(filterWaves,'outImage', imageOut) ;
        run(filterWaves) ;
        cmdWavesStep.Enabled := true ;
        chrono.Stop;
    end else
    if panelActif=pIntegration then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterIntegration,'inImage',imageIn);
        setParameterImage(filterIntegration,'outImage',imageOut);
        setParameterFloat(filterIntegration,'scale', sbIntegrationScale.Position/1000);
        setParameterFloat(filterIntegration,'offset', sbIntegrationOffset.Position);
        run(filterIntegration);
        chrono.Stop;
    end else
    if panelActif=pLocalDeviation then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterLocalDeviation,'inImage',imageIn);
        setParameterImage(filterLocalDeviation,'outImage',imageOut);
        setParameterInteger(filterLocalDeviation,'percentLocalDeviation',sbPercentLocalDeviation.Position);
        setParameterInteger(filterLocalDeviation,'localDeviationSize',sbLocalDeviationSize.Position);
        //setParameterString(filterLocalDeviation,'outputColor',cbLocalDeviationOutputColor.Text);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest(filterLocalDeviation,@roi);
        end else begin
          unsetRegionOfInterest(filterLocalDeviation);
        end;
        run(filterLocalDeviation);
        chrono.Stop;
    end else
    if panelActif=pApplication1 then begin
      imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
      image1:=imageOut;
      chrono.Start;
      application1.setInImage(imageIn);
      application1.setDefaultAreaMin(sbApplication1DefectAreaMin.Position);
      application1.setMinNumberOfDefectsForOK(sbApplication1MinNumberOfDefectsForOK.Position);
      application1.setMaxNumberOfDefectsForNG(sbApplication1MaxNumberOfDefectsForNG.Position);
      application1.Run;
      chrono.Stop;
      image.copyImageToImage(application1.getOutImage(),imageOut);
      txtApplication1NumberOfDefects.Text:=IntToStr(application1.getNumberOfDefects());
      decision:=application1.getDecision();
      if decision=1 then shapeApplication1Decision.Brush.Color:=clLime
      else if decision=0 then shapeApplication1Decision.Brush.Color:=clYellow
      else shapeApplication1Decision.Brush.Color:=clRed;
    end else
    if panelActif=pApplication2 then begin
      imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
      image1:=imageOut;
      chrono.Start;
      application2.setInImage(imageIn);
      application2.setDefaultAreaMin(sbApplication2DefectAreaMin.Position);
      application2.Run;
      chrono.Stop;
      image.copyImageToImage(application2.getOutImage(),imageOut);
    end else
    if panelActif=pCanny then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterCanny,'inImage',imageIn);
        setParameterImage(filterCanny,'outImage',imageOut);
        setParameterInteger(filterCanny,'threshold1',sbCannyThreshold1.Position);
        setParameterInteger(filterCanny,'threshold2',sbCannyThreshold2.Position);
        run(filterCanny);
        chrono.Stop;
    end else
    if panelActif=pGradientAnisotropicDiffusion then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterGradientAnisotropicDiffusion,'inImage',imageIn);
        setParameterImage(filterGradientAnisotropicDiffusion,'outImage',imageOut);
        setParameterFloat(filterGradientAnisotropicDiffusion,'conductance',sbGradientAnisotropicDiffusionConductance.Position/10);
        setParameterInteger(filterGradientAnisotropicDiffusion,'iteration',sbGradientAnisotropicDiffusionIteration.Position);
        if cbGradientAnisotropicDiffusionMethod.ItemIndex=1 then setParameterString(filterGradientAnisotropicDiffusion,'method', 'STANDARD_GREY_LEVEL')
        else if cbGradientAnisotropicDiffusionMethod.ItemIndex=2 then setParameterString(filterGradientAnisotropicDiffusion,'method', 'STANDARD_RGB')
        else setParameterString(filterGradientAnisotropicDiffusion,'method', 'FAST_BLUR_ANISOTROPIC');
        run(filterGradientAnisotropicDiffusion);
        chrono.Stop;
    end else
    if panelActif=pBilateral then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterSmoothBilateral,'inImage',imageIn);
        setParameterImage(filterSmoothBilateral,'outImage',imageOut);
        setParameterFloat(filterSmoothBilateral,'domainSigma',sbBilateralDomainsigma.Position/10);
        setParameterFloat(filterSmoothBilateral,'rangeSigma',sbBilateralRangesigma.Position/10);
        run(filterSmoothBilateral);
        chrono.Stop;
    end else
    if panelActif=pRescaleIntensity then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterRescaleIntensity,'inImage',imageIn);
        setParameterImage(filterRescaleIntensity,'outImage',imageOut);
        setParameterInteger(filterRescaleIntensity,'intensityMinimum',sbRescaleIntensityMinimum.Position);
        setParameterInteger(filterRescaleIntensity,'intensityMaximum',sbRescaleIntensityMaximum.Position);
        run(filterRescaleIntensity);
        chrono.Stop;
    end else
    if panelActif=pSigmoid then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filterSigmoid,'inImage',imageIn);
        setParameterImage(filterSigmoid,'outImage',imageOut);
        setParameterInteger(filterSigmoid,'intensityMinimum',sbSigmoidMinimum.Position);
        setParameterInteger(filterSigmoid,'intensityMaximum',sbSigmoidMaximum.Position);
        setParameterFloat(filterSigmoid,'alpha',sbSigmoidAlpha.Position/10);
        setParameterInteger(filterSigmoid,'beta',sbSigmoidBeta.Position);
        run(filterSigmoid);
        chrono.Stop;
    end else
    if panelActif=pCompare then begin
        preprocessMask(); // for imageMask
        imageOut2 := image.eraseOrCreateImageLike( imageOut2, imageIn );
        image2 := imageOut2;
        chrono.Start;
        setParameterImage( filterCompare, 'inImage1', imageIn );
        setParameterImage( filterCompare, 'inImage2', imageOut );
        setParameterImage( filterCompare, 'outImage', imageOut2 );
        setParameterImage( filterCompare, 'mask', imageMask );
        setParameterString( filterCompare, 'mode', cbCompareMode.Text );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterCompare, @roi );
        end else begin
          unsetRegionOfInterest( filterCompare );
        end;
        run( filterCompare );
        chrono.Stop;
    end else
    if panelActif=pContour then begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterContour, 'inImage', imageIn );
        setParameterImage( filterContour, 'outImage',imageOut );
        setParameterInteger( filterContour, 'threshold', sbContourThreshold.Position );
        setParameterBoolean( filterContour, 'fill', chkContourFill.Checked );
        setParameterBoolean( filterContour, 'criticalPoints', chkContourCriticalPoints.Checked );
        setParameterInteger( filterContour, 'approximationAccuracy', sbContourApproximationaccuracy.Position );
        run( filterContour );
        chrono.Stop;
    end else
    if panelActif=pLog then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterLog, 'inImage', imageIn );
        setParameterImage( filterLog, 'outImage', imageOut );
        setParameterImage( filterLog, 'mask', imageMask );
        setParameterInteger( filterLog, 'intensityMax', sbLogIntensityMax.Position );
        setParameterBoolean( filterLog, 'autoAdjust', chkLogAdjustAuto.Checked );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterLog, @roi );
        end else begin
          unsetRegionOfInterest( filterLog );
        end;
        run( filterLog );
        chrono.Stop;
    end else
    if panelActif=pLogPolar then begin
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterLogPolar, 'inImage', imageIn );
        setParameterImage( filterLogPolar, 'outImage', imageOut );
        setParameterInteger( filterLogPolar, 'magnitude', sbLogpolarMagnitude.Position );
        setParameterBoolean( filterLogPolar, 'reinverseTransformation', chkLogpolarReinversetransformation.Checked );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterLogPolar, @roi );
        end else begin
          unsetRegionOfInterest( filterLogPolar );
        end;
        run( filterLogPolar );
        chrono.Stop;
    end else
    if panelActif=pHoughTransform then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterHoughTransform, 'inImage', imageIn );
        setParameterImage( filterHoughTransform, 'outImage', imageOut );
        setParameterImage( filterHoughTransform, 'mask', imageMask );
        setParameterString( filterHoughTransform, 'preprocessor', cbHoughTransformPreprocessor.Text );
        setParameterInteger( filterHoughTransform, 'threshold', sbHoughTransformThreshold.Position );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterHoughTransform, @roi );
        end else begin
          unsetRegionOfInterest( filterHoughTransform );
        end;
        run( filterHoughTransform );
        chrono.Stop;
    end else
    if panelActif=pAdjust Then Begin
        imageOut := image.eraseOrCreateImageLike(imageOut,imageIn);
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterAdjust, 'inImage', imageIn );
        setParameterImage( filterAdjust, 'outImage', imageOut );
        setParameterInteger( filterAdjust, 'Contrast', sbConstrast.Position );
        setParameterInteger( filterAdjust, 'Brightness', sbBrightness.Position );
        setParameterBoolean( filterAdjust, 'AutoAdjust', chkAdjustAuto.Checked );
        run( filterAdjust );
        chrono.Stop;
    end else
    if panelActif=pRotation Then Begin
        imageOut2:=image.eraseOrCreateImageLike(imageOut2,imageIn);
        image2:=imageOut2;
        chrono.Start;
        setParameterImage(filterRotation,'inImage',imageIn);
        setParameterImage(filterRotation,'outImageMonitoring',imageOut2);
        setParameterBoolean(filterRotation,'monitoring',chkRotationMonitoring.Checked);
        setParameterFloat(filterRotation,'angle', StrToFloat(txtRotationAngle.Text));
        setParameterFloat(filterRotation,'xCenter', sbRotationCenterX.Position) ;
        setParameterFloat(filterRotation,'yCenter', sbRotationCenterY.Position) ;
        setParameterInteger(filterRotation,'interpolationMode', rdgRotationInterpolation.ItemIndex);
        setParameterString(filterRotation,'missingPixelColorMode',cbRotationMissingpixelcolormode.Text);
        setParameterBoolean(filterRotation,'autoAdjustSize',chkRotationAutoadjustsize.Checked);
        run(filterRotation);
        chrono.Stop;
        image1:=getOutputImage(filterRotation,'outImage');
        imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
        image.copyImageToImage(image1,imageOut);
    end else
    if panelActif=pImageCreator then begin
        chrono.Start;
        setParameterString( filterImageCreator, 'command', txtImageCreatorCommand.Text );
        run( filterImageCreator );
        chrono.Stop;
        image1 := getOutputImage( filterImageCreator, 'outImage' );
        imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
    end else
    if panelActif=pImageInfo then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterImage( filterImageInfo, 'inImage', imageIn );
        //setParameterImage( filterImageInfo, 'outImage',imageOut );
        setParameterImage( filterImageInfo, 'mask', imageMask );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterImageInfo, @roi );
        end else begin
          unsetRegionOfInterest( filterImageInfo );
        end;
        run( filterImageInfo );
        chrono.Stop;
        txtImageInfoPixelMin.Text := IntToStr( getOutputInteger( filterImageInfo, 'pixelMin' ) );
        txtImageInfoPixelMax.Text := IntToStr( getOutputInteger( filterImageInfo, 'pixelMax' ) );
        txtImageInfoPixelMaxSubMin.Text := IntToStr( getOutputInteger( filterImageInfo, 'pixelMax' ) - getOutputInteger( filterImageInfo, 'pixelMin' ) );
    end else
    if panelActif=pCoOccurrenceMatrix then begin
        preprocessMask(); // for imageMask
        imageOut2 := image.eraseOrCreateImageLike(imageOut2,imageIn);
        image2 := imageOut2;
        chrono.Start;
        setParameterImage( filterCoOccurrenceMatrix, 'inImage', imageIn );
        setParameterImage( filterCoOccurrenceMatrix, 'outImageMonitoring', imageOut2 );
        setParameterImage( filterCoOccurrenceMatrix, 'mask', imageMask );
        setParameterInteger( filterCoOccurrenceMatrix, 'horizontalDistance', sbCooccurenceHorSize.Position );
        setParameterInteger( filterCoOccurrenceMatrix, 'verticalDistance', sbCooccurenceVerSize.Position );
        setParameterInteger( filterCoOccurrenceMatrix, 'xAnalyse', rdCoocurenceX.ItemIndex );
        setParameterInteger( filterCoOccurrenceMatrix, 'yAnalyse', rdCoocurenceY.ItemIndex );
        setParameterFloat( filterCoOccurrenceMatrix, 'scale',  sbCoOccurenceScale.Position );
        setParameterBoolean( filterCoOccurrenceMatrix, 'Shift45', chkCoocurenceShift45.Checked);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filterCoOccurrenceMatrix, @roi );
        end else begin
          unsetRegionOfInterest( filterCoOccurrenceMatrix );
        end;
        if (shpViewerToolROI.Visible) then begin
          x1 := round(shpViewerToolROI.Left*255/ViewerImageOut.width);
          if x1<0 then x1 :=0;
          x2 := round((shpViewerToolROI.Left+shpViewerToolROI.width)*255/ViewerImageOut.width);
          if x2>255 then x2 := 255;
          y1 := round(shpViewerToolROI.Top*255/ViewerImageOut.height);
          if y1 < 0 then y1 := 0;
          y2 := round((shpViewerToolROI.Top+shpViewerToolROI.height)*255/ViewerImageOut.height);
          if y2 > 255 then y2 := 255;
          setParameterInteger( filterCoOccurrenceMatrix, 'coMinX', x1);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMaxX', x2);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMinY', y1);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMaxY', y2);
        end else begin
          setParameterInteger( filterCoOccurrenceMatrix, 'coMinX', 0);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMaxX', 255);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMinY', 0);
          setParameterInteger( filterCoOccurrenceMatrix, 'coMaxY', 255);
        end;
        run( filterCoOccurrenceMatrix );
        chrono.Stop;
        image1 := getOutputImage( filterCoOccurrenceMatrix, 'outImage' );
        imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_angularSecondMoment' );
        txtCoOccurrenceMatrixFeaturesAngularSecondMoment.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_energy' );
        txtCoOccurrenceMatrixFeaturesEnergy.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_entropy' );
        txtCoOccurrenceMatrixFeaturesEntropy.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_contrast' );
        txtCoOccurrenceMatrixFeaturesContrast.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_dissimilarity' );
        txtCoOccurrenceMatrixFeaturesDissimilarity.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_inverseDifferenceMoment' );
        txtCoOccurrenceMatrixFeaturesInversedifferencemoment.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_mean_i' );
        txtCoOccurrenceMatrixFeaturesMeanI.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_mean_j' );
        txtCoOccurrenceMatrixFeaturesMeanJ.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_variance_i' );
        txtCoOccurrenceMatrixFeaturesVarianceI.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_variance_j' );
        txtCoOccurrenceMatrixFeaturesVarianceJ.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
        tmpSingle := getOutputFloat( filterCoOccurrenceMatrix, 'features_correlation' );
        txtCoOccurrenceMatrixFeaturesCorrelation.Text := FloatToStrF(tmpSingle,ffFixed,10,10);
    end else
    if panelActif=pImageLoader then begin
        chrono.Start;
        setParameterString(filterImageLoader,'filesName',txtImageLoaderFiles.Text);
        run(filterImageLoader);
        chrono.Stop;
        lstImageLoaderViewImage.Items.Clear;
        images := getOutputImages(filterImageLoader,'outImages');
        if (images<>nil) and (Length(images^)>0) then begin
          for tmpI:=0 to Length(images^)-1 do begin
            lstImageLoaderViewImage.Items.Add('image '+IntToStr(tmpI)+' ('+IntToStr(images^[tmpI].Width)+'*'+IntToStr(images^[tmpI].Height)+')');
          end;
        end;
    end else
    if panelActif=pImageSaver then begin
        chrono.Start;
        setParameterString(filterImageSaver,'fileName',txtImageSaverFilename.Text);
        if rgImageSaverImage.ItemIndex=0 then setParameterImage(filterImageSaver,'inImage',imageIn)
        else if rgImageSaverImage.ItemIndex=1 then setParameterImage(filterImageSaver,'inImage',image1)
        else setParameterImage(filterImageSaver,'inImage',image2);
        run(filterImageSaver);
        chrono.Stop;
    end else
    if panelActif=pFiltersPlugin_Resonator then begin
        imageOut:=image.eraseOrCreateImageLike(imageOut,imageIn);
        image1:=imageOut;
        chrono.Start;
        setParameterImage(filtersPlugin_Resonator,'inImage',imageIn);
        setParameterImage(filtersPlugin_Resonator,'outImage',imageOut);
        setParameterFloat(filtersPlugin_Resonator, 'omega', scrOmega.Position/1000);
        if chkUseROI.Checked=true then begin
          setRegionOfInterest(filtersPlugin_Resonator,@roi);
        end else begin
          unsetRegionOfInterest(filtersPlugin_Resonator);
        end;
        run(filtersPlugin_Resonator);
        chrono.Stop;
    end ;

    if panelActif=pFiltersPlugin_TestDelphi then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterInteger( filtersPlugin_TestDelphi, 'testIntegerParameter', StrToInt64(txtPluginSampleParameterInteger.Text) );
        setParameterFloat( filtersPlugin_TestDelphi, 'testFloatParameter', StrToFloat(txtPluginSampleParameterFloat.Text) );
        setParameterBoolean( filtersPlugin_TestDelphi, 'testBooleanParameter', chkPluginSampleParameterBoolean.Checked );
        setParameterString( filtersPlugin_TestDelphi, 'testStringParameter', txtPluginSampleParameterString.Text );
        setParameterImage( filtersPlugin_TestDelphi, 'testImageParameter', imageIn );
        SetLength( tmpImages, 2 );
        tmpImages[0] := imageIn;
        tmpImages[1] := imageIn;
        setParameterImages( filtersPlugin_TestDelphi, 'testImagesParameter', @tmpImages );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filtersPlugin_TestDelphi, @roi );
        end else begin
          unsetRegionOfInterest( filtersPlugin_TestDelphi );
        end;
        run( filtersPlugin_TestDelphi );
        chrono.Stop;
        // get output [testIntegerOutput]
        txtPluginSampleOutputInteger.Text := IntToStr( getOutputInteger( filtersPlugin_TestDelphi, 'testIntegerOutput' ) );
        // get output [testFloatOutput]
        txtPluginSampleOutputFloat.Text := FloatToStrF( getOutputFloat( filtersPlugin_TestDelphi, 'testFloatOutput' ), ffFixed,4,3 );
        // get output image [testImageOutput]
        image1 := getOutputImage( filtersPlugin_TestDelphi, 'testImageOutput' );
        imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
        // get output images [testImagesOutput]
        images := getOutputImages( filtersPlugin_TestDelphi, 'testImagesOutput' );
        image2 := images^[cbPluginSampleOutputImages.ItemIndex];
        imageOut2:=image.eraseOrCreateImageLike( imageOut2, image2 );
        image.copyImageToImage( image2, imageOut2 );
        // get output pointers [testArrayPointersOutput]
        pointers := getOutputArrayPointers( filtersPlugin_TestDelphi, 'testArrayPointersOutput' );
        // we know that it is pointers on C string
        txtPluginOutputArrayPointers.Lines.Clear();
        for tmpI:=0 to Length(pointers^)-1 do begin
          tmpStr := StrPas( pointers^[tmpI] );
          txtPluginOutputArrayPointers.Lines.Add( tmpStr );
        end;
        txtPluginOutputArrayPointers.SelStart := 0;
        SendMessage(txtPluginOutputArrayPointers.handle, EM_SCROLLCARET,0,0);
    end else
    if panelActif=pFiltersPlugin_TestC then begin
        preprocessMask(); // for imageMask
        imageOut := image.eraseOrCreateImageLike( imageOut, imageIn );
        image1 := imageOut;
        chrono.Start;
        setParameterInteger( filtersPlugin_TestC, 'testIntegerParameter', StrToInt64(txtPluginTestC_ParameterInteger.Text) );
        setParameterFloat( filtersPlugin_TestC, 'testFloatParameter', StrToFloat(txtPluginTestC_ParameterFloat.Text) );
        setParameterBoolean( filtersPlugin_TestC, 'testBooleanParameter', chkPluginTestC_ParameterBoolean.Checked );
        setParameterString( filtersPlugin_TestC, 'testStringParameter', txtPluginTestC_ParameterString.Text );
        setParameterImage( filtersPlugin_TestC, 'testImageParameter', imageIn );
        SetLength( tmpImages, 2 );
        tmpImages[0] := imageIn;
        tmpImages[1] := imageIn;
        setParameterImages( filtersPlugin_TestC, 'testImagesParameter', @tmpImages );
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filtersPlugin_TestC, @roi );
        end else begin
          unsetRegionOfInterest( filtersPlugin_TestC );
        end;
        run( filtersPlugin_TestC );
        chrono.Stop;
        // get output [testIntegerOutput]
        txtPluginTestC_OutputInteger.Text := IntToStr( getOutputInteger( filtersPlugin_TestC, 'testIntegerOutput' ) );
        // get output [testFloatOutput]
        txtPluginTestC_OutputFloat.Text := FloatToStrF( getOutputFloat( filtersPlugin_TestC, 'testFloatOutput' ), ffFixed,4,3 );
        // get output image [testImageOutput]
        image1 := getOutputImage( filtersPlugin_TestC, 'testImageOutput' );
        imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
        image.copyImageToImage( image1, imageOut );
        // get output images [testImagesOutput]
        images := getOutputImages( filtersPlugin_TestC, 'testImagesOutput' );
        image2 := images^[cbPluginTestC_OutputImages.ItemIndex];
        imageOut2:=image.eraseOrCreateImageLike( imageOut2, image2 );
        image.copyImageToImage( image2, imageOut2 );
        // get output pointers [testArrayPointersOutput]
        pointers := getOutputArrayPointers( filtersPlugin_TestC, 'testArrayPointersOutput' );
        // we know that it is pointers on C string
        txtPluginTestC_OutputArrayPointers.Lines.Clear();
        for tmpI:=0 to Length(pointers^)-1 do begin
          tmpStr := StrPas( pointers^[tmpI] );
          txtPluginTestC_OutputArrayPointers.Lines.Add( tmpStr );
        end;
        txtPluginTestC_OutputArrayPointers.SelStart := 0;
        SendMessage(txtPluginTestC_OutputArrayPointers.handle, EM_SCROLLCARET,0,0);
    end else
    if panelActif=pFiltersPlugin_Video then begin
        preprocessMask(); // for imageMask
        chrono.Start;
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filtersPlugin_Video, @roi );
        end else begin
          unsetRegionOfInterest( filtersPlugin_Video );
        end;
        setParameterBoolean( filtersPlugin_Video, 'showViewer', chkPluginVideoShowViewer.Checked );
        setParameterString( filtersPlugin_Video, 'fileName', txtPluginVideoFileName.Text );
        if _runCommand<>'' then begin
          StrPCopy( tmpStrC, _runCommand );
          runCommand( filtersPlugin_Video, tmpStrC );
          _runCommand := '';
        end else begin
          run( filtersPlugin_Video );
        end;
        chrono.Stop;
        image1 := getOutputImage( filtersPlugin_Video, 'outImage' );
        if image1<>nil then begin
          imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
          image.copyImageToImage( image1, imageOut );
        end;
    end else
    if panelActif=pFiltersPlugin_WebCam then begin
        preprocessMask(); // for imageMask
        chrono.Start;
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filtersPlugin_WebCam, @roi );
        end else begin
          unsetRegionOfInterest( filtersPlugin_WebCam );
        end;
        setParameterBoolean( filtersPlugin_WebCam, 'showViewer', chkPluginWebCamShowViewer.Checked );
        if txtPluginWebCamDeviceIndex.Text<>'' then begin
          setParameterInteger( filtersPlugin_WebCam, 'deviceIndex', StrToInt(txtPluginWebCamDeviceIndex.Text) );
        end;
        if txtPluginWebCamFormatIndex.Text<>'' then begin
          setParameterInteger( filtersPlugin_WebCam, 'formatIndex', StrToInt(txtPluginWebCamFormatIndex.Text) );
        end;
        if _runCommand<>'' then begin
          StrPCopy( tmpStrC, _runCommand );
          runCommand( filtersPlugin_WebCam, tmpStrC );
          _runCommand := '';
        end else begin
          run( filtersPlugin_WebCam );
        end;
        chrono.Stop;
        // get devices list
        pointers := getOutputArrayPointers( filtersPlugin_WebCam, 'devices' );
        // we know that it is pointers on C string
        lbPluginWebCamDevices.Clear();
        for tmpI:=0 to Length(pointers^)-1 do begin
          tmpStr := StrPas( pointers^[tmpI] );
          lbPluginWebCamDevices.Items.Add( tmpStr );
        end;
        // get format list
        pointers := getOutputArrayPointers( filtersPlugin_WebCam, 'deviceFormats' );
        // we know that it is pointers on C string
        lbPluginWebCamDeviceFormats.Clear();
        for tmpI:=0 to Length(pointers^)-1 do begin
          tmpStr := StrPas( pointers^[tmpI] );
          lbPluginWebCamDeviceFormats.Items.Add( tmpStr );
        end;
        // get captured image
        image1 := getOutputImage( filtersPlugin_WebCam, 'outImage' );
        if image1<>nil then begin
          imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
          image.copyImageToImage( image1, imageOut );
        end;
    end else
    if panelActif=pFiltersPlugin_Viewer then begin
        preprocessMask(); // for imageMask
        chrono.Start;
        if chkUseROI.Checked=true then begin
          setRegionOfInterest( filtersPlugin_Viewer, @roi );
        end else begin
          unsetRegionOfInterest( filtersPlugin_Viewer );
        end;
        setParameterBoolean( filtersPlugin_Viewer, 'showViewer', chkPluginViewerShowViewer.Checked );
        setParameterImage( filtersPlugin_Viewer, 'inImage', imageOut );
        run( filtersPlugin_Viewer );
        chrono.Stop;
    end;
    if panelActif=pFiltersPlugin_SnapShot then begin
        chrono.Start;
        if txtPluginSnapShotWindowTitle.Text<>'' then begin
          setParameterString( filtersPlugin_SnapShot, 'window_title', txtPluginSnapShotWindowTitle.Text );
        end;
        if txtPluginSnapShotWindowHandle.Text<>'' then begin
          setParameterInteger( filtersPlugin_SnapShot, 'window_handle', StrToInt(txtPluginSnapShotWindowHandle.Text) );
        end else begin
          setParameterInteger( filtersPlugin_SnapShot, 'window_handle', 0 );
        end;
        if _runCommand<>'' then begin
          StrPCopy( tmpStrC, _runCommand );
          runCommand( filtersPlugin_SnapShot, tmpStrC );
          _runCommand := '';
        end else begin
          run( filtersPlugin_SnapShot );
        end;
        chrono.Stop;
        // get devices list
        pointers := getOutputArrayPointers( filtersPlugin_SnapShot, 'windows_title' );
        if pointers<>nil then begin
          // we know that it is pointers on C string
          lbPluginSnapShotWindowsTitle.Clear();
          for tmpI:=0 to Length(pointers^)-1 do begin
            tmpStr := StrPas( pointers^[tmpI] );
            lbPluginSnapShotWindowsTitle.Items.Add( tmpStr );
          end;
        end;
        // get outImage
        image1 := getOutputImage( filtersPlugin_SnapShot, 'outImage' );
        if image1<>nil then begin
          imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
          image.copyImageToImage( image1, imageOut );
        end;
    end;
    timePerRun := timePerRun + chrono.getTime();
  end;

  timePerRun := timePerRun div count;
  txtProcessTime.Text := IntToStr(timePerRun);
  chrono.Free();

  imageIOVideo.showImage( imageOut, ViewerImageOut );
  imageIOVideo.showImage( imageOut2, ViewerImageOut2 );
  processViewerTool();
  testing := false;
 end;
end;

procedure TMainForm.preprocessSimulateAngle( img : PBitmap32; angle : Single );
var
  tmpPointer : Pointer;
  tmpImg : PBitmap32;
begin
  image.freeImage(imageSimulateAngle);
  setParameterImage(fRotationForSimulateAngle,'inImage',img);
  setParameterImage(fRotationForSimulateAngle,'outImageMonitoring',nil);
  setParameterBoolean(fRotationForSimulateAngle,'monitoring',false);
  setParameterFloat(fRotationForSimulateAngle,'angle', angle);
  setParameterInteger(fRotationForSimulateAngle,'interpolationMode', 2);
  setParameterString(fRotationForSimulateAngle,'missingPixelColorMode','BLACK');
  setParameterBoolean(fRotationForSimulateAngle,'autoAdjustSize',true);
  run(fRotationForSimulateAngle);
  tmpImg:=getOutputImage(fRotationForSimulateAngle,'outImage');
  imageSimulateAngle:=image.createImageFromImage(tmpImg);
end;

procedure TMainForm.preprocessBlob( img : PBitmap32 );
var
  tmpPointer : Pointer;
begin
  image.freeImage( imageBlob );
  imageBlob := image.createImageLike( imageSimulateAngle );
  setParameterImage( fBlobExplorerForBlob, 'inImage', imageSimulateAngle );
  setParameterImage( fBlobExplorerForBlob, 'outImage', imageBlob );
  setParameterInteger( fBlobExplorerForBlob, 'intensityBackground', sbBlobExplorerIntensityBackground.Position );
  setParameterInteger( fBlobExplorerForBlob, 'intensityPrecision', sbBlobExplorerIntensityPrecision.Position );
  setParameterString( fBlobExplorerForBlob, 'enableBlobArea', cbBlobExplorerEnableBlobArea.Text );
  setParameterInteger( fBlobExplorerForBlob, 'blobAreaMin', StrToInt(txtBlobExplorerAreaMin.Text) );
  setParameterInteger( fBlobExplorerForBlob, 'blobAreaMax', StrToInt(txtBlobExplorerAreaMax.Text) );
  setParameterBoolean( fBlobExplorerForBlob, 'contour', chkBlobExplorerContour.Checked );
  setParameterBoolean( fBlobExplorerForBlob, 'criticalPoints', True );
  setParameterInteger( fBlobExplorerForBlob, 'contourCriticalPointsAppoximationAccuracy', sbBlobExplorerCriticalPointsAppoximationAccuracy.Position );
  setParameterString( fBlobExplorerForBlob, 'approximationMethod', cbBlobExplorerApproximationMethod.Text );
  setParameterBoolean( fBlobExplorerForBlob, 'blobSurfaceInfo', True );
  setParameterBoolean( fBlobExplorerForBlob, 'monitoring', False );
  run( fBlobExplorerForBlob );
end;

procedure TMainForm.preprocessStackAnalyser;
var
  i : Integer;
begin
  // imagesInStackAnalyser
  if Length( imagesInStackAnalyser )=0 then begin
    SetLength( imagesInStackAnalyser, 10 );
    for i:=0 to Length(imagesInStackAnalyser)-1 do begin
      imagesInStackAnalyser[i] := image.createImageLike( imageIn );
      setParameterImage( filterBlur, 'inImage', imageIn );
      setParameterImage( filterBlur, 'outImage', imagesInStackAnalyser[i] );
      setParameterInteger( filterBlur, 'mode', 0 );
      setParameterInteger( filterBlur, 'radius', i*25 );
      unsetRegionOfInterest( filterBlur );
      run( filterBlur );
    end;
    sbStackAnalyserInImages.Max := Length( imagesInStackAnalyser )-1;
  end;
  // imageMask
  preprocessMask;
end;

procedure TMainForm.preprocessMask;
begin
  if imageMask=nil then begin
    if chkMask.Checked=True then begin
      imageMask := fmask.createMask( imageIn.Width, imageIn.Height, fmask.maskDisk );
    end;
  end;
end;

procedure TMainForm.cbConstantAddOverflowingModeChange(Sender: TObject);
begin
  pCutterTiles.Visible:=False;
  if cbCutterType.Text='TILES' then begin
    pCutterTiles.Visible:=True;
    pCutterTiles.Align:=alBottom;
  end;
  Test;
end;

procedure TMainForm.sbConstantAddChange(Sender: TObject);
begin
  txtConstantAddValue.Text:=IntToStr(sbConstantAdd.Position);
  Test;
end;

procedure TMainForm.lstConvTypeClick(Sender: TObject);
begin
  if lstConvType.ItemIndex <> -1 Then Begin
    Test;
  End ;
end;

procedure TMainForm.sbThresholdBinaryLowerChange(Sender: TObject);
begin
  txtThresholdBinaryLowerValue.Text:=IntToStr(sbThresholdBinaryLower.Position);
  if sbThresholdBinaryUpper.Position < sbThresholdBinaryLower.Position Then
    sbThresholdBinaryUpper.Position := sbThresholdBinaryLower.Position ;
  Test;
end;

procedure TMainForm.sbThresholdBinaryUpperChange(Sender: TObject);
begin
  txtThresholdBinaryUpperValue.Text := IntToStr(sbThresholdBinaryUpper.Position);
  if sbThresholdBinaryLower.Position > sbThresholdBinaryUpper.Position Then
    sbThresholdBinaryLower.Position := sbThresholdBinaryUpper.Position ;
  Test;
end;

procedure TMainForm.sbExplorerXChange(Sender: TObject);
begin
  setLineXY(lineX,MulDiv(sbExplorerX.Position,ViewerImageIn.Width,imageIn.Width),lineX.Top,lineX.Width,LineX.Height);
  setLineXY(lineY,LineY.Left,MulDiv(sbExplorerY.Position,ViewerImageIn.Height,imageIn.Height),LineY.Width,LineY.Height);
  poi.X := sbExplorerX.Position;
  poi.Y := sbExplorerY.Position;
  txtExplorerX.Text := IntToStr( Round(poi.X) );
  txtExplorerY.Text := IntToStr( Round(poi.Y) );
  Test;
end;

procedure TMainForm.splMidleMoved(Sender: TObject);
begin
  cmdCopyImageOut.Top := splMidle.Top-2 ;
  cmdCopyImageOut2.Top := cmdCopyImageOut.Top ;
  cmdCopyImageOut1ToImageOut2.Top := splMidle.Top + pnlBottomCenter.Height div 2;
  setLineXY(lineX,lineX.Left,0,lineX.Width,ViewerImageIn.Height);
  setLineXY(lineY,0,LineY.Top,ViewerImageIn.Width,LineY.Height);
end;

procedure TMainForm.pcTestChange(Sender: TObject);
begin
  if panelActif=pExplorer then begin
    lineX.Visible:=True;
    lineY.Visible:=True;
  end else begin
    lineX.Visible:=False;
    lineY.Visible:=False;
  end;
end;

procedure TMainForm.sbSobelChange(Sender: TObject);
begin
  txtSobelBlurIteration.Text := IntToStr(sbSobelBlurIteration.Position);
  txtSobelGain.Text := IntToStr(sbSobelGain.Position);
  txtSobelThresholdLower.Text := IntToStr(sbSobelThresholdLower.Position);
  txtSobelThresholdUpper.Text := IntToStr(sbSobelThresholdUpper.Position);
  Test;
end;

procedure TMainForm.sbContrastExplorerPrecisionChange(Sender: TObject);
begin
  txtContrastExplorerPrecision.Text:=IntToStr(sbContrastExplorerPrecision.Position);
  Test;
end;

procedure TMainForm.sbMorphologySE_sizeChange(Sender: TObject);
begin
  txtMorphologySE_size.Text:=IntToStr(sbMorphologySE_size.Position);
  updateMorphologySE();
  Test;
end;

procedure TMainForm.cbMorphologyTypeChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbMorphologyIterationChange(Sender: TObject);
begin
  txtMorphologyIteration.Text:=IntToStr(sbMorphologyIteration.Position);
  Test;
end;

procedure TMainForm.sbPercentStandardDeviationChange(Sender: TObject);
begin
  txtPercentStandardDeviation.Text:=IntToStr(sbPercentStandardDeviation.Position);
  txtPercentLocalDeviation.Text:=IntToStr(sbPercentLocalDeviation.Position);
  Test;
end;

procedure TMainForm.shpROIMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbLeft then begin
    mouseDownX := X ;
    mouseDownY := Y ;
    moveROI:=not moveROI;
  end else begin
    resizeROI:=not resizeROI;
  end;
end;

procedure TMainForm.shpROIMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if moveROI=true then begin
    setROI(shpROI.Left+X-mouseDownX,shpROI.Top+Y-mouseDownY,shpROI.Width,shpROI.Height);
  end else if resizeROI=true then begin
    setROI(shpROI.Left,shpROI.Top,X,Y);
  end;
end;
procedure TMainForm.shpROIMouseUp(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
    moveROI := false ;
end;

procedure TMainForm.ViewerImageInMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  selectedPoint.x:=MulDiv(x,imageIn.Width,ViewerImageIn.Width);
  selectedPoint.y:=MulDiv(y,imageIn.Height,ViewerImageIn.Height);
  if panelActif=pExplorer then begin
    sbExplorerX.Position := Floor(selectedPoint.x);
    sbExplorerY.Position := Floor(selectedPoint.y);
  end else
  if panelActif=pRotation then begin
    sbRotationCenterX.position := Floor(selectedPoint.x);
    sbRotationCenterY.position := Floor(selectedPoint.y);
  end else begin
    setLineXY(lineX,x,LineX.Top,LineX.Width,LineX.Height);
    setLineXY(lineY,LineY.Left,y,LineY.Width,LineY.Height);
  end;
  Test;
end;

procedure TMainForm.ViewerImageInMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  if moveROI=true then begin
    setROI(X,Y,shpROI.Width,shpROI.Height);
  end else Begin
    if resizeROI=true then begin
      setROI(shpROI.Left,shpROI.Top,X-shpROI.Left,Y-shpROI.Top);
    end else Begin
     // to do
    End ;
  end;

end;

procedure TMainForm.ViewerImageInMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbLeft then begin
    moveROI:=false;
  end else begin
    resizeROI:=false;
  end;
end;

procedure TMainForm.setROI(X,Y,W,H:Integer);
begin
  shpROI.Left:=X;
  shpROI.Top:=Y;
  shpROI.Width:=W;
  shpROI.Height:=H;
  shpROI.Refresh;
  roi.Left:=MulDiv(X,imageIn.Width,ViewerImageIn.Width);
  roi.Top:=MulDiv(Y,imageIn.Height,ViewerImageIn.Height);

  roi.Right:=roi.Left+MulDiv(shpROI.Width,imageIn.Width,ViewerImageIn.Width);;
  roi.Bottom:=roi.Top+MulDiv(shpROI.Height,imageIn.Height,ViewerImageIn.Height);
  lblROI.Caption:='(x='+IntToStr(roi.Left)+',y='+IntToStr(roi.Top)+',w='+IntToStr(roi.Right-roi.Left)+',h='+IntToStr(roi.Bottom-roi.Top)+')';

  shpROIout.Left := MulDiv(roi.left, ViewerImageOut.Width, imageIn.Width) ;
  shpROIout.Top := MulDiv(roi.top, ViewerImageOut.Height, imageIn.height) ;

  shpROIout.Width := round((roi.Right-roi.Left)*ViewerImageOut.Width/imageIn.Width) ;
  shpROIout.height := round((roi.Bottom-roi.Top)*ViewerImageOut.Height/ imageIn.Height) ;
  Test;
end;

procedure TMainForm.lbFiltersClassicClick(Sender: TObject);
begin
  changeFilter(lbFiltersClassic);
end;

procedure TMainForm.lbFiltersOtherClick(Sender: TObject);
begin
  changeFilter(lbFiltersOther);
end;

procedure TMainForm.lbFiltersPluginsClick(Sender: TObject);
begin
  changeFilter(lbFiltersPlugins);
end;

procedure TMainForm.changeFilter(lb: TListBox);
var
  f : String;
  tmpI : Integer;
begin
  LineX.Visible:=false;
  LineY.Visible:=false;
  if lb.ItemIndex>=0 then begin
    f:=lb.Items[lb.ItemIndex];
    if panelActif<>nil then begin
      panelActif.Visible:=false;
    end;
    if f='ArithmeticAdd' then panelActif:=pAdd
    else if f='ArithmeticConstantAdd' then panelActif:=pConstantAdd
    else if f='ArithmeticSubstract' then panelActif:=pSubstract
    else if f='BlobBalance' then panelActif:=pBlobBalance
    else if f='BlobExplorer' then panelActif:=pBlobExplorer
    else if f='BlobGrouping' then panelActif:=pBlobGrouping
    else if f='BlobRepositioning' then panelActif:=pBlobRepositioning
    else if f='BlobRepositioning2' then panelActif:=pBlobRepositioning2
    else if f='Blur' then panelActif:=pBlur
    else if f='CellOnOff' then panelActif:=pCellOnOff
    else if f='CoOccurrenceMatrix' then panelActif:=pCoOccurrenceMatrix
    else if f='Copy' then panelActif:=pCopy
    else if f='ContrastExplorer' then panelActif:=pContrastExplorer
    else if f='Convolutions' then panelActif:=pConvolutions
    else if f='DistancesMap' then panelActif:=pDistancesMap
    else if f='Envelope' then panelActif:=pEnvelope
    else if f='Explorer' then panelActif:=pExplorer
    else if f='GranularityExplorer' then panelActif:=pGranularityExplorer
    else if f='Invert' then panelActif:=pInvert
    else if f='Resize' then panelActif := pResize
    else if f='LocalDeviation' then panelActif:=pLocalDeviation
    else if f='NonMaximaSuppression' then panelActif:=pNonMaximaSuppression
    else if f='Morphology' then panelActif:=pMorphology
    else if f='Histogram' then panelActif:=pHistogram
    else if f='HistogramContrast' then panelActif:=pHistogramContrast
    else if f='Pyramid' then panelActif:=pPyramid
    else if f='Normalize' then panelActif:=pPyramid
    else if f='StackMasher' then panelActif:=pPyramid
    else if f='StackProcessor' then panelActif:=pPyramid
    else if f='StandardDeviation' then panelActif:=pStandardDeviation
    else if f='Sobel' then panelActif:=pSobel
    else if f='surface inspection 1' then panelActif:=pApplication1
    else if f='SUSAN' then panelActif:=pSUSAN
    else if f='surface inspection 2' then panelActif:=pApplication2
    else if f='SPV' then panelActif:=pSPV
    else if f='ThresholdBinary' then panelActif:=pThresholdBinary
    else if f='Wavelets' then panelActif:=pWavelets
    else if f='Waves' then panelActif:=pWaves
    else if f='Cutter' then panelActif:=pCutter
    else if f='Canny' then panelActif:=pCanny
    else if f='Compare' then panelActif:=pCompare
    else if f='Contour' then panelActif:=pContour
    else if f='Log' then panelActif:=pLog
    else if f='LogPolar' then panelActif:=pLogPolar
    else if f='HoughTransform' then panelActif:=pHoughTransform
    else if f='Adjust' then panelActif:=pAdjust
    else if f='Means' then panelActif:=pMeans
    else if f='Median' then panelActif:=pMedian
    else if f='Rotation' then panelActif:=pRotation
    else if f='Integration' then panelActif:=pIntegration
    else if f='VectorHistogram' then panelActif:=pVectorHistogram
    else if f='Correlation' then panelActif:=pCorrelation
    else if f='GradientAnisotropicDiffusion' then panelActif:=pGradientAnisotropicDiffusion
    else if f='RescaleIntensity' then panelActif:=pRescaleIntensity
    else if f='Sigmoid' then panelActif:=pSigmoid
    else if f='SmoothBilateral' then panelActif:=pBilateral
    else if f='ImageCreator' then panelActif:=pImageCreator
    else if f='ImageInfo' then panelActif:=pImageInfo
    else if f='ImageLoader' then panelActif:=pImageLoader
    else if f='ImageSaver' then panelActif:=pImageSaver
    else if f='ProjectionLine' then panelActif:=pProjectionLine
    else if f='StackAnalyser' then panelActif:=pStackAnalyser
    else if f='RGB' then panelActif:=pRGB
    else if f='StackCreator' then panelActif:=pStackCreator
    else if f='FiltersPlugin_Resonator' then panelActif:=pFiltersPlugin_Resonator
    else if f='FiltersPlugin_TestDelphi' then panelActif:=pFiltersPlugin_TestDelphi
    else if f='FiltersPlugin_TestC' then panelActif:=pFiltersPlugin_TestC
    else if f='FiltersPlugin_Video' then panelActif:=pFiltersPlugin_Video
    else if f='FiltersPlugin_WebCam' then panelActif:=pFiltersPlugin_WebCam
    else if f='FiltersPlugin_Viewer' then panelActif:=pFiltersPlugin_Viewer
    else if f='FiltersPlugin_SnapShot' then panelActif:=pFiltersPlugin_SnapShot;
    if (f='Explorer') or (f='Rotation') or (f='Correlation') then begin
      LineX.Visible:=true;
      LineY.Visible:=true;
    end ;
    if panelActif<>nil then begin
      panelActif.Align:=alClient;
      panelActif.Visible:=true;
    end;
  end;
  if MemoHelp.Visible=True then begin
    sbHelpClick(Self);
    sbHelpClick(Self);
  end;
end;

procedure TMainForm.FormResize(Sender: TObject);
begin
  setROI(shpROI.Left,shpROI.Top,shpROI.Width,shpROI.Height);
end;

procedure TMainForm.cmdProcessClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.chkUseROIClick(Sender: TObject);
begin
  shpROI.Visible := chkUseROI.Checked;
  chkStandardDeviationShowOnlyROI.Enabled := chkUseROI.Checked;
  if chkUseROI.Checked=False then begin
    chkStandardDeviationShowOnlyROI.Checked := False;
    Test;
  end else begin
    setROI(
      ViewerImageIn.Width div 2, ViewerImageIn.Height div 2,
      ViewerImageIn.Width div 4, ViewerImageIn.Height div 4
    );
  end;
end;

procedure TMainForm.cbHistogramNormalizeChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbHistogramPrecisionChange(Sender: TObject);
begin
  txtHistogramPrecision.Text:=IntToStr(sbHistogramPrecision.Position);
  Test;
end;

procedure TMainForm.cbFilterTypeChange(Sender: TObject);
begin
  lbFiltersClassic.Visible := false;
  lbFiltersPlugins.Visible := false;
  lbFiltersOther.Visible := false;
  lbApplications.Visible := false;
  case cbFilterType.ItemIndex of
  0: begin
     lbFiltersClassic.Visible := true;
     lbFiltersClassic.Align := alClient;
     lbFiltersClassicClick(Self);
     end;
  1: begin
     lbFiltersPlugins.Visible := true;
     lbFiltersPlugins.Align := alClient;
     lbFiltersPluginsClick(Self);
     end;
  2: begin
     lbFiltersOther.Visible := true;
     lbFiltersOther.Align := alClient;
     lbFiltersOtherClick(Self);
     end;
  else
     begin
     if cbFilterType.Text='applications' then begin
       lbApplications.Visible := true;
       lbApplications.Align := alClient;
       lbApplicationsClick(Self);
     end;
     end;
  end;
end;

procedure TMainForm.sbBlurRadiusChange(Sender: TObject);
begin
  txtBlurRadius.Text := IntToStr( sbBlurRadius.Position );
  Test;
end;

procedure TMainForm.splTopMoved(Sender: TObject);
begin
  setLineXY(lineY,LineY.Left,LineY.Top,ViewerImageIn.Width,LineY.Height);
end;

procedure TMainForm.sbHistogramContrastRectangleWidthChange(
  Sender: TObject);
begin
  txtHistogramContrastRectangleWidth.Text:=IntToStr(sbHistogramContrastRectangleWidth.Position);
  Test;
end;

procedure TMainForm.sbHistogramContrastRectangleHeightChange(
  Sender: TObject);
begin
  txtHistogramContrastRectangleHeight.Text:=IntToStr(sbHistogramContrastRectangleHeight.Position);
  Test;
end;

procedure TMainForm.sbHistogramContrastPrecisionChange(Sender: TObject);
begin
  txtHistogramContrastPrecision.Text:=IntToStr(sbHistogramContrastPrecision.Position);
  Test;
end;

procedure TMainForm.sbPyramidChange(Sender: TObject);
var
  images : PArrayOfPBitmap32 ;
begin
  images := getOutputImages(filterStackProcessor,'outImages');
  if (images<>nil) and (length(images^) > sbPyramid.position) then begin
    image1 := images^[sbPyramid.position];
    if image1 <> nil Then Begin
      imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
      image.copyImageToImage(image1,imageOut);
      imageIOVideo.showImage(image1, ViewerImageOut);
    end;
  end else Begin
    Test();
  end;
end;

procedure TMainForm.cbHistogramContrastModeChange(Sender: TObject);
begin
  if cbHistogramContrastMode.Text='SHOW_DETAILS' then begin
    chkUseROI.State:=cbChecked;
  end;
  Test();
end;

procedure TMainForm.sbHistogramContrastGridSpacingWidthChange(
  Sender: TObject);
begin
  txtHistogramContrastGridSpacingWidth.Text:=IntToStr(sbHistogramContrastGridSpacingWidth.Position);
  Test();
end;

procedure TMainForm.sbHistogramContrastGridSpacingHeightChange(
  Sender: TObject);
begin
  txtHistogramContrastGridSpacingHeight.Text:=IntToStr(sbHistogramContrastGridSpacingHeight.Position);
  Test();
end;

procedure TMainForm.btnWebCamLiveClick(Sender: TObject);
begin
  if btnWebCamLive.Caption='live' then begin
    btnWebCamLive.Caption := 'stop';
    cbWebCamDevice.Enabled := False;
    cbWebCamFormat.Enabled := False;
    setParameterBoolean( filtersPlugin_WebCam2, 'showViewer', True );
    setParameterInteger( filtersPlugin_WebCam2, 'formatIndex', cbWebCamFormat.ItemIndex );
    runCommand( filtersPlugin_WebCam2, 'DEVICE_OPEN' );
  end else begin
    btnWebCamLive.Caption := 'live';
    cbWebCamDevice.Enabled := True;
    cbWebCamFormat.Enabled := True;
    setParameterBoolean( filtersPlugin_WebCam2, 'showViewer', False );
    runCommand( filtersPlugin_WebCam2, 'DEVICE_CLOSE' );
  end;
end;

procedure TMainForm.cbWebCamDeviceChange(Sender: TObject);
var
  deviceIndex : Integer;
  tmpI : integer;
  pointers : PArrayOfPointers;
  tmpStr : String;
begin
  deviceIndex := cbWebCamDevice.ItemIndex;
  if deviceIndex>=0 then begin
    setParameterInteger( filtersPlugin_WebCam2, 'deviceIndex', deviceIndex );
    runCommand( filtersPlugin_WebCam2, 'READ_DEVICE_FORMAT' );
    // get format list
    pointers := getOutputArrayPointers( filtersPlugin_WebCam2, 'deviceFormats' );
    // we know that it is pointers on C string
    cbWebCamFormat.Clear();
    for tmpI:=0 to Length(pointers^)-1 do begin
      tmpStr := StrPas( pointers^[tmpI] );
      cbWebCamFormat.Items.Add( tmpStr );
    end;
    cbWebCamFormat.Enabled := True;
  end;
end;

procedure TMainForm.cbWebCamFormatChange(Sender: TObject);
begin
  btnWebCamLive.Enabled := True;
  setParameterBoolean( filtersPlugin_WebCam2, 'showViewer', True );
end;

procedure TMainForm.chkVideoAutoCaptureRunClick(Sender: TObject);
begin
  TimerAutoProcess.Enabled := chkVideoAutoCaptureRun.Checked;
end;

procedure TMainForm.chkWebCamAutoCaptureRunClick(Sender: TObject);
begin
  TimerAutoProcess.Enabled := chkWebCamAutoCaptureRun.Checked;
end;

procedure TMainForm.sbGranularityExplorerPrecisionChange(Sender: TObject);
begin
  txtGranularityExplorerPrecision.Text:=IntToStr(sbGranularityExplorerPrecision.Position);
  Test();
end;

procedure TMainForm.cbStandardDeviationOutputColorChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbHistogramContrastBlurChange(Sender: TObject);
begin
  txtHistogramContrastBlur.Text:=IntToStr(sbHistogramContrastBlur.Position);
  Test();
end;

procedure TMainForm.sbGranularityExplorerSensibilityChange(
  Sender: TObject);
begin
  txtGranularityExplorerSensibility.Text:=IntToStr(sbGranularityExplorerSensibility.Position);
  Test();
end;

procedure TMainForm.lstPyramidFilterClick(Sender: TObject);
begin
  Test();
End;

procedure TMainForm.cmdCopyImageOut1ToImageOut2Click(Sender: TObject);
begin
  if image1<>nil then begin
    image.freeImage(imageOut2);
    imageOut2:=image.createImageFromImage(image1);
    image2:=imageOut2;
    imageIOVideo.showImage(image2,ViewerImageOut2);
  end;
end;

procedure TMainForm.sbBlobExplorerChange(Sender: TObject);
begin
  if sbBlobExplorerAreaMax.Position<sbBlobExplorerAreaMin.Position then sbBlobExplorerAreaMax.Position:=sbBlobExplorerAreaMin.Position;
  txtBlobExplorerAreaMin.Text:=IntToStr(Sqr(sbBlobExplorerAreaMin.Position));
  txtBlobExplorerAreaMax.Text:=IntToStr(Sqr(sbBlobExplorerAreaMax.Position));
  Test;
end;

procedure TMainForm.cbBlobExplorerEnableBlobSizeChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbPyramidNormalisationChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbApplicationsClick(Sender: TObject);
begin
  changeFilter(lbApplications);
end;

procedure TMainForm.sbApplication1DefectAreaMinChange(Sender: TObject);
begin
  txtApplication1DefectAreaMin.Text:=IntToStr(sbApplication1DefectAreaMin.Position);
  Test();
end;

procedure TMainForm.sbApplication2DefectAreaMinChange(Sender: TObject);
begin
  txtApplication2DefectAreaMin.Text:=IntToStr(sbApplication2DefectAreaMin.Position);
  Test();
end;

procedure TMainForm.sbApplication1MinMaxNumberOfDefectsChange(
  Sender: TObject);
begin
  if sbApplication1MaxNumberOfDefectsForNG.Position<sbApplication1MinNumberOfDefectsForOK.Position then begin
    sbApplication1MaxNumberOfDefectsForNG.Position:=sbApplication1MinNumberOfDefectsForOK.Position;
  end;
  txtApplication1MinNumberOfDefectsForOK.Text:=IntToStr(sbApplication1MinNumberOfDefectsForOK.Position);
  txtApplication1MaxNumberOfDefectsForNG.Text:=IntToStr(sbApplication1MaxNumberOfDefectsForNG.Position);
  Test();
end;

procedure TMainForm.cbSobelModeFastChange(Sender: TObject);
begin
  if cbSobelModeFast.Text='TRUE' then begin
    chkSobelAngleCalculation.Enabled := False;
    chkSobelAngleCalculation.Checked := False;
  end else begin
    chkSobelAngleCalculation.Enabled := True;
  end;
  Test();
end;

procedure TMainForm.sbSUSANprecisionChange(Sender: TObject);
begin
  txtSUSANprecision.Text:=IntToStr(sbSUSANprecision.Position);
  Test();
end;

procedure TMainForm.sbSUSANpixelBrightnessDifferenceThresholdChange(
  Sender: TObject);
begin
  txtSUSANpixelBrightnessDifferenceThreshold.Text:=IntToStr(sbSUSANpixelBrightnessDifferenceThreshold.Position);
  Test();
end;

procedure TMainForm.cbSUSANmodeChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbSUSANpixelCentroidDifferenceThresholdChange(
  Sender: TObject);
begin
  txtSUSANpixelCentroidDifferenceThreshold.Text:=IntToStr(sbSUSANpixelCentroidDifferenceThreshold.Position);
  Test();
end;

procedure TMainForm.sbSPVScanLineIncrementChange(Sender: TObject);
begin
  txtSPVBackground.Text:=IntToStr(sbSPVBackground.Position);
  txtSPVScanLineIncrement.Text:=IntToStr(sbSPVScanLineIncrement.Position);
  txtSPVmaximalTrackingStep.Text:=IntToStr(sbSPVmaximalTrackingStep.Position);
  txtSPVmaximalTrackingCycles.Text:=IntToStr(sbSPVmaximalTrackingCycles.Position);
  txtSPVpolygonalApproximationEpsilone.Text:=IntToStr(sbSPVpolygonalApproximationEpsilone.Position);
  Test();
end;

procedure TMainForm.cbSPVbackgroundColorChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbFiltersClassicDblClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbLocalDeviationSizeChange(Sender: TObject);
begin
  txtLocalDeviationSize.Text:=IntToStr(sbLocalDeviationSize.Position);
  Test();
end;

procedure TMainForm.chkShowRoiClick(Sender: TObject);
begin
  shpROIout.Visible := chkShowRoi.Checked ;
end;

procedure TMainForm.sbBlobExplorerIntensityBackgroundChange(
  Sender: TObject);
begin
  txtBlobExplorerIntensityBackground.Text:=IntToStr(sbBlobExplorerIntensityBackground.Position);
  txtBlobExplorerIntensityPrecision.Text:=IntToStr(sbBlobExplorerIntensityPrecision.Position);
  Test();
end;

procedure TMainForm.ViewerImageOut2Click(Sender: TObject);
begin
  cmdCopyImageOut2Click(Self);
end;

procedure TMainForm.sbDistanceMapScaleChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.chkDistanceMapPreInvertClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.TimerAutoProcessTimer(Sender: TObject);
begin
  try
    case PageControlSource.TabIndex of
    0 : // Image
      begin
        Test();
      end;
    1 :  // Video
      begin
        btnVideoCaptureClick( Self );
      end;
    2 :  // WebCam
      begin
        btnWebCamCaptureClick( Self );
      end;
    end;
  except
    chkVideoAutoCaptureRun.Checked := False;
    chkWebCamAutoCaptureRun.Checked := False;
  end;
end;

procedure TMainForm.rdgThresholdClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cbNonMaximaSuppressionOutputColorChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbFiltersOtherDblClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbFiltersPluginsDblClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbApplicationsDblClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lbFiltersOpencvDblClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbCannyThresholdChange(Sender: TObject);
begin
  txtCannyThreshold1.Text:=IntToStr(sbCannyThreshold1.Position);
  txtCannyThreshold2.Text:=IntToStr(sbCannyThreshold2.Position);
  Test();
end;

procedure TMainForm.sbContourThresholdChange(Sender: TObject);
begin
  txtContourThreshold.Text:=IntToStr(sbContourThreshold.Position);
  txtContourApproximationaccuracy.Text:=IntToStr(sbContourApproximationaccuracy.Position);
  Test();
end;

procedure TMainForm.chkContourFillClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cmdLoadVideoClick(Sender: TObject);
Var
  fileName : String ;
begin
  if dlgOpenFilm.Execute then Begin
    fileName := dlgOpenFilm.FileName ;
    setParameterBoolean( filtersPlugin_Video2, 'showViewer', True );
    setParameterString( filtersPlugin_Video2, 'fileName', fileName );
    runCommand( filtersPlugin_Video2, 'LOAD' );
  end;
end;

procedure TMainForm.cmdPauseClick(Sender: TObject);
begin
  runCommand( filtersPlugin_Video2, 'PAUSE' );
  _videoPlaying := False;
end;

procedure TMainForm.cmdStopClick(Sender: TObject);
begin
  runCommand( filtersPlugin_Video2, 'STOP' );
  _videoPlaying := False;
end;

procedure TMainForm.cmdPlayClick(Sender: TObject);
begin
  runCommand( filtersPlugin_Video2, 'PLAY' );
  _videoPlaying := True;
end;

procedure TMainForm.chkBlobExplorerCriticalPointsClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbBlobExplorerCriticalPointsAppoximationAccuracyChange(
  Sender: TObject);
begin
  txtBlobExplorerCriticalPointsAppoximationAccuracy.Text:=IntToStr(sbBlobExplorerCriticalPointsAppoximationAccuracy.Position);
  Test();
end;

procedure TMainForm.shpViewerToolROIMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbLeft then begin
    mouseDownX := X ;
    mouseDownY := Y ;
    moveViewerToolROI:=not moveViewerToolROI;
  end else begin
    resizeViewerToolROI:=not resizeViewerToolROI;
  end;
end;

procedure TMainForm.shpViewerToolROIMouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
  if moveViewerToolROI=true then begin
    setViewerToolROI(shpViewerToolROI.Left+X-mouseDownX,shpViewerToolROI.Top+Y-mouseDownY,shpViewerToolROI.Width,shpViewerToolROI.Height);
    if panelActif=pCoOccurrenceMatrix then begin
      Test;
    end;
  end else if resizeViewerToolROI=true then begin
    setViewerToolROI(shpViewerToolROI.Left,shpViewerToolROI.Top,X,Y);
    if panelActif=pCoOccurrenceMatrix then begin
      Test;
    end;
  end;
end;

procedure TMainForm.ViewerImageOutMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
begin
  if moveViewerToolROI=true then begin
    setViewerToolROI(X,Y,shpViewerToolROI.Width,shpViewerToolROI.Height);
  end else Begin
    if resizeViewerToolROI=true then begin
      setViewerToolROI(shpViewerToolROI.Left,shpViewerToolROI.Top,X-shpViewerToolROI.Left,Y-shpViewerToolROI.Top);
      if panelActif=pCoOccurrenceMatrix then begin
        Test;
      end;
    end else Begin
     // to do
    End ;
  end;
  if rbgViewerTools.ItemIndex=5 then begin
    processViewerToolPixelinfo( X, Y );
  end;
end;

procedure TMainForm.processViewerToolPixelinfo( mouseX, mouseY : Integer );
var
  imgX, imgY : Integer;
  tmpImageIn : PBitmap32;
  H, S, L : Single;
begin
  tmpImageIn := image1;
  if tmpImageIn=nil then begin
    tmpImageIn := imageIn;
  end;
  imgX := Floor( (mouseX * tmpImageIn.Width)  / ViewerImageOut.Width );
  imgY := Floor( (mouseY * tmpImageIn.Height) / ViewerImageOut.Height );
  txtViewerToolText1.Text := format('X=%d Y=%d', [imgX,imgY]);
  txtViewerToolText2.Text := image.getPixelAsString( tmpImageIn, imgX, imgY );
  image.RGBtoHSL( image.getPixel( tmpImageIn, imgX, imgY ), H, S, L );
  txtViewerToolText3.Text := format('Hue=%d, Saturation=%d, Luminosity=%d', [floor(H*255),floor(S*255),floor(L*255)]);
end;


procedure TMainForm.ViewerImageOutMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbLeft then begin
    moveViewerToolROI:=false;
  end else begin
    resizeViewerToolROI:=false;
  end;
end;

procedure TMainForm.setViewerToolROI(X,Y,W,H:Integer);
begin
  shpViewerToolROI.Left := X;
  shpViewerToolROI.Top := Y;
  shpViewerToolROI.Width := W;
  shpViewerToolROI.Height := H;
  shpViewerToolROI.Refresh;
  processViewerTool();
end;

procedure TMainForm.processViewerTool();
var
  tmpImageIn : PBitmap32;
  X,Y,W,H:Integer;
  samplingScaleLength : Single;
  tmpImage : PBitmap32;
  images : PArrayOfPBitmap32;
begin
  tmpImageIn:=image1;
  if tmpImageIn=nil then begin
    tmpImageIn:=imageIn;
  end;
  X := shpViewerToolROI.Left;
  Y := shpViewerToolROI.Top;
  W := shpViewerToolROI.Width;
  H := shpViewerToolROI.Height;
  roiViewerTool.Left:=MulDiv(X,tmpImageIn.Width,ViewerImageOut.Width);
  roiViewerTool.Top:=MulDiv(Y,tmpImageIn.Height,ViewerImageOut.Height);
  roiViewerTool.Right:=roiViewerTool.Left+MulDiv(W,tmpImageIn.Width,ViewerImageOut.Width);
  roiViewerTool.Bottom:=roiViewerTool.Top+MulDiv(H,tmpImageIn.Height,ViewerImageOut.Height);
  // if viewer tool is 'magnifying' or '3D'
  if (rbgViewerTools.ItemIndex=1)  or (rbgViewerTools.ItemIndex=2) then begin
    setParameterImage(filterViewerToolCopy,'inImage',tmpImageIn);
    setRegionOfInterest(filterViewerToolCopy,@roiViewerTool);
    run(filterViewerToolCopy);
    tmpImage := getOutputImage(filterViewerToolCopy,'outImage');
    viewertoolImageOut:=image.eraseOrCreateImageLike(viewertoolImageOut,tmpImage);
    image.copyImageToImage(tmpImage,viewertoolImageOut);
    if (rbgViewerTools.ItemIndex=1) then begin
      // if viewer tool is 'magnifying'
      imageIOVideo.showImage(viewertoolImageOut,ViewerToolImage);
    end else  if (rbgViewerTools.ItemIndex=2) then begin
      // if viewer tool is '3D'
      samplingScaleLength:=((viewertoolImageOut.Width)/10)/2;
      HeightField1.XSamplingScale.Min:=-samplingScaleLength;
      HeightField1.XSamplingScale.Max:=samplingScaleLength;
      samplingScaleLength:=((viewertoolImageOut.Height)/10)/2;
      HeightField1.YSamplingScale.Min:=-samplingScaleLength;
      HeightField1.YSamplingScale.Max:=samplingScaleLength;
    end;
  end else
  // if viewer tool is 'Explorer'
  if (rbgViewerTools.ItemIndex=3)  or (rbgViewerTools.ItemIndex=4) then begin
    setParameterImage( filterViewerToolCopy, 'inImage', tmpImageIn );
    setRegionOfInterest( filterViewerToolCopy, @roiViewerTool );
    run( filterViewerToolCopy );
    tmpImage := getOutputImage( filterViewerToolCopy, 'outImage' );
    setParameterImage( filterViewerToolExplorer, 'inImage', tmpImage );
    setParameterInteger( filterViewerToolExplorer, 'X', tmpImage.Width div 2 );
    setParameterInteger( filterViewerToolExplorer, 'Y', tmpImage.Height div 2 );
    setParameterInteger( filterViewerToolExplorer, 'precision', 1 );
    run( filterViewerToolExplorer );
    images := getOutputImages( filterViewerToolExplorer, 'outImages' );
    if rbgViewerTools.ItemIndex=3 then tmpImage := images^[0] else tmpImage := images^[1];
    viewertoolImageOut := image.eraseOrCreateImageLike( viewertoolImageOut, tmpImage );
    image.copyImageToImage( tmpImage, viewertoolImageOut );
    imageIOVideo.showImage( viewertoolImageOut, ViewerToolImage );
  end;
end;

procedure TMainForm.rbgViewerToolsClick(Sender: TObject);
begin
  pnlViewerTools.Left := ViewerImageOut2.Left;
  pnlViewerTools.Top := ViewerImageOut2.Top;
  pnlViewerTools.Width := ViewerImageOut2.Width;
  pnlViewerTools.Height := ViewerImageOut2.Height;
  txtViewerToolText1.Visible := False;
  txtViewerToolText2.Visible := False;
  txtViewerToolText3.Visible := False;
  shpViewerToolROI.Visible :=false;
  pnlViewerTools.Visible := false;
  ViewerToolImage.Visible := false;
  ViewerToolGLScene.Visible := false;
  case rbgViewerTools.ItemIndex of
  0: begin
     end;
  1,3,4: begin
       shpViewerToolROI.Visible := true;
       pnlViewerTools.Visible := true;
       ViewerToolGLScene.Visible := false;
       ViewerToolImage.Align := alClient;
       ViewerToolImage.Visible := true;
       processViewerTool();
     end;
  2: begin
       shpViewerToolROI.Visible := true;
       pnlViewerTools.Visible := true;
       processViewerTool();
       ViewerToolGLScene.Align := alClient;
       ViewerToolGLScene.Visible := true;
     end;
  5: begin
       pnlViewerTools.Visible := true;
       txtViewerToolText1.Visible := True;
       txtViewerToolText2.Visible := True;
       txtViewerToolText3.Visible := True;
     end;
  end;
end;

procedure TMainForm.HeightField1GetHeight(const x, y: Single;
  var z: Single; var color: TVector4f; var texPoint: TTexPoint);
var
  tmpX : Extended;
  image_x, image_y : Word;
  pixelColor : TColor32;
  pixelIntensity : Integer;
begin
  tmpX := (HeightField1.XSamplingScale.Max+HeightField1.XSamplingScale.Min-0.05) - x; // to inverse the view
  image_x := (Round(tmpX*10)+viewertoolImageOut.Width div 2);
  //image_x := Round(x*10)+viewertoolImageOut.Width div 2;
  image_y := Round(y*10)+viewertoolImageOut.Height div 2;
  pixelColor := image.getValidPixel( viewertoolImageOut, image_x, image_y );
  pixelIntensity := Intensity(pixelColor);
  z := pixelIntensity/256;
end;

procedure TMainForm.ViewerToolGLSceneMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
   viewertoolGlscene_mx:=x;
   viewertoolGlscene_my:=y;
   cameraDownX := ViewerToolGLScene.camera.position.x ;
   cameraDownY := ViewerToolGLScene.camera.position.y ;
   cameraDownZ := ViewerToolGLScene.camera.position.z ;
   cameraDownRollAngle :=  ViewerToolGLScene.camera.TargetObject.RollAngle ;
end;

procedure TMainForm.ViewerToolGLSceneMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var angle : Single ;
begin
  if ssLeft in Shift then begin
    GLCamera1.MoveAroundTarget(viewertoolGlscene_my-y, viewertoolGlscene_mx-x);
    viewertoolGlscene_mx:=x;
    viewertoolGlscene_my:=y;
  end;
  if ssRight in Shift then begin
    angle := (x-viewertoolGlscene_mx)/2 ;
    ViewerToolGLScene.camera.TargetObject.RollAngle:=cameraDownRollAngle + angle;
  end;
end;

procedure TMainForm.shpViewerToolROIMouseUp(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  moveViewerToolROI:=false ;
end;

procedure TMainForm.sbLogpolarMagnitudeChange(Sender: TObject);
begin
  txtLogpolarMagnitude.Text:=IntToStr(sbLogpolarMagnitude.Position);
  Test;
end;

procedure TMainForm.chkLogpolarReinversetransformationClick(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.FormMouseWheelDown(Sender: TObject; Shift: TShiftState;
  MousePos: Types.TPoint; var Handled: Boolean);
  Var scale : Single ;
begin
  scale := 1.03 ;
  ViewerToolGLScene.camera.position.x := ViewerToolGLScene.camera.position.x * scale ;
  ViewerToolGLScene.camera.position.y := ViewerToolGLScene.camera.position.y * scale ;
  ViewerToolGLScene.camera.position.z := ViewerToolGLScene.camera.position.z * scale ;
end;

procedure TMainForm.FormMouseWheelUp(Sender: TObject; Shift: TShiftState;
  MousePos: Types.TPoint; var Handled: Boolean);
  Var scale : Single ;
begin
  scale := 0.97 ;
  ViewerToolGLScene.camera.position.x := ViewerToolGLScene.camera.position.x * scale ;
  ViewerToolGLScene.camera.position.y := ViewerToolGLScene.camera.position.y * scale ;
  ViewerToolGLScene.camera.position.z := ViewerToolGLScene.camera.position.z * scale ;
end;

procedure TMainForm.sbCutterRectWidthChange(Sender: TObject);
begin
  txtCutterRectWidth.Text:=IntToStr(sbCutterRectWidth.Position);
  Test;
end;

procedure TMainForm.sbCutterRectHeightChange(Sender: TObject);
begin
  txtCutterRectHeight.Text:=IntToStr(sbCutterRectHeight.Position);
  Test;
end;

procedure TMainForm.chkCutterMonitoringClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbCutterOutImagesChange(Sender: TObject);
var
  images : PArrayOfPBitmap32 ;
begin
  images := getOutputImages(filterCutter,'outImages');
  if (images<>nil) and (Length(images^) > sbCutterOutImages.position) then Begin
    image1 := images^[sbCutterOutImages.position];
    if image1 <> nil Then Begin
      txtCutterOutimageIndex.Text:=IntToStr(sbCutterOutImages.position+1)+'/'+IntToStr(sbCutterOutImages.Max+1);
      imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
      image.copyImageToImage(image1,imageOut);
      imageIOVideo.showImage(image1, ViewerImageOut);
    end ;
  end else begin
    sbCutterOutImages.position:=0;
    Test;
  end;
end;

procedure TMainForm.sbConstrastChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbBrightnessChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbMedianChange(Sender: TObject);
begin
  txtMedian.Text:=IntToStr(sbMedian.Position);
  Test;
end;

procedure TMainForm.chkWaveletsInverseClick(Sender: TObject);
begin
  Test ;
end;

procedure TMainForm.cbSubstractModeChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cbCutterTypeChange(Sender: TObject);
begin
  pCutterTiles.Visible:=False;
  pCutterBlob.Visible:=False;
  if cbCutterType.Text='TILES' then begin
    pCutterTiles.Visible:=True;
    pCutterTiles.Align:=alBottom;
  end else
  if cbCutterType.Text='BLOB' then begin
    pCutterBlob.Visible:=True;
    pCutterBlob.Align:=alBottom;
  end;
  Test;
end;

procedure TMainForm.sbCutterBlobBackgroundChange(Sender: TObject);
begin
  txtCutterBlobBackground.Text:=IntToStr(sbCutterBlobBackground.Position);
  Test;
end;

procedure TMainForm.sbCutterBlobAreaChange(Sender: TObject);
begin
  if sbCutterBlobAreaMax.Position<sbCutterBlobAreaMin.Position then sbCutterBlobAreaMax.Position:=sbCutterBlobAreaMin.Position;
  txtCutterBlobAreaMin.Text:=IntToStr(Sqr(sbCutterBlobAreaMin.Position));
  txtCutterBlobAreaMax.Text:=IntToStr(Sqr(sbCutterBlobAreaMax.Position));
  Test;
end;

procedure TMainForm.sbRotationAngleChange(Sender: TObject);
begin
  txtRotationAngle.Text := FloatToStrF(sbRotationAngle.Position/10,ffFixed,4,1);
  txtRotationAngle.Refresh ;
  Test ;
end;

procedure TMainForm.sbRotationCenterXChange(Sender: TObject);
begin
  setLineXY(lineX,MulDiv(sbRotationCenterX.Position,ViewerImageIn.Width,imageIn.Width),lineX.Top,lineX.Width,LineX.Height);
  setLineXY(lineY,LineY.Left,MulDiv(sbRotationCenterY.Position,ViewerImageIn.Height,imageIn.Height),LineY.Width,LineY.Height);
  Test ;
end;

procedure TMainForm.rdgRotationInterpolationClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbCutterMarginChange(Sender: TObject);
begin
  txtCutterMargin.Text:=IntToStr(sbCutterMargin.Position);
  Test;
end;

procedure TMainForm.cbRotationMissingpixelcolormodeChange(Sender: TObject);
begin
 Test;
end;

procedure TMainForm.chkRotationMonitoringClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbIntegrationScaleChange(Sender: TObject);
begin
  Test
end;

procedure TMainForm.sbIntegrationOffsetChange(Sender: TObject);
begin
  Test ;
end;

procedure TMainForm.rdgBlurModeClick(Sender: TObject);
begin
  Test ;
end;

procedure TMainForm.sbBlobRepositioningBlobNumeroChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbBlobRepositioningSimulateAngleChange(
  Sender: TObject);
begin
  txtBlobRepositioningSimulateAngle.Text := FloatToStrF(sbBlobRepositioningSimulateAngle.Position/10,ffFixed,4,1);
  txtBlobRepositioning2SimulateAngle.Text := FloatToStrF(sbBlobRepositioning2SimulateAngle.Position/10,ffFixed,4,1);
  Test;
end;

procedure TMainForm.cbBlobRepositioningMonitoringViewChange(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbBlobRepositioningSmoothChange(Sender: TObject);
begin
  Test ;
end;

procedure TMainForm.cmdBlobRepositioningLearnClick(Sender: TObject);
begin
  blobRepositioningLearnedAngle:=StrToFloat(txtBlobRepositioningSimulateAngle.Text);
  runCommand(filterBlobRepositioning,'learn');
  Test;
end;

procedure TMainForm.sbVectorHistogramSmoothChange(Sender: TObject);
begin
  txtVectorHistogramSmooth.Text:=IntToStr(sbVectorHistogramSmooth.Position);
  Test;
end;

procedure TMainForm.sbVectorHistogramBlobNumeroChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbBlobRepositioningMarginChange(Sender: TObject);
begin
  txtBlobRepositioningMargin.Text:=IntToStr(sbBlobRepositioningMargin.Position);
  txtBlobRepositioning2Margin.Text:=IntToStr(sbBlobRepositioning2Margin.Position);
  Test;
end;

procedure TMainForm.chkCutterBlobUseblobrepositioningClick(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cbVectorHistogramAngleprecisionChange(Sender: TObject);
begin
  Test;
end;

{
  pCutterTiles.Visible:=False;
  pCutterBlob.Visible:=False;
  if cbCutterType.Text='TILES' then begin
    pCutterTiles.Visible:=True;
    pCutterTiles.Align:=alBottom;
  end else
  if cbCutterType.Text='BLOB' then begin
    pCutterBlob.Visible:=True;
    pCutterBlob.Align:=alBottom;
  end;
  Test;
}

procedure TMainForm.chkBlobRepositioningMonitoringClick(Sender: TObject);
begin
  lblBlobRepositioningMonitoringView.Visible:=chkBlobRepositioningMonitoring.Checked;
  cbBlobRepositioningMonitoringView.Visible:=chkBlobRepositioningMonitoring.Checked;
  Test;
end;

procedure TMainForm.cbBlobRepositioningMethodChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cbBlobRepositioningVectorhistogramAngleprecisionChange(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbResizeScaleChange(Sender: TObject);
begin
  txtResizeScale.Text := IntToStr(sbResizeScale.Position) + ' %';
  Test ;
end;

procedure TMainForm.cbResizeModeChange(Sender: TObject);
begin
  test ;
end;

procedure TMainForm.cmdBlobRepositioningAutomatictestClick(
  Sender: TObject);
var
  iangle, iangleFrom, iangleTo, iangleInc : Integer;
  angle{, calculatedAngle} : Single;
  error, errorTotal, averageError : Single;
  maxError : Single;
  count : Integer;
  formatSettings : TFormatSettings;
begin
 if cmdBlobRepositioningAutomatictestStop.Visible=false then begin
  formatSettings.DecimalSeparator:='.';
  iangleFrom:=Floor(StrToFloat(txtBlobRepositioningAutomatictestAngleFrom.Text,formatSettings)*10);
  iangleTo:=Floor(StrToFloat(txtBlobRepositioningAutomatictestAngleTo.Text,formatSettings)*10);
  iangleInc:=Floor(StrToFloat(txtBlobRepositioningAutomatictestAngleInc.Text,formatSettings)*10);
  if iangleInc<=iangleInc then iangleInc:=1;
  iangle:=iangleFrom;
  errorTotal:=0;
  count:=1;
  maxError:=-MaxSingle;
  pbBlobRepositioningAutomatictest.Min:=iangleFrom;
  pbBlobRepositioningAutomatictest.Max:=iangleTo;
  pbBlobRepositioningAutomatictest.Visible:=true;
  cmdBlobRepositioningAutomatictestStop.Visible:=true;
  repeat
    angle:=iangle/10;
    txtBlobRepositioningAutomatictestAngle.Text:=FloatToStr(angle);
    sbBlobRepositioningSimulateAngle.Position:=iangle;
    Application.ProcessMessages;
    pbBlobRepositioningAutomatictest.Position:=iangle;
    //calculatedAngle:=-StrToFloat(txtBlobRepositioningComputedAngle.Text);
    error:=Abs(StrToFloat(txtBlobRepositioningError.Text));
    errorTotal:=errorTotal+error;
    averageError:=errorTotal/count;
    txtBlobRepositioningAutomatictestAverageError.Text:=FloatToStr(averageError);
    maxError:=Max(error,maxError);
    txtBlobRepositioningAutomatictestMaxError.Text:=FloatToStr(maxError);
    Inc(count);
    Inc(iangle,iangleInc);
  until (iangle>iangleTo) or (bAutotestStop=true);
  pbBlobRepositioningAutomatictest.Visible:=false;
  cmdBlobRepositioningAutomatictestStop.Visible:=false;
  bAutotestStop:=false;
 end;
end;

procedure TMainForm.cmdBlobRepositioning2AutomatictestClick(
  Sender: TObject);
var
  iangle, iangleFrom, iangleTo, iangleInc : Integer;
  angle{, calculatedAngle} : Single;
  error, errorTotal, averageError : Single;
  maxError : Single;
  count : Integer;
  formatSettings : TFormatSettings;
begin
 if cmdBlobRepositioning2AutomatictestStop.Visible=false then begin
  formatSettings.DecimalSeparator:='.';
  iangleFrom:=Floor(StrToFloat(txtBlobRepositioning2AutomatictestAngleFrom.Text,formatSettings)*10);
  iangleTo:=Floor(StrToFloat(txtBlobRepositioning2AutomatictestAngleTo.Text,formatSettings)*10);
  iangleInc:=Floor(StrToFloat(txtBlobRepositioning2AutomatictestAngleInc.Text,formatSettings)*10);
  if iangleInc<=iangleInc then iangleInc:=1;
  iangle:=iangleFrom;
  errorTotal:=0;
  count:=1;
  maxError:=-MaxSingle;
  pbBlobRepositioning2Automatictest.Min:=iangleFrom;
  pbBlobRepositioning2Automatictest.Max:=iangleTo;
  pbBlobRepositioning2Automatictest.Visible:=true;
  cmdBlobRepositioning2AutomatictestStop.Visible:=true;
  repeat
    angle:=iangle/10;
    txtBlobRepositioning2AutomatictestAngle.Text:=FloatToStr(angle);
    sbBlobRepositioning2SimulateAngle.Position:=iangle;
    Application.ProcessMessages;
    pbBlobRepositioning2Automatictest.Position:=iangle;
    //calculatedAngle:=-StrToFloat(txtBlobRepositioning2ComputedAngle.Text);
    error:=Abs(StrToFloat(txtBlobRepositioning2Error.Text));
    errorTotal:=errorTotal+error;
    averageError:=errorTotal/count;
    txtBlobRepositioning2AutomatictestAverageError.Text:=FloatToStr(averageError);
    maxError:=Max(error,maxError);
    txtBlobRepositioning2AutomatictestMaxError.Text:=FloatToStr(maxError);
    Inc(count);
    Inc(iangle,iangleInc);
  until (iangle>iangleTo) or (bAutotestStop=true);
  pbBlobRepositioning2Automatictest.Visible:=false;
  cmdBlobRepositioning2AutomatictestStop.Visible:=false;
  bAutotestStop:=false;
 end;
end;

procedure TMainForm.cmdBlobRepositioningAutomatictestStopClick(
  Sender: TObject);
begin
  bAutotestStop:=true;
end;

procedure TMainForm.sbGradientAnisotropicDiffusionConductanceChange(
  Sender: TObject);
begin
  txtGradientAnisotropicDiffusionConductance.Text := FloatToStr(sbGradientAnisotropicDiffusionConductance.Position/10);
  txtGradientAnisotropicDiffusionIteration.Text := FloatToStr(sbGradientAnisotropicDiffusionIteration.Position);
  Test;
end;

procedure TMainForm.sbRescaleIntensityChange(Sender: TObject);
begin
  if sbRescaleIntensityMinimum.Position>sbRescaleIntensityMaximum.Position then begin
    sbRescaleIntensityMinimum.Position:=sbRescaleIntensityMaximum.Position;
  end else begin
    txtRescaleIntensityMinimum.Text:=IntToStr(sbRescaleIntensityMinimum.Position);
    txtRescaleIntensityMaximum.Text:=IntToStr(sbRescaleIntensityMaximum.Position);
    Test;
  end;
end;

procedure TMainForm.cmdWavesStepClick(Sender: TObject);
begin
  isWavesSimpleRun := true ;
  Test ;
  isWavesSimpleRun := false ;
end;
procedure TMainForm.cbGradientAnisotropicDiffusionMethodChange(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbSigmoidMinimumChange(Sender: TObject);
begin
  txtSigmoidMinimum.Text:=IntToStr(sbSigmoidMinimum.Position);
  txtSigmoidMaximum.Text:=IntToStr(sbSigmoidMaximum.Position);
  txtSigmoidAlpha.Text:=FloatToStr(sbSigmoidAlpha.Position/10);
  txtSigmoidBeta.Text:=IntToStr(sbSigmoidBeta.Position);
  Test;
end;

procedure TMainForm.sbBilateralDomainsigmaChange(Sender: TObject);
begin
  txtBilateralDomainsigma.Text := FloatToStr(sbBilateralDomainsigma.Position/10);
  txtBilateralRangesigma.Text := FloatToStr(sbBilateralRangesigma.Position/10);
  Test;
end;


procedure TMainForm.ApplicationEventsIdle(Sender: TObject;
  var Done: Boolean);
begin
  if (chkWavesContinue.Checked) and (panelActif=pWaves) then Begin
    isWavesSimpleRun := true ;
    Test ;
    isWavesSimpleRun := false ;
  end ;
end;

procedure TMainForm.sbCorrelationRangeMinChange(Sender: TObject);
begin
  if sbCorrelationRangeMin.Position>sbCorrelationRangeMax.Position then begin
    sbCorrelationRangeMin.Position:=sbCorrelationRangeMax.Position;
  end else begin
    txtCorrelationRangeMin.Text:=IntToStr(sbCorrelationRangeMin.Position);
    txtCorrelationRangeMax.Text:=IntToStr(sbCorrelationRangeMax.Position);
    Test;
  end;
end;

procedure TMainForm.chkCorrelationMonitoringClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cbHistogramFeatureChange(Sender: TObject);
begin
  Test
end;

procedure TMainForm.cmdImageLoaderLoadClick(Sender: TObject);
begin
  Test;
  if lstImageLoaderViewImage.Items.Count>0 then begin
    lstImageLoaderViewImage.Selected[0] := True;
    lstImageLoaderViewImageClick( Self );
  end;
end;

procedure TMainForm.cmdImageLoaderOpenClick(Sender: TObject);
var
  i : Integer;
  filesname : String;
begin
  if dlgImageLoaderOpen.Execute then Begin
    filesname := '';
    for i:=0 to dlgImageLoaderOpen.Files.Count-1 do begin
        if i>0 then filesname:=filesname+';';
        filesname := filesname + dlgImageLoaderOpen.Files.Strings[i];
    end;
    txtImageLoaderFiles.Text := filesname;
  end;
end;

procedure TMainForm.lstImageLoaderViewImageClick(Sender: TObject);
var
  images : PArrayOfPBitmap32 ;
begin
  images := getOutputImages(filterImageLoader,'outImages');
  if (images<>nil) and (Length(images^) > lstImageLoaderViewImage.ItemIndex) then Begin
    image1 := images^[lstImageLoaderViewImage.ItemIndex];
    if image1 <> nil Then Begin
      imageOut:=image.eraseOrCreateImageLike(imageOut,image1);
      image.copyImageToImage(image1,imageOut);
      imageIOVideo.showImage(image1, ViewerImageOut);
    end;
  end else Begin
    Test;
  End;
end;

procedure TMainForm.cmdImageSaverSaveClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cmdImageSaverSelectClick(Sender: TObject);
begin
  if dlgImageSaverSelect.Execute then begin
    txtImageSaverFilename.Text := dlgImageSaverSelect.FileName ;
  end;
end;

procedure TMainForm.sbProjectionLinePreprocessingBlobIndexChange(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbProjectionLineSmoothChange(Sender: TObject);
begin
  txtProjectionLineSmooth.Text:=IntToStr(sbProjectionLineSmooth.Position);
  Test;
end;

procedure TMainForm.sbProjectionLinePreprocessingSimulateAngleChange(
  Sender: TObject);
begin
  txtProjectionLinePreprocessingSimulateAngle.Text := FloatToStrF(sbProjectionLinePreprocessingSimulateAngle.Position/10,ffFixed,4,1);
  Test;
end;

procedure TMainForm.rgProjectionLineInputClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbVectorHistogramPreprocessingAngleChange(
  Sender: TObject);
begin
  txtVectorHistogramPreprocessingAngle.Text := FloatToStrF(sbVectorHistogramPreprocessingAngle.Position/10,ffFixed,4,1);
  Test;
end;

procedure TMainForm.sbBlobBalancePreprocessingAngleChange(Sender: TObject);
begin
  txtBlobBalancePreprocessingAngle.Text := FloatToStrF(sbBlobBalancePreprocessingAngle.Position/10,ffFixed,4,1);
  Test;
end;

procedure TMainForm.sbBlobBalancePreprocessingBlobIndexChange(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.chkBlobBalanceMonitoringClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.cmdBlobBalanceSetAngleToZeroClick(Sender: TObject);
begin
  runCommand(filterBlobBalance,'setAngleToZero');
  Test;
end;

procedure TMainForm.txtBlobRepositioningBlobThresholdChange(
  Sender: TObject);
begin
  txtBlobRepositioningBlobThreshold.Text:=IntToStr(sbBlobRepositioningBlobThreshold.Position);
  Test;
end;

procedure TMainForm.sbBlobRepositioningBlobChange(
  Sender: TObject);
begin
  txtBlobRepositioningBlobThreshold.Text:=IntToStr(sbBlobRepositioningBlobThreshold.Position);
  txtBlobRepositioningBlobAreaMin.Text:=IntToStr(Sqr(sbBlobRepositioningBlobAreaMin.Position));
  txtBlobRepositioningBlobAreaMax.Text:=IntToStr(Sqr(sbBlobRepositioningBlobAreaMax.Position));
  txtBlobRepositioning2BlobThreshold.Text:=IntToStr(sbBlobRepositioning2BlobThreshold.Position);
  txtBlobRepositioning2BlobAreaMin.Text:=IntToStr(Sqr(sbBlobRepositioning2BlobAreaMin.Position));
  txtBlobRepositioning2BlobAreaMax.Text:=IntToStr(Sqr(sbBlobRepositioning2BlobAreaMax.Position));
  Test;
end;

procedure TMainForm.cmdBlobRepositioning2LearnClick(Sender: TObject);
begin
  blobRepositioning2LearnedAngle:=StrToFloat(txtBlobRepositioning2SimulateAngle.Text);
  runCommand(filterBlobRepositioning2,'learn');
  Test;
end;

function TMainForm.calculAngleError(angleCurrent,angleOnLearn,computedAngle:Single) : Single;
begin
  Result:=(angleCurrent-angleOnLearn)+computedAngle;
  if Result>180 then Result:=Result-360;
  if Result<-180 then Result:=Result+360;
end;

procedure TMainForm.sbHelpClick(Sender: TObject);
var
  f : String;
begin
  with MemoHelp do begin
   if Visible=False then begin
    Visible := True;
    Align := alClient;
    with Lines do begin
      Clear();
      Add('(right click mouse to close this help)');
      Add('');
      if lbFiltersClassic.ItemIndex<0 then begin
        Add('This is a small help to show you main functions of each filters');
        Add(' - first thing to do : choose a filter in the list');
        Add(' - then you will obtain help for this filter');
        Add(' - at any time you can show/hide help of a filter by right clicking on it');
        Add('');
        Add('User interface informations :');
        Add(' - you can execute a filter by double clicking on it');
        Add(' - you can copy imageOut 1 or 2 into imageIn by double clicking on it');
        Add(' - you can see filter''s execution time in milliseconds');
        Add(' - with some filter you can use ROI (Region Of Interest)');
        Add(' - you can use the magnifying or the 3D viewer tool on imageOut 1');
        Add(' - you can use a filter in real time with your camera');
        Add('   (button [live], mode [auto process])');
        Add('');
        Add('''FiltersTest'' use the open source image processing library ''Filters''.');
        Add('');
        Add('  see the web site :    http://filters.sourceforge.net');
      end else begin
        if (lbFiltersPlugins.Visible=True) and (lbFiltersPlugins.ItemIndex>=0) then f := lbFiltersPlugins.Items[lbFiltersPlugins.ItemIndex]
        else f := lbFiltersClassic.Items[lbFiltersClassic.ItemIndex];
        if f='ArithmeticAdd' then begin
          Add('filter [ArithmeticAdd]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [Adjust] with :');
          Add('   - [contrast] to the max');
          Add('   - [brightness] to the min');
          Add(' - return to this filter [ArithmeticAdd] and execute it');
          Add('-> the output is on imageOut2 : it''s the sum of imageIn and imageOut1');
        end else if f='ArithmeticConstantAdd' then begin
          Add('filter [ArithmeticConstantAdd]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - change [constant]');
          Add(' - set [overflowingMode] to [WRAP_AROUND_ZERO]');
          Add(' - change [constant]');
          Add('-> the output is on imageOut1');
        end else if f='ArithmeticSubstract' then begin
          Add('filter [ArithmeticSubstract]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [blur]');
          Add(' - return to this filter [ArithmeticSubstract] and execute it');
          Add('-> the output is on imageOut2 : you can see the change provide by the blur filter');
          Add(' - set [mode] to [SUBSTRACT]');
          Add('-> the output is on imageOut2 : you have a quite nice contour');
        end else if f='Compare' then begin
          Add('filter [Compare]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [Blur], with [radius] = 200');
          Add(' - return to this filter [Compare] and execute it');
          Add('-> the output is on imageOut2 : you can see the Minimal intensity between both original and blured Lenna');
          Add(' - set [mode] to [MAX]');
          Add('-> the output is on imageOut2 : you can see the Maximal intensity between both original and blured Lenna');
        end else if f='BlobBalance' then begin
          Add('filter [BlobBalance]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - execute filter [blobExplorer] with :');
          Add('   - [background] to 100');
          Add(' - return to this filter [blobBalance] and execute it');
          Add('-> the monitoring output is on imageOut1 : you can see the left and right gravity center');
          Add('-> the output is the angle of the line who crosses both gravity center / horizontal');
          Add(' - change [filter rotation angle] to simulate a rotation');
        end else if f='BlobExplorer' then begin
          Add('filter [BlobExplorer]');
          Add('');
          Add('Example 1 :');
          Add(' - open image [blob1.bmp]');
          Add(' - execute');
          Add('-> the output is on imageOut1 : you can see all extracted blobs (one color for each)');
          Add(' - set [area min] to 100');
          Add('-> the output is blobs of pixels area >= 100');
          Add('Example 2 :');
          Add(' - open image [circuit.bmp]');
          Add(' - execute filter [contrastExplorer]');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - return to this filter [blobExplorer] and execute it');
          Add(' - change [area min] and [area max]');
          Add('Example 3 :');
          Add(' - open image [blob2.tif]');
          Add(' - set [background] to 100');
          Add(' - check [calcul blob surface info]');
          Add('-> the output is the extracted blob with the surrounding rectangle in blue and the center of gravity in red');
          Add(' - check [critical points]');
          Add('-> the output shown the pixels of blob''s contour');
          Add(' - change [approximation accuracy] to change the contours pixels precision');
        end else if f='BlobGrouping' then begin
          Add('filter [BlobGrouping]');
          Add('');
          Add('Example :');
          Add(' - open image [blob1.bmp]');
          Add(' - execute filter [blobExplorer]');
          Add('-> the output is on imageOut1 : you can see all extracted blobs (one color for each)');
          Add(' - execute filter [blobGrouping]');
          Add('-> the output is on imageOut1 : all blobs of the same averaged intensity are grouped together, regardless of the pixel connectivity');
          Add('     (in this simple example, all blobs are grouped in one white blob)');
        end else if f='BlobRepositioning' then begin
          Add('filter [BlobRepositioning]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - on tab [parameters], set [blob background threshold] to 100');
          Add(' - click [learn]');
          Add(' - on tab [preprocessing], change [filter rotation angle]');
          Add('-> the output is on imageOut1 : you can see the extracted blob, in always the same learned position');
        end else if f='BlobRepositioning2' then begin
          Add('filter [BlobRepositioning2]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - on tab [parameters], set [blob background threshold] to 100');
          Add(' - click [learn]');
          Add(' - on tab [preprocessing], change [filter rotation angle]');
          Add('-> the output is on imageOut1 : you can see the extracted blob, in always the exactly same learned position');
        end else if f='Blur' then begin
          Add('filter [Blur]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - click on the viewer tools [magnify] (to the right of imageOut2)');
          Add(' - left click on the magnify rectangle and move it near the eyes of lenna');
          Add(' - right click on the magnify rectangle to increase it, to have the entire face of lenna');
          Add(' - set [blur] to 0');
          Add('-> the output is on imageOut1 : you can see the original image');
          Add(' - change [blur]');
          Add('-> the output is on imageOut1 : you can see the blurred image');
          Add(' - click type [fast anisotropic]');
          Add(' - change [blur]');
          Add('-> the output is on imageOut1 : you can see the blurred image but with details preserved');
        end else if f='CellOnOff' then begin
          Add('filter [CellOnOff]');
          Add('');
        end else if f='Copy' then begin
          Add('filter [Copy]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute');
          Add('-> the output is on imageOut1 : you can see a copy of the original image');
          Add(' - check [use ROI] (Region Of Interest)');
          Add(' - left click on the ROI rectangle and move it near the eyes of lenna');
          Add(' - right click on the ROI rectangle to increase it, to have the entire face of lenna');
          Add('-> the output is on imageOut1 : you can see a copy of your ROI');
        end else if f='ContrastExplorer' then begin
          Add('filter [ContrastExplorer]');
          Add('');
          Add('Example 1 :');
          Add(' - open image [circuit.bmp]');
          Add(' - execute');
          Add('-> the output is on imageOut1 : you can see all local pixel difference');
          Add('Example 2 :');
          Add(' - open image [mire.jpg]');
          Add(' - execute');
          Add(' - change [precision]');
        end else if f='Convolutions' then begin
          Add('filter [Convolutions]');
          Add('');
          Add('Example :');
          Add(' - open image [mire.jpg]');
          Add(' - execute');
          Add(' - click on a matrix');
          Add('-> the output is on imageOut1 : you can see the matrix convolution applied on original image');
        end else if f='CoOccurrenceMatrix' then begin
          Add('filter [CoOccurrenceMatrix]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add('-> the output is on imageOut1 : you can see the co-occurence matrix (column is the occurence of the same value of pixel_1 and pixel_2, with value is according to the analyse choosen, and horizontal/vertical distance is the distance between this two pixel)');
          Add('     the value choosen for the X analyse is the column of the matrix');
          Add('     the value choosen for the Y analyse is the row of the matrix');
          Add('Example 2 :');
          Add(' - do example 1');
          Add(' - change [scale] to the maximum [350]');
          Add(' - click on [ROI on result]');
          Add(' - right click on the ROI on result, and enlarge it');
          Add('-> on imageOut2 you can see a segmentation of the white object');
        end else if f='DistancesMap' then begin
          Add('filter [DistanceMap]');
          Add('');
          Add('Example :');
          Add(' - open image [dcirc.bmp]');
          Add(' - execute');
          Add(' - change [post processing]');
          Add('-> the output is on imageOut1 : you can see the distance map');
        end else if f='Envelope' then begin
          Add('filter [Envelope]');
          Add('');
          Add('Example :');
          Add(' - open image [blob1.bmp]');
          Add(' - click on [outputs ENVELOPE_MIN]');
          Add('-> the output is on imageOut1 : you can see the minimal intensity envelope');
          Add(' - click on [outputs ENVELOPE_MAX]');
          Add('-> you can see the maximal intensity envelope');
          Add('(you can use the viewer tool [Explorer X/Y] to see more precisely the advantage of this filter)');
        end else if f='Explorer' then begin
          Add('filter [Explorer]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - click on imageIn on the eye of lenna');
          Add(' - the output imageOut1 show the horizontal pixels values');
          Add(' - the output imageOut2 show the vertical pixels values');
        end else if f='GranularityExplorer' then begin
          Add('filter [GranularityExplorer]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [precision] to 2');
          Add(' - set [sensibility] to max');
          Add('-> the output is on imageOut1 : you can see the high granularity zone of the image');
        end else if f='Invert' then begin
          Add('filter [Invert]');
          Add('');
          Add('Example :');
          Add(' - open image [dcirc.bmp]');
          Add(' - execute');
          Add('-> the output is on imageOut1 : you can see the inverted image');
        end else if f='Resize' then begin
          Add('filter [Resize]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [scale factor] to 30%');
          Add(' - set [mode] to [fast blur]');
        end else if f='LocalDeviation' then begin
          Add('filter [LocalDeviation]');
          Add('');
        end else if f='NonMaximaSuppression' then begin
          Add('filter [NonMaximaSuppression]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [sobel]');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - return to this filter [NonMaximaSuppression]');
          Add(' - set [output color] to [UNCHANGED]');
          Add(' - change [precision]');
          Add('-> the output is on imageOut1 : you can see some interesting pixels');
        end else if f='Morphology' then begin
          Add('filter [Morphology]');
          Add('');
          Add('Example :');
          Add(' - open image [blox.bmp]');
          Add(' - set [iteration] to 3');
          Add(' - change [type]');
          Add('-> the output is on imageOut1 : you can see some  morphological operations');
        end else if f='Histogram' then begin
          Add('filter [Histogram]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute');
          Add(' - change [precision]');
          Add('-> the output is on imageOut1 : you can see the global pixel histogram of the image');
          Add(' - check [use ROI] (Region Of Interest)');
          Add(' - left click on the ROI rectangle and move it');
          Add('-> the output is on imageOut1 : you can see the local pixel histogram of the ROI');
        end else if f='HistogramContrast' then begin
          Add('filter [HistogramContrast]');
          Add('');
        end else if (f='Pyramid') or (f='Normalize') or (f='StackMasher') or (f='StackProcessor') then begin
          Add('filter [Pyramid], [Normalize], [StackMasher], [StackProcessor]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - change [pyramid] image to show');
          Add(' - click on filter [Susan]');
          Add(' - change [pyramid] image to show');
          Add(' - click on filter [Blur]');
          Add(' - check [normalize]');
          Add(' - set [pyramid] image to show to first image');
          Add(' - change [use one pyramid output image as reference]');
          Add(' - check [merge all images in one]');
          Add(' - change [use one pyramid output image as reference]');
        end else if f='StandardDeviation' then begin
          Add('filter [StandardDeviation]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - set [threshold] to 90');
          Add(' - set [output color] to UNCHANGED');
          Add(' - try with [use ROI]');
        end else if f='Sobel' then begin
          Add('filter [Sobel]');
          Add('');
          Add('Example :');
          Add(' - open image [suzan.jpg]');
          Add(' - execute');
        end else if f='SUSAN' then begin
          Add('filter [SUSAN]');
          Add('');
          Add('Example :');
          Add(' - open image [suzan.jpg]');
          Add(' - change [mode]');
        end else if f='SPV' then begin
          Add('filter [SparsePixelVectorization]');
          Add('');
          Add('Example 1 :');
          Add(' - open image [line1.bmp]');
          Add(' - set [polygonal approximation] to [1]');
          Add(' - set [show vector width] to [true]');
          Add(' - set [scan line increment] to [7]');
          Add(' - set [monitoring] to [polygonal approximation]');
          Add(' - change [polygonal approximation]');
          Add('Example 2 :');
          Add(' - open image [suzan.jpg]');
          Add(' - execute filter [sobel]');
          Add('   - click on imageOut1 to copy it to imageIn');
          Add(' - return to this filter [SPV] and execute it');
        end else if f='ThresholdBinary' then begin
          Add('filter [ThresholdBinary]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - set [lower] to 0');
          Add(' - set [upper] to 100');
          Add(' - click [Low Black]');
          Add(' - click [Middle Black]');
          Add(' - click [High White]');
        end else if f='Wavelets' then begin
          Add('filter [Wavelets]');
          Add('');
        end else if f='Waves' then begin
          Add('filter [Waves]');
          Add('');
        end else if f='Cutter' then begin
          Add('filter [Cutter]');
          Add('');
          Add('Example :');
          Add(' - open image [suzan.jpg]');
          Add(' - execute');
          Add(' - change [out images]');
          Add('-> the output is on imageOut1 : you can see all extracted images with method [TILES]');
          Add(' - change [rect height] and [rect width]');
          Add('-> the output monitoring is on imageOut2 : you can see rectangles used to cut original image');
          Add(' - set [type] to [BLOB]');
          Add(' - change [out images]');
          Add('-> the output is on imageOut1 : you can see all extracted blob''s image with method [BLOB]');
          Add(' - set [margin] to 50');
          Add(' - check and uncheck [clean]');
          Add('-> the output is on imageOut1 : you can see only blob''s pixel or the original corresponding image');
        end else if f='Canny' then begin
          Add('filter [Canny]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - change [threshold 1]');
        end else if f='Contour' then begin
          Add('filter [Contour]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - set [threshold] to 100');
          Add('-> the output is on imageOut1 : you can see the extracted contour');
          Add(' - check [critical points]');
          Add(' - change [approximation accuracy]');
          Add('-> the output is on imageOut1 : you can see pixelsin red of the extracted contour');
        end else if f='LogPolar' then begin
          Add('filter [LogPolar]');
          Add('');
          Add('Example :');
          Add(' - open image [suzan.jpg]');
          Add(' - check [use ROI] (Region Of Interest)');
          Add(' - check [show ROI]');
          Add(' - left click on the ROI rectangle and move it');
          Add('-> the output is on imageOut1 : you can see precise image near the ROI');
        end else if f='Adjust' then begin
          Add('filter [Adjust]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [contrast] to the max');
          Add(' - set [brightness] to the max');
          Add('-> the output is on imageOut1');
        end else if f='ImageInfo' then begin
          Add('filter [ImageInfo]');
          Add(' - click button [process]');
          Add('-> the output is the [min] and [max] value : you can see that this image don''t use intensity less than 10.');
          Add('Example :');
          Add(' - open image [microbubbles.tif]');
        end else if f='Median' then begin
          Add('filter [Median]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - change [precision]');
          Add('-> the monitoring output is on imageOut1 : you can see the image with only median pixel');
        end else if f='Means' then begin
          Add('filter [Means]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - change [precision]');
          Add('-> the output is on imageOut1 : each pixel is the mean of it''s neighbors');
        end else if f='Log' then begin
          Add('filter [Log]');
          Add('');
          Add('Example :');
          Add(' - open image [texture.jpg]');
          Add(' - click button [process]');
          Add('-> the output is on imageOut1 : dark pixel are now more visible');
        end else if f='Rotation' then begin
          Add('filter [Rotation]');
          Add('');
          Add('Example 1 :');
          Add(' - open image [blob2.tif]');
          Add(' - click on imageIn in the center of the first left hole of the object');
          Add(' - check [monitoring]');
          Add(' - uncheck [auto adjust size]');
          Add(' - change [angle]');
          Add('-> the output is on imageOut1 : you can see the rotated image centered on the hole');
          Add('Example 2 :');
          Add(' - open image [circle1.bmp]');
          Add(' - set [interpolation] to [nearest neighbor]');
          Add(' - set [angle] to 5°');
          Add(' - check [auto adjust size]');
          Add(' - execute');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - execute');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - ...');
          Add(' - now reopen image [circle1.bmp]');
          Add(' - set [interpolation] to [linear]');
          Add(' - execute');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - execute');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - ...');
          Add('-> you see the difference ?');
        end else if f='Integration' then begin
          Add('filter [Integration]');
          Add('');
        end else if f='VectorHistogram' then begin
          Add('filter [VectorHistogram]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - execute filter [blobExplorer] with :');
          Add('   - [background] to 100');
          Add(' - return to this filter [VectorHistogram] and execute it');
          Add('-> the monitoring output is on imageOut1 : you can see the vector histogram of the blob''s contour segments');
          Add(' - change [filter rotation angle] to simulate a rotation');
        end else if f='Correlation' then begin
          Add('filter [Correlation]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [blobExplorer] with :');
          Add('   - check [use ROI] (Region Of Interest)');
          Add('   - left click on the ROI rectangle and move it near the eyes of lenna');
          Add(' - return to this filter [Correlation]');
          Add('-> now we have 2 images : imageIn=[full lenna] and imageOut1=[an eye of lenna]');
          Add(' - uncheck [use ROI]');
          Add(' - click on different position in imageIn to set different center of both image');
          Add('-> the output monitoring is on imageOut2 : you can see both images');
          Add('-> the output is the value [normalized correlation] : if you reposition exactly the eye, you will obtain a full correlation (=1)');
        end else if f='GradientAnisotropicDiffusion' then begin
          Add('filter [GradientAnisotropicDiffusion]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - click on the viewer tools [magnify] (to the right of imageOut2)');
          Add(' - left click on the magnify rectangle and move it near the eyes of lenna');
          Add(' - right click on the magnify rectangle to increase it, to have the entire face of lenna');
          Add(' - set [conductance] to 0');
          Add('-> the output is on imageOut1 : you can see the original image');
          Add(' - change [conductance]');
          Add('-> the output is on imageOut1 : you can see the blurred image with method [fats blur anisotropic]');
          Add(' - set [method] to [standard in grey level]');
          Add('-> the output is on imageOut1 : you can see the blurred image with the standard anisotropic method');
        end else if f='RescaleIntensity' then begin
          Add('filter [RescaleIntensity]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [intensity minimum] to 0');
          Add(' - set [intensity maximum] to 10');
          Add(' - click on imageOut1 to copy it to imageIn');
          Add(' - set [intensity maximum] to 255');
        end else if f='Sigmoid' then begin
          Add('filter [Sigmoid]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [intensity minimum] to 0');
          Add(' - set [intensity maximum] to 255');
          Add(' - set [beta] to 120');
          Add(' - change [alpha]');
        end else if f='SmoothBilateral' then begin
          Add('filter [SmoothBilateral]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - set [domain sigma] to 3');
        end else if f='ImageCreator' then begin
          Add('filter [ImageCreator]');
          Add('');
          Add('Example :');
          Add(' - enter in [command] this string : [createMask( 10, 10, ''maskCross'' ) ]');
          Add('-> the output is on imageOut1 : you can see the created image');
        end else if f='ImageLoader' then begin
          Add('filter [ImageLoader]');
          Add('');
          Add('Example :');
          Add(' - click [select], then choose all images files, and click [ok]');
          Add(' - click [load]');
          Add(' - change [view]');
          Add('-> the output is on imageOut1 : you can see the loaded image');
        end else if f='ImageSaver' then begin
          Add('filter [ImageSaver]');
          Add('');
          Add('Example :');
          Add(' - open image [lenna.jpg]');
          Add(' - execute filter [resize] with :');
          Add('   - set [scale factor] to 50%');
          Add(' - return to this filter [imageSaver]');
          Add(' - set [Image] to [out 1]');
          Add(' - click [select], then enter a file name, and click [ok]');
          Add(' - click [save]');
          Add('-> the output is in the file : you can open it to verify');
        end else if f='ProjectionLine' then begin
          Add('filter [ProjectionLine]');
          Add('');
          Add('Example :');
          Add(' - open image [blob2.tif]');
          Add(' - execute filter [blobExplorer] with :');
          Add('   - set [background] to 100');
          Add(' - return to this filter [ProjectionLine]');
          Add(' - set [input is] to [segment]');
          Add(' - set [smooth] to [50]');
          Add(' - change [filter rotation angle]');
          Add('-> the output is on imageOut1 : you can see the vertical projection of the blob''s pixel segemts');
        end else if f='StackAnalyser' then begin
          Add('filter [StackAnalyser]');
          Add('');
          Add('Example :');
          Add(' - to test this filter we create a stack of images with the inImage blured');
          Add('-> you can see this stack in outImage2');
          Add(' - click on [analyse AVERAGE]');
          Add('-> the output is on imageOut1 : you can see the average of all images in the stack');
        end else if f='StackCreator' then begin
          Add('filter [StackCreater]');
          Add('');
          Add('Example :');
          Add(' - select filter [stackCreator]');
          Add(' - at the right of the button [live], choose your camera (you need a camera or a webcam for this demo)');
          Add(' - click on button [live] ');
          Add(' - check mode [auto process] to on');
          Add('-> at each process execution, a image is captured and pushed in the stack');
          Add('-> the monitoring output is on imageOut1 : you can see the one image that is in the stack');
          Add('-> you can see a delay between the image captured by your camera and the image seen in imageOut');
        end else if f='HoughTransform' then begin
          Add('filter [HoughTransform]');
          Add('');
          Add('Example :');
          Add(' - open image [sphere.bmp]');
          Add('-> the monitoring output is on imageOut1 : you can see that lines are perfectly square !');
        end else if f='RGB' then begin
          Add('filter [RGB]');
          Add('');
          Add('Example :');
          Add(' - open image [mire.JPG]');
          Add(' - change [constant R] to -255');
          Add('-> the output is on imageOut1 : you can see the image without the red channel');
        end else if f='FiltersPlugin_TestDelphi' then begin
          Add('filter [FiltersPlugin_TestDelphi]');
          Add('');
          Add('It''s a filter, written in language Delphi, to test the Filters Plugin API, and it do nothing more...');
          Add('-> the output are on imageOut1 and imageOut2');
        end else if f='FiltersPlugin_TestC' then begin
          Add('filter [FiltersPlugin_TestC]');
          Add('');
          Add('It''s a filter, written in language C/C++, to test the Filters Plugin API, and it do nothing more...');
          Add('-> the output are on imageOut1 and imageOut2');
        end else if f='FiltersPlugin_Video' then begin
          Add('filter [FiltersPlugin_Video]');
          Add('');
          Add('Example :');
          Add(' - click [select...], and choose the video [OK_320_1.avi]');
          Add(' - click on the checkbox [show viewer]');
          Add(' - click [LOAD]');
          Add(' - click [PLAY]');
          Add('-> you can see the playing video in the window');
          Add('-> to load and process a filter on a video, then open the video with the help of the tool [Video] of FiltersTest menu (it you FiltersPlugin_Video internaly)');
        end else if f='FiltersPlugin_Viewer' then begin
          Add('filter [FiltersPlugin_Viewer]');
          Add('');
          Add('Example :');
          Add(' - click on the checkbox [show viewer]');
          Add('-> you can see the image imageOut1 in the window');
        end else if f='FiltersPlugin_SnapShot' then begin
          Add('filter [FiltersPlugin_SnapShot]');
          Add('');
          Add('Example :');
          Add('-> you can see snapshot of Windows desk');
        end else if f='FiltersPlugin_WebCam' then begin
          Add('filter [FiltersPlugin_WebCam]');
          Add('');
          Add('Example :');
          Add(' - click [read devices]');
          Add(' - choose your camera');
          Add(' - click [read formats of device]');
          Add(' - choose a format');
          Add(' - click on the checkbox [open/close device (...)]');
          Add(' - click on the checkbox [show viewer]');
          Add('-> you can see the images from your camera');
          Add('-> to process a filter on images from a camera, you have to prefer tool [WebCam] of FiltersTest menu (it you FiltersPlugin_WebCam internaly)');
        end;
      end;
    end;
   end else begin
    Visible := False;
   end;
  end;
end;

procedure TMainForm.MemoHelpMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbRight then begin
    MemoHelp.Visible:=False;
  end;
end;

procedure TMainForm.chkPyramidSmasherClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.lbFiltersClassicMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if Button=mbRight then begin
    sbHelpClick(Self);
  end;
end;

procedure TMainForm.lstMorphologyTypeClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbBlobGroupingIntensityPrecisionChange(
  Sender: TObject);
begin
  txtBlobGroupingIntensityPrecision.Text:=IntToStr(sbBlobGroupingIntensityPrecision.Position);
  Test;
end;

procedure TMainForm.chkStandardDeviationShowOnlyROIClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbExplorerPrecisionChange(Sender: TObject);
begin
  txtExplorerPrecision.Text:=IntToStr(sbExplorerPrecision.Position);
  Test;
end;

procedure TMainForm.chkBlobRepositioning2BackgroundColorClick(
  Sender: TObject);
begin
  Test;
end;

procedure TMainForm.txtImageCreatorCommandKeyPress(Sender: TObject;
  var Key: Char);
begin
  if Key=#13 then Test;
end;

procedure TMainForm.initPanelImageCreator;
var
  cstr, cstr2 :  array[0..1024] of char;
  parametersCount, p : Integer;
begin
  txtImageCreatorHelp.Lines.Clear;
  parametersCount := getParametersCount( filterImageCreator );
  for p:=0 to parametersCount-1 do begin
    getParameterName( filterImageCreator, p, cstr );
    getParameterHelp( filterImageCreator, p, cstr2 );
    txtImageCreatorHelp.Lines.Add( '[' + StrPas( cstr ) + '] > ' +StrPas( cstr2 ) );
  end;
end;

procedure TMainForm.rgrpMorphoSEClick(Sender: TObject);
begin
  updateMorphologySE();
  Test;
end;

procedure TMainForm.updateMorphologySE;
var
  SE_size : Integer;
  r, c : Integer;
  value : TColor32;
begin
  SE_size := sbMorphologySE_size.Position;
  case rgrpMorphoSE.ItemIndex of
    0 : // custom
    begin
      if SE_size<>morphoSE.Width then begin
        morphoSE := image.createImage( SE_size, SE_size );
      end;
    end;
    1 : // disk
    begin
      image.freeImage( morphoSE );
      morphoSE := fmask.createMask( SE_size, SE_size, maskDisk );
    end;
    2 : // filled
    begin
      image.freeImage( morphoSE );
      morphoSE := fmask.createMask( SE_size, SE_size, maskFilled );
    end;
    3 : // cross
    begin
      image.freeImage( morphoSE );
      morphoSE := fmask.createMask( SE_size, SE_size, maskCross );
    end;
    4 : // empty
    begin
      morphoSE := image.createImage( SE_size, SE_size );
    end;
  end;
  gridMorphologySE.ColCount := SE_size;
  gridMorphologySE.RowCount := SE_size;
  for r:=0 to SE_size-1 do begin
    for c:=0 to SE_size-1 do begin
      gridMorphologySE.Cells[c,r] := '';
      value := image.getPixel( morphoSE, c, r );
      if value<>0 then begin
        gridMorphologySE.Cells[c,r] := 'X';
      end;
    end;
  end;
end;

procedure TMainForm.gridMorphologySEMouseDown(Sender: TObject;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
  col, row: Longint;
  value : TColor32;
begin
  gridMorphologySE.MouseToCell(X, Y, col, row);
  if Button=mbLeft then value := clWhite32 else value := 0;
  image.setPixel( morphoSE, col, row, value );
  updateMorphologySE();
  Test;
end;

procedure TMainForm.gridMorphologySEMouseMove(Sender: TObject;
  Shift: TShiftState; X, Y: Integer);
var
  col, row: Longint;
  value : TColor32;
begin
  if (ssLeft in Shift) or (ssRight in Shift)	then begin
    gridMorphologySE.MouseToCell(X, Y, col, row);
    if ssLeft in Shift then value := clWhite32 else value := 0;
    image.setPixel( morphoSE, col, row, value );
    updateMorphologySE();
    Test;
  end;
end;

procedure TMainForm.cbContrastExplorerModeChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.sbCooccurenceHorSizeChange(Sender: TObject);
begin
  txtHorCoSize.Text:=IntToStr(sbCooccurenceHorSize.Position);
  txtVerCoSize.Text:=IntToStr(sbCooccurenceVerSize.Position);
  txtCoocurrenceScale.Text := IntToStr(sbCoOccurenceScale.Position);
  Test;
end;

procedure TMainForm.cbCopyOutputColorChange(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.rdCoocurenceClick(Sender: TObject);
begin
  Test ;
end;

procedure TMainForm.chkSobelAngleCalculationClick(Sender: TObject);
begin
  Test;
end;

procedure TMainForm.chkCoocurenceResultROIClik(Sender: TObject);
begin
  shpViewerToolROI.Visible := chkCoocurenceResultROI.Checked ;
  Test ;
end;

procedure TMainForm.sbNonMaximaSuppressionGainChange(Sender: TObject);
begin
  txtNonMaximaSuppressionGain.Text := IntToStr( sbNonMaximaSuppressionGain.Position );
  Test();
end;

procedure TMainForm.chkSusanAngleCalculationClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbSusanGainChange(Sender: TObject);
begin
  txtSusanGain.Text := IntToStr(sbSusanGain.Position);
  Test();
end;

procedure TMainForm.ViewerImageOutDblClick(Sender: TObject);
begin
  cmdCopyImageOutClick(Self);
end;

procedure TMainForm.chkCoocurenceShift45Click(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbGranularityExplorerDifferenceThresholdChange(
  Sender: TObject);
begin
  txtGranularityExplorerDifferenceThreshold.Text := IntToStr( sbGranularityExplorerDifferenceThreshold.Position );
  Test();
end;

procedure TMainForm.lstStackAnalyserAnalyseClick(Sender: TObject);
var
  images : PArrayOfPBitmap32 ;
begin
  images := getOutputImages( filterStackAnalyser, 'outImages' );
  if (images<>nil) and (length(images^) > lstStackAnalyserAnalyse.ItemIndex) and (lstStackAnalyserAnalyse.ItemIndex<>-1) then begin
    image1 := images^[lstStackAnalyserAnalyse.ItemIndex];
    if image1 <> nil Then Begin
      imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
      image.copyImageToImage( image1, imageOut );
      imageIOVideo.showImage( image1, ViewerImageOut );
    end;
  end else begin
    Test();
  end;
end;

procedure TMainForm.sbStackAnalyserInImagesChange(Sender: TObject);
begin
  if length(imagesInStackAnalyser)=0 then begin
    preprocessStackAnalyser();
  end;
  image2 := imagesInStackAnalyser[sbStackAnalyserInImages.position];
  if image2 <> nil Then Begin
    imageOut2 := image.eraseOrCreateImageLike( imageOut2, image2 );
    image.copyImageToImage( image2, imageOut2 );
    imageIOVideo.showImage( image2, ViewerImageOut2 );
  end;
end;

procedure TMainForm.chkMaskClick(Sender: TObject);
begin
  if chkMask.Checked=False then begin
    image.freeImage( imageMask );
  end;
  Test();
end;

procedure TMainForm.sbStackCreatorImageIndexChange(Sender: TObject);
var
  images : PArrayOfPBitmap32;
begin
  txtStackCreatorImageIndex.Text := IntToStr( sbStackCreatorImageIndex.Position );
  txtStackCreatorStackSize.Text := IntToStr( sbStackCreatorStackSize.Position );
  images := getOutputImages( filterStackCreator, 'outImages' );
  if (images<>nil) and (Length(images^)>0) then begin
    sbStackCreatorImageIndex.Max := Length(images^)-1 ;
    image1 := images^[sbStackCreatorImageIndex.position];
    imageOut := image.eraseOrCreateImageLike(imageOut,image1);
    image.copyImageToImage( image1, imageOut );
    imageIOVideo.showImage(imageOut,ViewerImageOut);
  end;
end;

procedure TMainForm.chkStackCreatorDemoStackAnalyserClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.lstEnvelopeOutputsClick(Sender: TObject);
var
  images : PArrayOfPBitmap32 ;
begin
  images := getOutputImages( filterEnvelope, 'outImages' );
  if (images<>nil) and (length(images^) > lstEnvelopeOutputs.ItemIndex) and (lstEnvelopeOutputs.ItemIndex<>-1) then begin
    image1 := images^[lstEnvelopeOutputs.ItemIndex];
    if image1 <> nil Then Begin
      imageOut := image.eraseOrCreateImageLike( imageOut, image1 );
      image.copyImageToImage( image1, imageOut );
      imageIOVideo.showImage( image1, ViewerImageOut );
    end;
    processViewerTool();
  end else begin
    Test();
  end;
end;

procedure TMainForm.sbEnvelopeSmoothChange(Sender: TObject);
begin
  txtEnvelopeSmooth.Text := IntToStr( sbEnvelopeSmooth.Position );
  Test();
end;

procedure TMainForm.sbMeansPrecisionChange(Sender: TObject);
begin
  txtMeansPrecision.Text := IntToStr( sbMeansPrecision.Position );
  Test();
end;

procedure TMainForm.cbAddModeChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.chkAdjustAutoClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbLogIntensityMaxChange(Sender: TObject);
begin
  txtLogIntensityMax.Text := IntToStr(sbLogIntensityMax.Position);
  Test();
end;

procedure TMainForm.sbRGBConstantRChange(Sender: TObject);
begin
  txtRGBConstantR.Text:=IntToStr(sbRGBConstantR.Position);
  txtRGBConstantG.Text:=IntToStr(sbRGBConstantG.Position);
  txtRGBConstantB.Text:=IntToStr(sbRGBConstantB.Position);
  Test();
end;

procedure TMainForm.chkBlobExplorerIntensityInvertClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.sbHoughTransformThresholdChange(Sender: TObject);
begin
  txtHoughTransformThreshold.Text:=IntToStr(sbHoughTransformThreshold.Position);
  Test();
end;

procedure TMainForm.cbHoughTransformPreprocessorChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cbBlobExplorerImageToShowChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cbPluginSampleOutputImagesChange(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.txtPluginSampleParameterIntegerChange(Sender: TObject);
begin
  if txtPluginSampleParameterInteger.Text='' then txtPluginSampleParameterInteger.Text:='0';
  if txtPluginSampleParameterFloat.Text='' then txtPluginSampleParameterFloat.Text:='0.0';
  if txtPluginTestC_ParameterInteger.Text='' then txtPluginTestC_ParameterInteger.Text:='0';
  if txtPluginTestC_ParameterFloat.Text='' then txtPluginTestC_ParameterFloat.Text:='0.0';
  Test();
end;

procedure TMainForm.chkPluginSampleParameterBooleanClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.txtImageCreatorHelpDblClick(Sender: TObject);
begin
  txtImageCreatorCommand.Text := txtImageCreatorHelp.SelText ;
  Test;
end;

procedure TMainForm.chkPluginVideoShowViewerClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cmdPluginVideoFileNameClick(Sender: TObject);
begin
  if dlgPluginVideoOpen.Execute then Begin
    txtPluginVideoFileName.Text := dlgPluginVideoOpen.FileName;
  end;
end;

procedure TMainForm.lstPluginVideoCommandClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.cmdPluginVideoLoadClick(Sender: TObject);
begin
  _runCommand := 'LOAD';
  Test();
end;

procedure TMainForm.cmdPluginVideoPlayClick(Sender: TObject);
begin
  _runCommand := 'PLAY';
  Test();
end;

procedure TMainForm.cmdPluginVideoStopClick(Sender: TObject);
begin
  _runCommand := 'STOP';
  Test();
end;

procedure TMainForm.cmdPluginVideoPauseClick(Sender: TObject);
begin
  _runCommand := 'PAUSE';
  Test();
end;

procedure TMainForm.btnPluginWebCamGetDevicesClick(Sender: TObject);
begin
  _runCommand := 'READ_DEVICES';
  Test();
end;

procedure TMainForm.lbPluginWebCamDevicesClick(Sender: TObject);
begin
  txtPluginWebCamDeviceIndex.Text := IntToStr( lbPluginWebCamDevices.ItemIndex );
end;

procedure TMainForm.btnPluginWebCamGetFormatsClick(Sender: TObject);
begin
  _runCommand := 'READ_DEVICE_FORMAT';
  Test();
end;

procedure TMainForm.lbPluginWebCamDevicesDblClick(Sender: TObject);
begin
  _runCommand := 'READ_DEVICE_FORMAT';
  Test();
end;

procedure TMainForm.chkPluginWebCamDeviceOpenCloseClick(Sender: TObject);
begin
  _runCommand := 'DEVICE_CLOSE';
  if chkPluginWebCamDeviceOpenClose.Checked=true then _runCommand := 'DEVICE_OPEN';
  Test();
end;

procedure TMainForm.lbPluginWebCamDeviceFormatsClick(Sender: TObject);
begin
  txtPluginWebCamFormatIndex.Text := IntToStr( lbPluginWebCamDeviceFormats.ItemIndex );
end;

procedure TMainForm.lbPluginWebCamDeviceFormatsDblClick(Sender: TObject);
begin
  chkPluginWebCamDeviceOpenClose.Checked := False;
  chkPluginWebCamDeviceOpenClose.Checked := True;
end;

procedure TMainForm.chkPluginViewerShowViewerClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.chkBlobExplorerContourClick(Sender: TObject);
begin
  Test();
end;

procedure TMainForm.btnPluginSnapShotGetWindowsTitleClick(Sender: TObject);
begin
  _runCommand := 'GET_WINDOWS_TITLE';
  Test();
end;

procedure TMainForm.lbPluginSnapShotWindowsTitleDblClick(Sender: TObject);
begin
  txtPluginSnapShotWindowTitle.Text := lbPluginSnapShotWindowsTitle.Items[lbPluginSnapShotWindowsTitle.ItemIndex];
  txtPluginSnapShotWindowHandle.Text := '';
  Test();
end;

procedure TMainForm.lbPluginSnapShotWindowsTitleClick(Sender: TObject);
begin
  txtPluginSnapShotWindowTitle.Text := lbPluginSnapShotWindowsTitle.Items[lbPluginSnapShotWindowsTitle.ItemIndex];
  txtPluginSnapShotWindowHandle.Text := '';
end;

procedure TMainForm.btnPluginSnapShotApplicationClick(Sender: TObject);
var
  SEInfo: TShellExecuteInfo;
  ExitCode: DWORD;
  ExecuteFile, ParamString, StartInString: string;
begin
  ExecuteFile:=txtPluginSnapShotApplication.Text;
  FillChar(SEInfo, SizeOf(SEInfo), 0);
  SEInfo.cbSize := SizeOf(TShellExecuteInfo);
  with SEInfo do begin
   fMask := SEE_MASK_NOCLOSEPROCESS;
   Wnd := Application.Handle;
   lpFile := PChar(ExecuteFile);
   nShow := SW_SHOWNORMAL;
  end;
  ShellExecuteEx(@SEInfo);
end;

end.

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.