Beispiel #1
0
        public Bitmap YCbCrLinearFilter(Bitmap img)
        {
            YCbCrLinear filter = new YCbCrLinear();

            filter.InCb = new AForge.Range(-0.276f, 0.163f);
            filter.InCr = new AForge.Range(-0.202f, 0.500f);
            return(filter.Apply(img));
        }
Beispiel #2
0
        public static Bitmap ApplyYCbCrLinearFilter(Bitmap sourceImage)
        {
            var filter = new YCbCrLinear {
                InCb = new Range(-0.3f, 0.3f)
            };

            return(ApplyFilterBitmap(filter, sourceImage));
        }
Beispiel #3
0
        // On Filters->YCbCr filtering
        private void yCbCrLinearFiltersItem_Click(object sender, System.EventArgs e)
        {
            YCbCrLinear filter = new YCbCrLinear( );

            filter.InCb = new Range(-0.3f, 0.3f);

            ApplyFilter(filter);
            yCbCrLinearFiltersItem.Checked = true;
        }
Beispiel #4
0
        private void yCbCrLinearCorrectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UncheckAllMenuItems();
            YCbCrLinear filter = new YCbCrLinear();

            filter.InCb = new Range(-0.3f, 0.3f);

            ApplyFilter(filter);
            yCbCrLinearCorrectionToolStripMenuItem.Checked = true;
        }
Beispiel #5
0
        // On Filters->YCbCr filtering
        /// <summary>
        /// 该滤波器工作在YCbCr颜色空间中,
        /// 并且提供对其通道的线性校正设施——将指定通道的输入范围映射到指定输出范围。
        /// 能够改变图像的色彩
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void yCbCrLinearFiltersItem_Click(object sender, System.EventArgs e)
        {
            YCbCrLinear filter = new YCbCrLinear();

            //InCb:[-0.5~0.5]
            //InCr:[-0.5~0.5]
            //InY:[0~1]
            filter.InCb = new Range(-0.276f, 0.163f);
            filter.InCr = new Range(-0.202f, 0.500f);
            ApplyFilter(filter);
            yCbCrLinearFiltersItem.Checked = true;
        }
Beispiel #6
0
        public mFilterYCbCrLinear(wDomain YinRange, wDomain CBinRange, wDomain CRinRange, wDomain YoutRange, wDomain CBoutRange, wDomain CRoutRange)
        {
            Yin   = YinRange;
            Yout  = YoutRange;
            Cbin  = CBinRange;
            Cbout = CBoutRange;
            Crin  = CRinRange;
            Crout = CRoutRange;

            BitmapType = mFilter.BitmapTypes.None;

            Effect = new YCbCrLinear();

            Effect.InY  = new Range((float)Yin.T0, (float)Yin.T1);
            Effect.InCb = new Range((float)Cbin.T0, (float)Cbin.T1);
            Effect.InCr = new Range((float)Crin.T0, (float)Crin.T1);

            Effect.OutY  = new Range((float)Yout.T0, (float)Yout.T1);
            Effect.OutCb = new Range((float)Cbout.T0, (float)Cbout.T1);
            Effect.OutCr = new Range((float)Crout.T0, (float)Crout.T1);

            filter = Effect;
        }
Beispiel #7
0
        private Bitmap AddFilter(Bitmap bitmap)
        {
            switch (filterNumber)
            {
            case Filters.BrightnessCorrection:
                return(ApplyFilter(bitmap, new BrightnessCorrection()));

            case Filters.ColorFiltering:
                return(ApplyFilter(bitmap, new ColorFiltering(new IntRange(25, 230), new IntRange(25, 230), new IntRange(25, 230))));

            case Filters.ContrastCorrection:
                return(ApplyFilter(bitmap, new ContrastCorrection()));

            case Filters.DifferenceEdgeDetector:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new DifferenceEdgeDetector()));

            case Filters.FloydSteinbergDithering:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new FloydSteinbergDithering()));

            case Filters.Grayscale:
                return(ApplyFilter(bitmap, Grayscale.CommonAlgorithms.BT709));

            case Filters.HomogenityEdgeDetector:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new HomogenityEdgeDetector()));

            case Filters.HSLFiltering:
                return(ApplyFilter(bitmap, new HSLFiltering(new IntRange(330, 30), new Range(0, 1), new Range(0, 1))));

            case Filters.HueModifier:
                return(ApplyFilter(bitmap, new HueModifier(50)));

            case Filters.Jitter:
                return(ApplyFilter(bitmap, new Jitter()));

            case Filters.LevelsLinear:
                LevelsLinear lfilter = new LevelsLinear();
                lfilter.InRed   = new IntRange(30, 230);
                lfilter.InGreen = new IntRange(50, 240);
                lfilter.InBlue  = new IntRange(10, 210);
                return(ApplyFilter(bitmap, lfilter));

            case Filters.OrderedDithering:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new OrderedDithering()));

            case Filters.RotateChannels:
                return(ApplyFilter(bitmap, new RotateChannels()));

            case Filters.SaturationCorrection:
                return(ApplyFilter(bitmap, new SaturationCorrection(0.15f)));

            case Filters.Sepia:
                return(ApplyFilter(bitmap, new Sepia()));

            case Filters.SobelEdgeDetector:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new SobelEdgeDetector()));

            case Filters.Threshold:
                bitmap = Grayscale.CommonAlgorithms.RMY.Apply(bitmap);
                return(ApplyFilter(bitmap, new Threshold()));

            case Filters.YCbCrFiltering:
                return(ApplyFilter(bitmap, new YCbCrFiltering(new Range(0.2f, 0.9f), new Range(-0.3f, 0.3f), new Range(-0.3f, 0.3f))));

            case Filters.YCbCrLinear:
                YCbCrLinear filter = new YCbCrLinear();
                filter.InCb = new Range(-0.3f, 0.3f);
                return(ApplyFilter(bitmap, filter));

            default:
                return(bitmap);
            }
        }
