Example #1
0
        /// <summary>
        /// Color Filter constructor
        /// </summary>
        public ColorFilter()
        {
            FilterParameter grayScaleConversion = new FilterParameter(GRAYSCALE, "Conversion to GrayScale", false);
            FilterParameter alphaCoefficient    = new FilterParameter(ALPHA + COEFF, "Alpha coefficient", 1.0);
            FilterParameter alphaOffset         = new FilterParameter(ALPHA + OFFSET, "Alpha Offset", 0.0);
            FilterParameter redCoefficient      = new FilterParameter(RED + COEFF, "Red coefficient", 1.0);
            FilterParameter redOffset           = new FilterParameter(RED + OFFSET, "Red Offset", 0.0);
            FilterParameter greenCoefficient    = new FilterParameter(GREEN + COEFF, "Green coefficient", 1.0);
            FilterParameter greenOffset         = new FilterParameter(GREEN + OFFSET, "Green Offset", 0.0);
            FilterParameter blueCoefficient     = new FilterParameter(BLUE + COEFF, "Blue coefficient", 1.0);
            FilterParameter blueOffset          = new FilterParameter(BLUE + OFFSET, "Blue Offset", 0.0);


            AddParameter(alphaCoefficient);
            AddParameter(alphaOffset);

            AddParameter(redCoefficient);
            AddParameter(redOffset);

            AddParameter(greenCoefficient);
            AddParameter(greenOffset);

            AddParameter(blueCoefficient);
            AddParameter(blueOffset);

            AddParameter(grayScaleConversion);
        }
Example #2
0
        /// <summary>
        /// Create an instance of the ChannelOperationFilter class
        /// </summary>
        public ChannelOperationFilter()
        {
            FilterParameter splitChannels = new FilterParameter(SPLITCHANNEL, "Split the image into 4 IImageAdapter (one per channel)", true);
            FilterParameter reinjectAlphaInAllChannels = new FilterParameter(REINJECTLAPHA, "Set the alpha value of every channel to the original alpha for easy viewing", true);

            FilterParameter joinChannels     = new FilterParameter(JOINCHANNEL, "Merge the IImageAdapter into 1 ", false);
            FilterParameter addChannels      = new FilterParameter(ADDCHANNEL, "Add the channel value of the image to the IImageAdapter", false);
            FilterParameter subtractChannels = new FilterParameter(SUBTRACTCHANNEL, "Substract the channel value of the image from the IImageAdapter (color starvation is likely to occur)", false);
            FilterParameter multiplyChannels = new FilterParameter(MULTIPLYCHANNEL, "Multiply the channel value of the image to the IImageAdapter", false);
            FilterParameter divideChannels   = new FilterParameter(DIVIDECHANNEL, "Divide the channel value of the image from the IImageAdapter", false);


            FilterParameter alphaChannel = new FilterParameter(ALPHACHANNEL, "The Alpha composant of the image to be added to IImageAdapter", new ImageAdapter(0, 0));
            FilterParameter redChannel   = new FilterParameter(REDCHANNEL, "The Red composant of the image to be added to IImageAdapter", new ImageAdapter(0, 0));
            FilterParameter greenChannel = new FilterParameter(GREENCHANNEL, "The Green composant of the image to be added to IImageAdapter", new ImageAdapter(0, 0));
            FilterParameter blueChannel  = new FilterParameter(BLUECHANNEL, "The Blue composant of the image to be added to IImageAdapter", new ImageAdapter(0, 0));


            AddParameter(splitChannels);
            AddParameter(joinChannels);
            AddParameter(addChannels);
            AddParameter(subtractChannels);
            AddParameter(multiplyChannels);
            AddParameter(divideChannels);
            AddParameter(alphaChannel);
            AddParameter(redChannel);
            AddParameter(greenChannel);
            AddParameter(blueChannel);
            AddParameter(reinjectAlphaInAllChannels);
        }
Example #3
0
        /// <summary>
        /// Tint Filter constructor
        /// </summary>
        public TintFilter()
        {
            FilterParameter amount = new FilterParameter(AMOUNT, "Tint Amount", (double)0.0);
            FilterParameter hue    = new FilterParameter(HUE, "Tint Hue", (double)0.0);

            AddParameter(amount);
            AddParameter(hue);
        }
