Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
        public Bitmap Process(Bitmap image)
        {
            Bitmap filteredImage = convertFormatTo32(image);

            if (filterLevel >= 0)
            {
                filteredImage = resize(filteredImage, ImageSize.Width, ImageSize.Height);
            }
            if (filterLevel >= 1)
            {

                if (ContrastStretch)
                {
                    AForge.Imaging.Filters.ContrastStretch stretcher = new AForge.Imaging.Filters.ContrastStretch();
                    filteredImage = stretcher.Apply(filteredImage);

                }

                if (Histogram)
                {
                    AForge.Imaging.Filters.HistogramEqualization histogrammer = new AForge.Imaging.Filters.HistogramEqualization();
                    filteredImage = histogrammer.Apply(filteredImage);

                }

                if (Gaussian)
                {
                    AForge.Imaging.Filters.GaussianBlur blurrer = new AForge.Imaging.Filters.GaussianBlur();
                    blurrer.Size = (int)GaussianStrength;
                    filteredImage = blurrer.Apply(filteredImage);
                }

                if (ContrastAdjustment)
                {
                    AForge.Imaging.Filters.ContrastCorrection contraster = new AForge.Imaging.Filters.ContrastCorrection();
                    contraster.Factor = (float)ContrastStrength;
                    filteredImage = contraster.Apply(filteredImage);
                }

                if (Greyscale)
                {
                    filteredImage = AForge.Imaging.Filters.Grayscale.CommonAlgorithms.BT709.Apply(filteredImage);
                    //Greyscale downgrades format
                    // filteredImage  = convertFormatTo32(filteredImage.InternalBitmap);
                }
                if (Threshold)
                {
                    //filteredImage.InternalBitmap = convertFormatToGS(filteredImage.InternalBitmap);
                    AForge.Imaging.Filters.Threshold thresholder = new AForge.Imaging.Filters.Threshold();
                    thresholder.ThresholdValue = (int)(((double)ThresholdStrength / 10.0) * 255.0);
                    filteredImage = thresholder.Apply(filteredImage);

                }
                if (Bradley)
                {
                    AForge.Imaging.Filters.BradleyLocalThresholding bradlifier = new AForge.Imaging.Filters.BradleyLocalThresholding();

                    filteredImage = bradlifier.Apply(filteredImage);

                }
            }

            return filteredImage;
        }
Ejemplo n.º 4
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";
        }
Ejemplo n.º 5
0
        /// <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();
        }