コード例 #1
0
 public static Bitmap BrightnessControl(this Bitmap bitmap, int brightVal)
 {
     // create filter
     AForge.Imaging.Filters.BrightnessCorrection filter = new AForge.Imaging.Filters.BrightnessCorrection(brightVal);
     // apply the filter
     return(filter.Apply(bitmap));
 }
コード例 #2
0
        private void AdjustThumbnailBrightness(Bitmap loBitmap)
        {
            //Format the image according to AForge.NET needs to apply the filter
            AForge.Imaging.Image.FormatImage(ref loBitmap);
            // Create an instance of the brightness correction filter
            AForge.Imaging.Filters.BrightnessCorrection loBrightnessCorrection = new AForge.Imaging.Filters.BrightnessCorrection(priBrightnessDelta);
            // Process the image (correct the brightness)
            proThumbnailImage = loBrightnessCorrection.Apply(loBitmap);

            Graphics g = Graphics.FromImage((System.Drawing.Image)proThumbnailImage);

            g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
            // Create the string to draw
            string loString = string.Format("Brightness value: {0}", priBrightnessDelta);
            // Create the font and the brush
            Font       loFont  = new Font("Arial", 12);
            SolidBrush loBrush = new SolidBrush(Color.CornflowerBlue);
            // Create the point for the upper-left corner of drawing
            PointF loPoint = new PointF(10.0F, (proThumbnailSize.Height - 50.0F));

            // Draw string to the thumbnail
            g.DrawString(loString, loFont, loBrush, loPoint);
            // Draw a rectangle around the thumbnail
            g.DrawRectangle(new Pen(loBrush, 10), new Rectangle(0, 0, proThumbnailImage.Width, proThumbnailImage.Height));

            g.Dispose();
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: ams342t0/more-assorted-stuff
        private void init()
        {
            gb = new AForge.Imaging.Filters.GaussianBlur();
            cc = new AForge.Imaging.Filters.ContrastCorrection();
            bc = new AForge.Imaging.Filters.BrightnessCorrection();

            th.Minimum = 0;
            th.Maximum = 277695;
            th.Value   = 270000;
        }
コード例 #4
0
ファイル: px.cs プロジェクト: ams342t0/more-assorted-stuff
        private void init()
        {
            gb = new AForge.Imaging.Filters.GaussianBlur();
            cc = new AForge.Imaging.Filters.ContrastCorrection();
            bc = new AForge.Imaging.Filters.BrightnessCorrection();

            th.Minimum = 0;
            th.Maximum = 277695;
            th.Value   = 270000;

            try
            {
                src = Program.pbitmap;
                draw_image();
            }
            catch (Exception xk)
            {
                MessageBox.Show("Error displaying source");
                this.Close();
            }
        }
コード例 #5
0
        /// <summary>
        /// In Fill Mode, we will blur and fill the background
        /// </summary>
        /// <param name="file"></param>
        /// <param name="parameter"></param>
        private static void FillBackground(Image source, Graphics target, ImageFiltrationParameters parameter)
        {
            if (parameter.Mode != ImageResizeMode.FitWithBg)
            {
                return;
            }

            // get blurred image and draw using fit width mode
            var blurFilter = new AForge.Imaging.Filters.GaussianBlur(8, 10);

            using (var blurred = blurFilter.Apply((Bitmap)source))
            {
                var p = new ImageFiltrationParameters(source, parameter.TargetWidth, parameter.TargetHeight, ImageResizeMode.Fill);

                var darken = new AForge.Imaging.Filters.BrightnessCorrection(-100);
                darken.ApplyInPlace(blurred);

                target.DrawImage(blurred, p.ImageOffsetAndSize.Left,
                                 p.ImageOffsetAndSize.Top,
                                 p.ImageOffsetAndSize.Width,
                                 p.ImageOffsetAndSize.Height);
            }
        }
コード例 #6
0
        private void init()
        {
            Graphics g;

            System.Drawing.Image src;
            Pen p;

            AForge.Imaging.Filters.GaussianBlur         gb;
            AForge.Imaging.Filters.ContrastCorrection   cc;
            AForge.Imaging.Filters.BrightnessCorrection bc;
            AForge.Imaging.Filters.Threshold            th;

            gb = new AForge.Imaging.Filters.GaussianBlur();
            cc = new AForge.Imaging.Filters.ContrastCorrection();
            bc = new AForge.Imaging.Filters.BrightnessCorrection();
            th = new AForge.Imaging.Filters.Threshold();


            // load image source
            src = System.Drawing.Image.FromFile(@"d:\source.png");


            gb.Size        = 2;
            cc.Factor      = 40;
            bc.AdjustValue = -30;

            src = (System.Drawing.Image)(cc.Apply(bc.Apply(gb.Apply((Bitmap)src))));

            pictureBox1.Image = new Bitmap(pictureBox1.Width, pictureBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            g = Graphics.FromImage(pictureBox1.Image);

            img = (Bitmap)pictureBox1.Image;

            width  = img.Width;
            height = img.Height;
            blk_w  = width / 9;
            blk_h  = height / 9;

            g.FillRectangle(Brushes.White, pictureBox1.DisplayRectangle);
            g.DrawImage(src, new Rectangle(0, 0, pictureBox1.Width, pictureBox1.Height), new Rectangle(0, 0, src.Width, src.Height), GraphicsUnit.Pixel);

            p = new Pen(Color.White, 20);


            for (int iy = 0; iy < 9; iy++)
            {
                g.DrawLine(p, 0, iy * blk_h, width, iy * blk_h);
            }

            g.DrawLine(p, 0, height - 1, width, height - 1);

            for (int ix = 0; ix < 9; ix++)
            {
                g.DrawLine(p, ix * blk_w, 0, ix * blk_w, height);
            }
            g.DrawLine(p, width - 1, 0, width - 1, height - 1);


            // init destination image
            // set destination width and height

            textBox1.Text = "290000";
        }
コード例 #7
0
ファイル: SelectAreasForm.cs プロジェクト: crisguycabs/origin
        /// <summary>
        /// Modifica el brillo y contraste de la imagen que aparece en pantalla
        /// </summary>
        private void Filtrar(int n)
        {
            Bitmap temp = MyDicom.CrearBitmap(padre.actual.datacuboHigh.dataCube[n - 1].segCore, padre.actual.areaCore.width * 2, padre.actual.areaCore.width * 2);

            AForge.Imaging.Filters.BrightnessCorrection brillo = new AForge.Imaging.Filters.BrightnessCorrection(Convert.ToInt32(trackBrillo.Value));
            AForge.Imaging.Filters.ContrastCorrection contraste = new AForge.Imaging.Filters.ContrastCorrection(Convert.ToInt32(trackContraste.Value));

            contraste.ApplyInPlace(temp);
            brillo.ApplyInPlace(temp);

            pictCore.Image = temp;

            //pictElemento.Invalidate();
        }