Example #4
0
        /// <summary>
        /// MorphShape Filter constructor
        /// </summary>
        public MorphShapeFilter()
        {
            FilterParameter morphShape      = new FilterParameter(MORPHSHAPE, "Morph the image to be contained in another shape", (Shape)Shape.Circle);
            FilterParameter extendToMaxSide = new FilterParameter(EXTENDTOMAXSIDE, "Extend the image to the biggest size (Width / Height)", (bool)false);

            AddParameter(extendToMaxSide);
            AddParameter(morphShape);
        }
Example #5
0
        /// <summary>
        /// Blur Filter constructor
        /// </summary>
        public BlurFilter()
        {
            FilterParameter radius = new FilterParameter(RADIUS, "The value of the Radius to use for the blur", (double)0.0);
            FilterParameter expand = new FilterParameter(EXPAND, "Indicates if the data should be mirrored to fit in the filter (side effect) or dropped resulting in fading on the edges", false);

            AddParameter(radius);
            AddParameter(expand);
        }
Example #6
0
        /// <summary>
        /// Sharpen Filter constructor
        /// </summary>
        public SharpenFilter()
        {
            FilterParameter amount = new FilterParameter(AMOUNT, "Sharpen Amount", (double)0.0);
            FilterParameter radius = new FilterParameter(RADIUS, "Sharpen Radius", (double)0.0);

            AddParameter(amount);
            AddParameter(radius);
        }
Example #7
0
        /// <summary>
        /// Create a new instance of the PixelizeFilter class
        /// </summary>
        public PixelizeFilter()
        {
            FilterParameter squareSize   = new FilterParameter(SQUARESIZE, "The size of the square in the mosaic", (int)1);
            FilterParameter useMean      = new FilterParameter(USEMEAN, "Mean or average", (bool)false);
            FilterParameter extendedSize = new FilterParameter(EXTENDEDSIZE, "Mean or average", (int)-1);

            AddParameter(squareSize);
            AddParameter(useMean);
            AddParameter(extendedSize);
        }
Example #8
0
        /// <summary>
        /// Instanciate a BrightnessContrastFilter class
        /// </summary>
        public BrightnessContrastFilter()
        {
            FilterParameter contrast   = new FilterParameter(CONTRAST, "Adjust the contrast of the image", (double)0.0);
            FilterParameter brightness = new FilterParameter(BRIGHTNESS, "Adjust the brightness of the image", (double)0.0);
            FilterParameter autoAdjust = new FilterParameter(AUTOADJUST, "Automatically adjust the contrast and brightness of the image", (bool)false);

            AddParameter(brightness);
            AddParameter(contrast);
            AddParameter(autoAdjust);
        }
Example #9
0
        /// <summary>
        /// GammaCorrect Filter constructor
        /// </summary>
        public GammaCorrectFilter()
        {
            FilterParameter redgamma   = new FilterParameter(REDGAMMA, "Gamma of Red Channel", (double)1.0);
            FilterParameter greengamma = new FilterParameter(GREENGAMMA, "Gamma of Green Channel", (double)1.0);
            FilterParameter bluegamma  = new FilterParameter(BLUEGAMMA, "Gamma of Blue Channel", (double)1.0);

            AddParameter(redgamma);
            AddParameter(greengamma);
            AddParameter(bluegamma);
        }
Example #10
0
        /// <summary>
        /// Gaussian Filter constructor
        /// </summary>
        public GaussianFilter()
        {
            FilterParameter length = new FilterParameter(LENGTH, "The length of the filter", (int)0);
            FilterParameter sigma  = new FilterParameter(SIGMA, "The value of the Gaussian", (double)1.0);
            FilterParameter kernel = new FilterParameter(KERNEL, "The kernel to be used for the Gaussian", (double[])new double[0]);

            AddParameter(length);
            AddParameter(sigma);
            AddParameter(kernel);
        }