Beispiel #8
0
        /// <summary>
        /// This is the method that actually does the work.
        /// </summary>
        /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            Bitmap img = null;

            DA.GetData(0, ref img);
            Interval L = new Interval(0, 1);

            DA.GetData("Luminance", ref L);
            Interval S = new Interval(0, 1);

            DA.GetData("Saturation", ref S);
            Interval Y = new Interval(0, 255);

            DA.GetData("Luma", ref Y);
            Interval Cb = new Interval(-1, 1);

            DA.GetData("Chroma_Blue", ref Cb);
            Interval Cr = new Interval(-1, 1);

            DA.GetData("Chroma_Red", ref Cr);
            Interval R = new Interval(0, 255);

            DA.GetData("Red", ref R);
            Interval G = new Interval(0, 255);

            DA.GetData("Green", ref G);
            Interval B = new Interval(0, 255);

            DA.GetData("Blue", ref B);

            Bitmap filteredImage = img;

            Interval bInterval        = new Interval(0, 1);
            Interval Interval255      = new Interval(0, 255);
            Interval IntervalMinusOne = new Interval(-1, 1);

            //////////////////////////////////////////////////////////////////////////
            HSLLinear myHSLfilter = new HSLLinear();

            if (bInterval.IncludesInterval(L))
            {
                myHSLfilter.InLuminance = new AForge.Range(Convert.ToSingle(L.Min), Convert.ToSingle(L.Max));
            }
            if (bInterval.IncludesInterval(S))
            {
                myHSLfilter.InSaturation = new AForge.Range(Convert.ToSingle(S.Min), Convert.ToSingle(S.Max));
            }
            filteredImage = myHSLfilter.Apply(img);
            //////////////////////////////////////////////////////////////////////////
            YCbCrLinear myYCbCrfilter = new YCbCrLinear();

            if (Interval255.IncludesInterval(Y))
            {
                myYCbCrfilter.InCb = new AForge.Range(Convert.ToSingle(Y.Min), Convert.ToSingle(Y.Max));
            }
            if (IntervalMinusOne.IncludesInterval(Cb))
            {
                myYCbCrfilter.InCb = new AForge.Range(Convert.ToSingle(Cb.Min), Convert.ToSingle(Cb.Max));
            }
            if (IntervalMinusOne.IncludesInterval(Cr))
            {
                myYCbCrfilter.InCr = new AForge.Range(Convert.ToSingle(Cr.Min), Convert.ToSingle(Cr.Max));
            }
            filteredImage = myYCbCrfilter.Apply(filteredImage);
            //////////////////////////////////////////////////////////////////////////
            LevelsLinear myRGBfilter = new LevelsLinear();

            if (Interval255.IncludesInterval(R))
            {
                myRGBfilter.InRed = new AForge.IntRange((int)(R.Min), (int)(R.Max));
            }
            if (Interval255.IncludesInterval(G))
            {
                myRGBfilter.InGreen = new AForge.IntRange((int)(G.Min), (int)(G.Max));
            }
            if (Interval255.IncludesInterval(B))
            {
                myRGBfilter.InBlue = new AForge.IntRange((int)(B.Min), (int)(B.Max));
            }
            filteredImage = myRGBfilter.Apply(filteredImage);

            DA.SetData(0, filteredImage);
        }
Beispiel #9
0
 public YCbCrLinearFilter()
 {
     yCbCrLinear      = new YCbCrLinear();
     yCbCrLinear.InCb = new AForge.Range(-0.3f, 0.3f);
 }