/// <summary>
        /// Filter implementation
        /// </summary>
        protected override IImageAdapter ProcessFilter(IImageAdapter source)
        {
            IImageAdapter     retVal    = null;
            Image2DTransforms transform = new Image2DTransforms(source);

            transform.ResizeToFitOutputImage = ResizeOutputImage;
            if (UseMatrix == false)
            {
                if (Rotation % 360.0 != 0.0)
                {
                    transform.RotateTransform(Rotation, AngleUnit.Degree);
                }

                transform.TranslateTransform(HorizontalOffset, VerticalOffset);
                transform.ScaleTransform(HorizontalScaling, VerticalScaling);
                // Note : Cannot use Matrix property as it will reset the "UseMatrix" field
                this[MATRIX].Parameter = transform.ConvertTransformsToMatrix();
            }

            transform.Transform(Matrix);
            retVal = transform.ImageTransformed;

            if (VerticalFlip || HorizontalFlip)
            {
                int           x = 0;
                int           y = 0;
                IImageAdapter imageTransformed = retVal;
                int           width            = (int)imageTransformed.Width;
                int           height           = (int)imageTransformed.Height;
                if (UseMatrix == false)
                {
                    if (HorizontalFlip)
                    {
                        y = height - 1;
                    }
                    if (VerticalFlip)
                    {
                        x = width - 1;
                    }
                }

                retVal = new ImageAdapter(imageTransformed.Width, imageTransformed.Height);
                for (int j = 0; j < height; j++)
                {
                    for (int i = 0; i < width; i++)
                    {
                        retVal[(int)Math.Abs(x - i), (int)Math.Abs(y - j)] = imageTransformed[i, j];
                    }
                }
            }
            return(retVal);
        }
Beispiel #2
0
        /// <summary>
        /// filter implementation
        /// </summary>
        protected override IImageAdapter ProcessFilter(IImageAdapter source)
        {
            // Check Params
            if (source == null)
            {
                throw new ArgumentNullException("source", "Argument cannot be null");
            }
            if (Width == 0)
            {
                Width = source.Width;
            }
            if (Height == 0)
            {
                Height = source.Height;
            }

            if ((Height < source.Height || Width < source.Width) && (LowPassFilterOnSubSampling == true))
            {
                GaussianFilter gf    = new GaussianFilter();
                int            ratio = (int)Math.Max(source.Width / Width, source.Height / Height);
                if (ratio < 1)
                {
                    ratio = 2;
                }
                gf.Length = ratio;
                source    = gf.Process(source);
                Console.WriteLine("<<Proceed with GF subsampling>>");
            }

/*
 *                  //
 *
 *
 *
 */
            Image2DTransforms transform = new Image2DTransforms(source);

            transform.Transform(Matrix);
            return(transform.ImageTransformed);
        }