Example #11
0
        //
        #endregion Public properties
        #endregion properties

        #region Constructor
        /// <summary>
        /// Create a new instance of the OpacityPoints filter
        /// </summary>
        public OpacityPointsFilter()
        {
            FilterParameter radius     = new FilterParameter(RADIUS, "Radius of the Fading", (double)100.0);
            FilterParameter points     = new FilterParameter(POINTS, "Radius of the Glow", (System.Drawing.Point[]) new System.Drawing.Point[0]);
            FilterParameter fadingType = new FilterParameter(FADINGTYPE, "The Type of Fading", (FadingType)FadingType.OpaqueToTranslucent);

            AddParameter(fadingType);
            AddParameter(points);
            AddParameter(radius);
        }
Example #12
0
        /// <summary>
        /// Color Transform Filter constructor
        /// </summary>
        public ColorTransformFilter()
        {
            FilterParameter srccolor    = new FilterParameter(SOURCECOLOR, "Source Color Context", (string)"sRGB");
            FilterParameter dstcolor    = new FilterParameter(DESTINATIONCOLOR, "Destination Color Context", (string)"RGB");
            FilterParameter pixelformat = new FilterParameter(PIXELFORMAT, "Pixel Format", (string)"ARGB32");

            AddParameter(srccolor);
            AddParameter(dstcolor);
            AddParameter(pixelformat);
        }
Example #13
0
        /// <summary>
        /// Tint Filter constructor
        /// </summary>
        public TintShadeFilter()
        {
            FilterParameter amount         = new FilterParameter(AMOUNT, "Tint Amount", (double)0.0);
            FilterParameter hue            = new FilterParameter(HUE, "Tint Hue", (double)0.0);
            FilterParameter redLuminance   = new FilterParameter(REDLUMINANCE, "Red paricipation in Luminance", (double)_redLuminance);
            FilterParameter greenLuminance = new FilterParameter(GREENLUMINANCE, "Green paricipation in Luminance", (double)_greenLuminance);
            FilterParameter blueLuminance  = new FilterParameter(BLUELUMINANCE, "Blue paricipation in Luminance", (double)_blueLuminance);

            AddParameter(amount);
            AddParameter(hue);
        }
Example #14
0
        /// <summary>
        /// Instantiate a OrderStatisticFilter class
        /// </summary>
        public OrderStatisticFilter()
        {
            FilterParameter mean     = new FilterParameter(MEAN, "Replace every pixel by the mean of the ones nearby ", true);
            FilterParameter min      = new FilterParameter(MAX, "Replace every pixel by the min of the ones nearby ", false);
            FilterParameter max      = new FilterParameter(MIN, "Replace every pixel by the max of the ones nearby ", false);
            FilterParameter maskSize = new FilterParameter(MASKSIZE, "The area to apply the filter on", 3);

            AddParameter(mean);
            AddParameter(min);
            AddParameter(max);
            AddParameter(maskSize);
        }
Example #15
0
        /// <summary>
        /// Attractor Filter constructor
        /// </summary>
        public AttractorFilter()
        {
            FilterParameter threshold  = new FilterParameter(THRESHOLD, "The threshold value", (double)1024);
            FilterParameter attractors = new FilterParameter(ATTRACTORS, "The Attractor Normalized Colors", (Color[])new Color[] { Color.White, Color.Black });
            FilterParameter automatic  = new FilterParameter(AUTOMATIC, "Turn the binarize to be automatic", (bool)true);
            FilterParameter automaticNumberOfColors = new FilterParameter(AUTOMATICNUMBEROFCOLORS, "The number of color per channel (used by automatic binarizing)", new byte[] { 255, 255, 255 });

            AddParameter(threshold);
            AddParameter(attractors);
            AddParameter(automatic);
            AddParameter(automaticNumberOfColors);
        }
Example #16
0
        /// <summary>
        /// Affine Filter constructor
        /// </summary>
        public GeometryFilter() : base()
        {
            FilterParameter matrix            = new FilterParameter(MATRIX, "Transform matrix", new Matrix2D());
            FilterParameter width             = new FilterParameter(WIDTH, "Result width", (int)0);
            FilterParameter height            = new FilterParameter(HEIGHT, "Result Height", (int)0);
            FilterParameter smoothSubSampling = new FilterParameter(LPFSUBSAMPLING, "Low Pass filter the image before sub-sampling (Width and Height reduction)", true);

            AddParameter(matrix);
            AddParameter(width);
            AddParameter(height);
            AddParameter(smoothSubSampling);
        }
Example #17
0
        /// <summary>
        /// Flip/Rotate Filter constructor
        /// </summary>
        public FlipRotateFilter()
        {
            _innerFilter = new SpatialTransformFilter();

            FilterParameter flipVertical   = new FilterParameter(FLIPVERTICAL, "Verical flip of the image", (bool)false);
            FilterParameter flipHorizontal = new FilterParameter(FLIPHORIZONTAL, "Horizontal Flip of the image", (bool)false);
            FilterParameter rotation       = new FilterParameter(ROTATION, "Rotate the image", (RotationValue)RotationValue.NoRotation);

            AddParameter(flipVertical);
            AddParameter(flipHorizontal);
            AddParameter(rotation);
        }
Example #18
0
        /// <summary>
        /// Instanciate a new SaturateEdgeFilter object
        /// </summary>
        public SaturateEdgeFilter()
        {
            double [,] kernelValues = new double[, ] {
                { 0, -1, 0 }, { -1, 4, -1 }, { 0, -1, 0 }
            };
            FilterParameter threshold  = new FilterParameter(THRESHOLD, "Thresold for the saturating value", (double)0.01);
            FilterParameter kernel     = new FilterParameter(KERNEL, "Laplacian Kernel", (double[, ])kernelValues);
            FilterParameter colorAbove = new FilterParameter(COLORABOVE, "Color to use if edge find and above threshold", (IColor) new ColorByte(255, 255, 0, 0));
            FilterParameter colorBelow = new FilterParameter(COLORBELOW, "Color to use if below threshold", (IColor) new ColorByte());

            AddParameter(threshold);
            AddParameter(kernel);
            AddParameter(colorAbove);
            AddParameter(colorBelow);
        }
Example #19
0
        /// <summary>
        /// Glow Filter constructor
        /// </summary>
        public GlowFilter()
        {
            FilterParameter radius      = new FilterParameter(RADIUS, "Radius of the Glow", (double)10.0);
            FilterParameter intensity   = new FilterParameter(INTENSITY, "Intensity of the Glow", (double)0.5);
            FilterParameter aspectratio = new FilterParameter(ASPECTRATIO, "Aspect Ratio of the Glow", (double)0.0);
            FilterParameter composite   = new FilterParameter(COMPOSITE, "Compose original image with Glow?", (bool)true);
            FilterParameter innercolor  = new FilterParameter(INNERCOLOR, "Inner Color of the Glow", (Color)Color.FromArgb(0x00, 0xff, 0xff, 0xff));
            FilterParameter outercolor  = new FilterParameter(OUTERCOLOR, "Outer Color of the Glow", (Color)Color.FromArgb(0x00, 0x00, 0xff, 0x00));

            AddParameter(radius);
            AddParameter(intensity);
            AddParameter(aspectratio);
            AddParameter(composite);
            AddParameter(innercolor);
            AddParameter(outercolor);
        }
Example #20
0
        /// <summary>
        /// Filter implementation with rectangle clipping effect.
        /// if a rectangle does not cover a pixel in the processed image,
        /// the pixel keeps its original value;
        /// </summary>
        protected void AddParameter(FilterParameter parameter)
        {
            if (parameter == null)
            {
                throw new ArgumentNullException("parameter", "Parameter must be a valid instance of FilterParameter (null passed in)");
            }

            if (!_params.Contains(parameter.Name))
            {
                _params.Add(parameter.Name, parameter);
            }
            else
            {
                _params[parameter.Name] = parameter;
            }
        }
Example #21
0
        /// <summary>
        /// Create an instance of the LogicalOperationFilter class
        /// </summary>
        public LogicalOperationFilter()
        {
            FilterParameter ANDparam    = new FilterParameter(AND, "Apply the Logical operation AND on this IImageAdapter", false);
            FilterParameter ORparam     = new FilterParameter(OR, "Apply the Logical operation OR on this IImageAdapter", false);
            FilterParameter XORparam    = new FilterParameter(XOR, "Apply the Logical operation XOR on this IImageAdapter", false);
            FilterParameter maskParam   = new FilterParameter(MASK, "Mask to be used on the original image", (ImageAdapter) new ImageAdapter(1, 1));
            FilterParameter ignoreAlpha = new FilterParameter(IGNOREALPHA, "Include - or not - the alpha channel in the operation", true);

            FilterParameter NOTparam = new FilterParameter(NOT, "Apply the Logical operation NOT on this IImageAdapter", true);

            AddParameter(ANDparam);
            AddParameter(ORparam);
            AddParameter(XORparam);
            AddParameter(NOTparam);
            AddParameter(maskParam);
            AddParameter(ignoreAlpha);
        }
Example #22
0
        /// <summary>
        /// Gaussian Filter constructor
        /// </summary>
        public MorphologicalFilter()
        {
            IColor          white           = new ColorByte(255, 255, 255, 255);
            IColor          black           = new ColorByte(255, 0, 0, 0);
            FilterParameter iteration       = new FilterParameter(ITERATION, "Number of Iteration", (int)1);
            FilterParameter outward         = new FilterParameter(OUTWARD, "Direction of the morphological filter", true);
            FilterParameter foregroundColor = new FilterParameter(FOREGROUNDCOLOR, "ForeGround color", (IColor)white);
            FilterParameter backgroundColor = new FilterParameter(BACKGROUNDCOLOR, "BackGround color", (IColor)black);

            AddParameter(iteration);
            AddParameter(outward);
            AddParameter(foregroundColor);
            AddParameter(backgroundColor);

            ForegroundColor = white;
            BackgroundColor = black;
        }
Example #23
0
        /// <summary>
        /// Affine Filter constructor
        /// </summary>
        public AffineFilter()
        {
            FilterParameter image              = new FilterParameter(IMAGE, "Image to blend", new ImageAdapter(0, 0));
            FilterParameter offsetX            = new FilterParameter(OFFSET_X, "X offset", (int)0);
            FilterParameter offsetY            = new FilterParameter(OFFSET_Y, "Y offset", (int)0);
            FilterParameter offsetCoefficient  = new FilterParameter(OFFSET, "offset coeeficient", (double)0.0);
            FilterParameter leftCoefficient    = new FilterParameter(LEFT, "left coefficient", (double)1.0);
            FilterParameter rightCoefficient   = new FilterParameter(RIGHT, "right coefficient", (double)0.0);
            FilterParameter normalizeTransform = new FilterParameter(NORMALIZE_TRANSFORM, "The Post Process will normalize the results", true);

            AddParameter(image);
            AddParameter(leftCoefficient);
            AddParameter(rightCoefficient);
            AddParameter(offsetCoefficient);
            AddParameter(offsetX);
            AddParameter(offsetY);
            AddParameter(normalizeTransform);
        }
Example #24
0
        /// <summary>
        /// Convolution Filter constructor
        /// </summary>
        public ConvolutionFilter()
        {
            FilterParameter laplacian = new FilterParameter(LAPLACIAN, "Set a Laplacian filter kernel", false);
            FilterParameter emboss    = new FilterParameter(EMBOSS, "Set an Emboss filter kernel", false);
            FilterParameter matrix    = new FilterParameter(MATRIX, "The convolution matrix kernel", new double[, ] {
                { 1.0 }
            });
            FilterParameter derive  = new FilterParameter(DERIVE, "Set a Derive filter kernel", false);
            FilterParameter sharpen = new FilterParameter(SHARPEN, "Set a Sharpen filter kernel", false);
            FilterParameter smooth  = new FilterParameter(SMOOTH, "Set a Smoothing filter kernel", false);
            FilterParameter abs     = new FilterParameter(ABS, "Compute the Abs() of the transform", true);

            AddParameter(matrix);
            AddParameter(derive);
            AddParameter(emboss);
            AddParameter(laplacian);
            AddParameter(sharpen);
            AddParameter(smooth);
            AddParameter(abs);
        }
Example #25
0
        /// <summary>
        /// Instanciate a new SpatialTransformFilter object
        /// </summary>
        public SpatialTransformFilter()
        {
            FilterParameter rotation          = new FilterParameter(ROTATION, "Rotate the image", (double)0.0);
            FilterParameter flipx             = new FilterParameter(FLIPX, "Flip the image horizontally?", (bool)false);
            FilterParameter flipy             = new FilterParameter(FLIPY, "Flip the image veritcally?", (bool)false);
            FilterParameter offsetx           = new FilterParameter(OFFSETX, "shift the image on the X axis", (double)0.0);
            FilterParameter offsety           = new FilterParameter(OFFSETY, "shift the image on the Y axis", (double)0.0);
            FilterParameter scalingx          = new FilterParameter(SCALINGX, "Scale the the image on the X axis", (double)1.0);
            FilterParameter scalingy          = new FilterParameter(SCALINGY, "Scale the the image on the X axis", (double)1.0);
            FilterParameter matrix            = new FilterParameter(MATRIX, "Custom matrix used for the transform", new Matrix2D());
            FilterParameter useMatrix         = new FilterParameter(USEMATRIX, "Direct to use the matrix or the helper units", (bool)true);
            FilterParameter ResizeOutputImage = new FilterParameter(RESIZEOUTPUTIMAGE, "Resize the returned  IImageAdapter to fit the output image", (bool)true);

            AddParameter(rotation);
            AddParameter(flipx);
            AddParameter(flipy);
            AddParameter(offsetx);
            AddParameter(offsety);
            AddParameter(scalingx);
            AddParameter(scalingy);
            AddParameter(matrix);
            AddParameter(useMatrix);
            AddParameter(ResizeOutputImage);
        }
Example #26
0
        private void ProcessFilters(XmlNode node, ref Hashtable aliasCollection)
        {
            // Check params
            if (node == null || node.NodeType != XmlNodeType.Element)
            {
                return;
            }

            // Recurse thru children -- need to process the inner Filter first (most nested one).
            if (((XmlElement)node).HasChildNodes)
            {
                foreach (XmlNode childNode in node)
                {
                    ProcessFilters(childNode, ref aliasCollection);
                }
            }

            // This is a Filter, needs to be applied to the image (IImageAdapter)
            if (((XmlElement)node).Name == "Filter")
            {
                IImageAdapter source     = null;
                Hashtable     parameters = new Hashtable();

                // Get input file (parameters)
                XmlNodeList inputParam = node.SelectNodes("INPUT/*");

                if (inputParam == null || inputParam.Count == 0)
                {
                    throw new XmlException("<INPUT> Tag not found or does not have a(ny) child(ren), invalid xml format");
                }

                foreach (XmlElement xmlElement in inputParam)
                {
                    if (xmlElement.LocalName == "IIMAGEADAPTERSOURCE")
                    {
                        if (xmlElement.HasChildNodes == false)
                        {
                            throw new XmlException("<IIMAGEADAPTERSOURCE> Tag doesn't have any child, invalid xml format");
                        }

                        //

                        source = (ImageAdapter)GetParamValue((XmlElement)xmlElement.FirstChild, aliasCollection, true);
                    }
                    else
                    {
                        object paramValue = GetParamValue(xmlElement, aliasCollection, false);

                        parameters.Add(xmlElement.LocalName, paramValue);
                    }
                }

                // Create filter
                //                Assembly asm = Assembly.LoadFrom(CombinePaths(Directory.GetCurrentDirectory(), VISUALSCANENGINE));
                //                Type filterType = asm.GetType(FILTERNAMESPACE + "." + node.Attributes["name"].Value, false, true);
                Assembly asm        = Assembly.GetExecutingAssembly();
                Type     filterType = asm.GetType(this.GetType().Namespace + "." + node.Attributes["name"].Value, false, true);
                Filter   filter     = asm.CreateInstance(filterType.ToString(), true) as Filter;

                // Set all Filter Parameters defined in XML
                IEnumerator iter = parameters.Keys.GetEnumerator();

                while (iter.MoveNext())
                {
                    string key            = (string)iter.Current;
                    object val            = parameters[key];
                    object convertedValue = null;

                    // Get FilterParam associated with this XmlNode
                    FilterParameter filterParam = (FilterParameter)filterType.InvokeMember("Item", BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase, null, filter, new object[] { key });

                    // Convert Xml string to expected type.
                    Type paramType = filterParam.Parameter.GetType();

                    if (paramType.GetInterface(typeof(IConvertible).ToString()) != null)
                    {
                        // Try to Call "Parse" with culture invariant (double / float / ...)
                        const string PARSE       = "Parse";
                        Type[]       typeToPass  = new Type[] { val.GetType(), CultureInfo.InvariantCulture.GetType() };
                        object[]     paramToPass = new object[] { val, CultureInfo.InvariantCulture };
                        BindingFlags flags       = BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public | BindingFlags.InvokeMethod;
                        MethodInfo   mi          = paramType.GetMethod(PARSE, flags, null, typeToPass, null);

                        if (mi == null)
                        {
                            // Not supported, call "Parse" without culture involved
                            typeToPass  = new Type[] { val.GetType() };
                            paramToPass = new object[] { val };
                            mi          = paramType.GetMethod(PARSE, flags, null, typeToPass, null);
                            if (mi == null)
                            {
                                // What's going on here ? A type that implement IConvertible but not Parse ? Custom ?
                                throw new ApplicationException("The type ('" + filterType.FullName + "')does not implement the Parse Method");
                            }
                        }

                        convertedValue = paramType.InvokeMember(PARSE, flags, null, paramType, paramToPass);
                    }
                    else
                    {
                        if (paramType == typeof(ImageAdapter))
                        {
                            // Ok to Set type directly
                            convertedValue = val;
                        }
                        else
                        {
                            throw new ApplicationException("Unsupported type, Check your filter file. If you are sure it is correct contact the 'avalon test tool team'");
                        }
                    }

                    filterParam.Parameter = convertedValue;
                }

                // Apply filter
                IImageAdapter imageProcessed = filter.Process(source);

                // Add return value and ouput to AliasCollection
                if (node.Attributes["alias"] == null)
                {
                    throw new XmlException("Filter tag must have an 'alias' attribute set");
                }

                string alias = node.Attributes["alias"].Value;

                if (aliasCollection.Contains(alias))
                {
                    throw new XmlException("Duplicate alias found ('" + alias + "'); 'alias' attribute must be unique");
                }

                aliasCollection.Add(alias, imageProcessed);

                // Retrieve OUTPUT params and add to the AliasCollection
                XmlNodeList outputList = node.SelectNodes("OUTPUT/*");

                foreach (XmlElement output in outputList)
                {
                    string param = output.LocalName;

                    if (output.Attributes["alias"] == null)
                    {
                        throw new XmlException("All child of the OUTPUT tag must have an 'alias' attribute set");
                    }

                    string          outputAlias = output.Attributes["alias"].Value;
                    FilterParameter FilterParam = (FilterParameter)filterType.InvokeMember("Item", BindingFlags.GetProperty | BindingFlags.FlattenHierarchy | BindingFlags.Instance | BindingFlags.Public, null, filter, new object[] { param });

                    if (FilterParam == null)
                    {
                        throw new RenderingVerificationException("This filter does not implement the specified property", new MissingMemberException(filterType.FullName, param));
                    }

                    if (aliasCollection.Contains(outputAlias))
                    {
                        throw new XmlException("Duplicate alias found ('" + outputAlias + "'); 'alias' attribute must be unique");
                    }

                    aliasCollection.Add(outputAlias, FilterParam.Parameter as IImageAdapter);
                }
            }
        }
Example #27
0
        /// <summary>
        /// Discret Wavelet Transform Filter constructor
        /// </summary>
        public WaveletTransformFilter()
        {
            FilterParameter level = new FilterParameter(LEVEL, "The value of the Level to use for the details fitlering", (int)1);

            AddParameter(level);
        }
Example #28
0
        /// <summary>
        /// Constructor
        /// </summary>
        public EqualizeFilter()
        {
            FilterParameter adaptiveFilter = new FilterParameter(ADAPTIVE, "Perform an adaptive (local) Equalization", false);

            AddParameter(adaptiveFilter);
        }