예제 #1
0
        void DisplayLiveView()
        {
            if (LiveViewData == null || LiveViewData.ImageData == null)
            {
                return;
            }
            MemoryStream stream = new MemoryStream(LiveViewData.ImageData,
                                                   LiveViewData.ImageDataPosition,
                                                   LiveViewData.ImageData.Length -
                                                   LiveViewData.ImageDataPosition);

            using (var bmp = new Bitmap(stream))
            {
                Bitmap res = bmp;
                if (Brightness != 0)
                {
                    BrightnessCorrection filter = new BrightnessCorrection(Brightness);
                    res = filter.Apply(res);
                }

                DisplayBitmap = BitmapFactory.ConvertToPbgra32Format(BitmapSourceConvert.ToBitmapSource(res));
                DrawGrid(DisplayBitmap);
                DisplayBitmap.Freeze();
                live_view_image.Source = DisplayBitmap;
            }
        }
예제 #2
0
        private void videoNewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap               bitmap           = (Bitmap)eventArgs.Frame.Clone();
            Threshold            thresholdFilter  = new Threshold(120);
            Grayscale            grayscaleFilter  = new Grayscale(0.2, 0.7, 0.07);
            BrightnessCorrection brightnessFilter = new BrightnessCorrection(brightnessVal);
            ContrastCorrection   contrastFilter   = new ContrastCorrection(contrastVal);
            SaturationCorrection saturationFilter = new SaturationCorrection(saturationVal);

            bitmap = brightnessFilter.Apply((Bitmap)bitmap.Clone());
            bitmap = contrastFilter.Apply((Bitmap)bitmap.Clone());
            bitmap = saturationFilter.Apply((Bitmap)bitmap.Clone());

            if (isGray)
            {
                bitmap = grayscaleFilter.Apply((Bitmap)bitmap.Clone());
            }
            if (isBW)
            {
                bitmap = grayscaleFilter.Apply((Bitmap)bitmap.Clone());
                bitmap = thresholdFilter.Apply(bitmap);
            }

            currentFrame = (Bitmap)bitmap.Clone();
            if (fileWriter != null)
            {
                fileWriter.WriteVideoFrame((Bitmap)bitmap.Clone());
            }
        }
        public Bitmap ChangeAttributes(Bitmap bitmap, int brightness, int contrast)
        {
            BrightnessCorrection bfilter = new BrightnessCorrection(brightness);
            ContrastCorrection   cfilter = new ContrastCorrection(contrast);

            return(bfilter.Apply(cfilter.Apply(bitmap.Clone(new Rectangle(0, 0, bitmap.Width, bitmap.Height), PixelFormat.Format24bppRgb))));
        }
예제 #4
0
        public Bitmap ToBrightnessCorrection(Bitmap Im)
        {
            AForge.Imaging.Filters.BrightnessCorrection Img = new BrightnessCorrection();
            Bitmap bmImage = AForge.Imaging.Image.Clone(new Bitmap(Im), PixelFormat.Format24bppRgb);

            return(Img.Apply(bmImage));
        }
예제 #5
0
        public static Bitmap AdjustContrastBrightness(Bitmap input, int brightnessAdjustment, int contrastAdjustment)
        {
            BrightnessCorrection bCorrector = new BrightnessCorrection(brightnessAdjustment);
            ContrastCorrection   cCorrector = new ContrastCorrection(contrastAdjustment);

            return(bCorrector.Apply(cCorrector.Apply(input)));
        }
예제 #6
0
        public Bitmap GetBrightness(System.Drawing.Image imgOrigin)
        {
            Bitmap bmp = (Bitmap)imgOrigin.Clone();
            int    px  = 0;

            for (int i = 0; i < bmp.Height; i++)
            {
                for (int j = 0; j < bmp.Width; j++)
                {
                    Color  c = bmp.GetPixel(j, i);
                    double b = 0.2126 * c.R + 0.7152 * c.G + 0.0722 * c.B;
                    //double b = c.GetBrightness();
                    _brightness += b;
                    px++;
                }
            }
            _brightness = _brightness / px;

            int difBright = 150 - (int)_brightness;
            BrightnessCorrection _filterB = new BrightnessCorrection(difBright);

            _filterB.ApplyInPlace(bmp);

            return(bmp);
        }
예제 #7
0
        public Form1()
        {
            InitializeComponent();
            fic    = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            bgc    = BufferedGraphicsManager.Current;
            cc     = new ContrastCorrection((int)nContrast.Value);
            bc     = new BrightnessCorrection((int)nBrightness.Value);
            grid   = new Pen(Brushes.LimeGreen, 2);
            marker = new Pen(Brushes.Red, 2);
            //p = new pimg(process_image);

            cbCamera.Items.Clear();

            try
            {
                foreach (FilterInfo f in fic)
                {
                    cbCamera.Items.Add(f.Name);
                }
                cbCamera.SelectedIndex = 0;
            }
            catch (Exception k)
            {
            }
        }
예제 #8
0
        private void CameraOne_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            if (isRecording1)
            {
                using (var bitmap = (Bitmap)eventArgs.Frame.Clone())
                {
                    if (firstFrameTime != null)
                    {
                        writer.WriteVideoFrame(bitmap, DateTime.Now - firstFrameTime.Value);
                    }
                    else
                    {
                        writer.WriteVideoFrame(bitmap);
                        firstFrameTime = DateTime.Now;
                    }
                }
            }

            Bitmap bitmap1 = (Bitmap)eventArgs.Frame.Clone();
            BrightnessCorrection br = new BrightnessCorrection(brightess1);
            ContrastCorrection cr = new ContrastCorrection(contrast1);
            SaturationCorrection sr = new SaturationCorrection(saturation1);
            bitmap1 = br.Apply((Bitmap)bitmap1.Clone());
            bitmap1 = cr.Apply((Bitmap)bitmap1.Clone());
            bitmap1 = sr.Apply((Bitmap)bitmap1.Clone());
            try
            { 
                pbCam1.Image = bitmap1;
            }
            catch (NullReferenceException ex)
            {
                Console.WriteLine("A problem with image loading occured! You may want to close other apps using your camera!");
            }
        }
예제 #9
0
 public void ReloadBc()
 {
     if (ImgDefaultPath1 == null || ImgDefaultPath1.Length <= 0 || VsFace1 == null)
     {
         return;
     }
     try
     {
         var image1 = new Bitmap(new MemoryStream((byte[])ImgDefaultPath1.Clone()));
         var image2 = new Bitmap(new MemoryStream((byte[])ImgChangedImage.Clone()));
         var brightnessCorrection = new BrightnessCorrection();
         brightnessCorrection.AdjustValue = Mainform.btBrightness.Value;
         var image3             = brightnessCorrection.Apply(image1);
         var image4             = brightnessCorrection.Apply(image2);
         var contrastCorrection = new ContrastCorrection();
         contrastCorrection.Factor = Mainform.btContrast.Value;
         var bitmap1      = contrastCorrection.Apply(image3);
         var bitmap2      = contrastCorrection.Apply(image4);
         var memoryStream = new MemoryStream();
         bitmap1.Save(memoryStream, ImageFormat.Bmp);
         ImgPath1 = (byte[])memoryStream.GetBuffer().Clone();
         bitmap2.Save(memoryStream, ImageFormat.Bmp);
         ImgChangedImage = (byte[])memoryStream.GetBuffer().Clone();
         memoryStream.Close();
         bitmap1.Dispose();
         bitmap2.Dispose();
         DrawSquare(VsFace1);
     }
     catch
     {
     }
 }
예제 #10
0
        /// <summary>
        /// Creates a comic rendered copy of the input image.
        /// </summary>
        public override Bitmap Render(Bitmap sourceImage)
        {
            // Converters
            GrayscaleY     convertGray  = new GrayscaleY();
            GrayscaleToRGB convertColor = new GrayscaleToRGB();

            // Convert grayscal images
            if (sourceImage.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                sourceImage = convertColor.Apply(sourceImage);
            }

            Bitmap comicImage = AForge.Imaging.Image.Clone(sourceImage);
            Bitmap edgeLayer  = null;
            Bitmap glowLayer  = null;

            // Glow for smooth colors
            GaussianBlur filterBlur = new GaussianBlur();

            filterBlur.Sigma = 2.0;
            filterBlur.Size  = 4;
            glowLayer        = filterBlur.Apply(comicImage);

            //SmartBlur filterBlur = new SmartBlur(10, 0.2);
            //glowLayer = filterBlur.Apply(comicImage);

            ContrastCorrection filterContrast = new ContrastCorrection(1 - (-this.Coloring * 0.1));

            filterContrast.ApplyInPlace(glowLayer);

            BrightnessCorrection filterBrightness = new BrightnessCorrection((-this.Coloring * 0.1) + 0.1);

            filterBrightness.ApplyInPlace(glowLayer);

            Screen blendScreen = new Screen(glowLayer);

            blendScreen.ApplyInPlace(comicImage);


            // Create a layer for edges
            Convolution filterConvolution = new Convolution(ConvolutionKernel);

            edgeLayer = filterConvolution.Apply(comicImage);

            // Convert to grayscale
            edgeLayer = convertGray.Apply(edgeLayer);

            // Threshold (edge thickness)
            Threshold filterThreshold = new Threshold((byte)(this.Edging * 255 / 100));

            filterThreshold.ApplyInPlace(edgeLayer);
            edgeLayer = convertColor.Apply(edgeLayer);

            // intersect comic with top layer (Darken blend)
            Intersect blendIntersect = new Intersect(edgeLayer);

            blendIntersect.ApplyInPlace(comicImage);

            return(comicImage);
        }
 /// <summary>
 /// Initializes saturation/contrast/exposure/gamma/brightess filter.
 /// </summary>
 public SaturationContrastBrightnessFilter()
 {
     this.ce = new ContrastEnhancement(0, Space.YCbCr);
     this.sc = new SaturationCorrection(0);
     this.bc = new BrightnessCorrection(0, Space.YCbCr);
     this.ec = new ShiftCorrection(0, Space.YCbCr);
     this.gc = new GammaCorrection(0, Space.YCbCr);
 }
예제 #12
0
        public mAdjustBrightness(int adjustValue)
        {
            AdjustValue = adjustValue;

            BitmapType = BitmapTypes.None;

            filter = new BrightnessCorrection(AdjustValue);
        }
예제 #13
0
        public Bitmap Brightness(Bitmap image, int brightness)
        {
            BrightnessCorrection brightnessFilter = new BrightnessCorrection(brightness);

            // apply the filter
            brightnessFilter.ApplyInPlace(image);
            return(image);
        }
예제 #14
0
        public static Bitmap BrightnessCorrection(Bitmap Imagem)
        {
            BrightnessCorrection filter = new BrightnessCorrection();

            Imagem = Imagem.Clone(new Rectangle(0, 0, Imagem.Width, Imagem.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            Imagem = filter.Apply(Imagem);
            return(Imagem);
        }
 private void streamedFrame(object sender, NewFrameEventArgs eventArgs)
 {
     try
     {
         if (_isRecording)
         {
             recordVideo(eventArgs);
         }
         using (var bitmap = (Bitmap)eventArgs.Frame.Clone())
         {
             if (_isMonochromatic)
             {
                 using (var isgrayscaledBitmap = Grayscale.CommonAlgorithms.BT709.Apply(bitmap))
                     using (var monochromaticcBitmap = new Threshold(100).Apply(isgrayscaledBitmap))
                     {
                         bitmapImage = monochromaticcBitmap.ToBitmapImage();
                     }
             }
             else if (_isGrayScaled)
             {
                 using (var isGrayscaledBitmap = Grayscale.CommonAlgorithms.BT709.Apply(bitmap))
                 {
                     bitmapImage = isGrayscaledBitmap.ToBitmapImage();
                 }
             }
             else if (contrast != 0)
             {
                 ContrastCorrection filter = new ContrastCorrection((int)contrast);
                 using (var contrastBitMap = filter.Apply(bitmap))
                     bitmapImage = contrastBitMap.ToBitmapImage();
             }
             else if (brightness != 0)
             {
                 BrightnessCorrection bfilter = new BrightnessCorrection((int)brightness);
                 using (var brightnessBitMap = bfilter.Apply(bitmap))
                     bitmapImage = brightnessBitMap.ToBitmapImage();
             }
             else if (saturation != 0)
             {
                 SaturationCorrection bfilter = new SaturationCorrection((int)brightness);
                 using (var saturationBitMap = bfilter.Apply(bitmap))
                     bitmapImage = saturationBitMap.ToBitmapImage();
             }
             else
             {
                 bitmapImage = bitmap.ToBitmapImage();
             }
         }
         bitmapImage.Freeze();
         Dispatcher.BeginInvoke(new ThreadStart(delegate { VideoSource.Source = bitmapImage; }));
         motionDetect(eventArgs);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error:\n", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
         StopCamera();
     }
 }
예제 #16
0
        /// <summary>
        /// Adjust the brightness of the image
        /// </summary>
        /// <param name="source">the source bitmap</param>
        /// <param name="brightnessValue">brightness adjustment value in the range of -255 to 255</param>
        public static void Brightness(this Bitmap source, Int32 brightnessValue)
        {
            if (brightnessValue < -255 || brightnessValue > 255)
            {
                throw new ArgumentOutOfRangeException("brightnessValue", "should be between -255 and 255");
            }
            var filter = new BrightnessCorrection(brightnessValue);

            filter.ApplyInPlace(source);
        }
예제 #17
0
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            BrLabel.Text = trackBar1.Value.ToString();
            int br = trackBar1.Value;

            if (pictureBox1.Image != null)
            {
                BrightnessCorrection brc = new BrightnessCorrection(br);
                pictureBox2.Image = brc.Apply((Bitmap)pictureBox1.Image.Clone());
            }
        }
예제 #18
0
        /// <summary>
        /// Creates a comic rendered copy of the input image.
        /// </summary>
        public override Bitmap Render(Bitmap sourceImage)
        {
            GrayscaleToRGB convertColor = new GrayscaleToRGB();

            if (sourceImage.PixelFormat == PixelFormat.Format8bppIndexed)
            {
                sourceImage = convertColor.Apply(sourceImage);
            }

            BilateralBlur blur  = new BilateralBlur(3, 0.1);
            Bitmap        comic = blur.Apply(sourceImage);

            // Edges
            Bitmap            grayscale = Grayscale.CommonAlgorithms.Y.Apply(comic);
            SobelEdgeDetector sobelEdge = new SobelEdgeDetector();

            sobelEdge.ScaleIntensity = true;
            Bitmap edgeLayer = sobelEdge.Apply(grayscale);

            edgeLayer = convertColor.Apply(edgeLayer);

            Invert invertEdge = new Invert();

            invertEdge.ApplyInPlace(edgeLayer);

            HSLLinear edgeLinear = new HSLLinear();

            edgeLinear.InLuminance.Min = 0;
            edgeLinear.InLuminance.Max = 0.8;
            edgeLinear.ApplyInPlace(edgeLayer);


            // highlights
            Bitmap     highlightLayer      = invertEdge.Apply(edgeLayer);
            Dilatation highlightDilitation = new Dilatation();

            highlightDilitation.ApplyInPlace(highlightLayer);

            BrightnessCorrection highlightBright = new BrightnessCorrection(-0.35);

            highlightBright.ApplyInPlace(highlightLayer);
            ColorDodge highlightBlend = new ColorDodge(highlightLayer);

            highlightBlend.ApplyInPlace(comic);


            // Merge edges with working layer
            Multiply multEdge = new Multiply(edgeLayer);

            multEdge.ApplyInPlace(comic);


            return(comic);
        }
예제 #19
0
        private void ImgHSLC(string type)
        {
            if (this.tb_Contrast.Value == 50 && this.tb_Hue.Value == 0 && this.tb_Light.Value == 0 && this.tb_Saturation.Value == 0)
            {
                this.drawArea.Image = this.sourceImage;
                return;
            }
            Bitmap bt = this.filteredImage;

            switch (type)
            {
            case "Hue":
                if (huemodifierFilter == null)
                {
                    huemodifierFilter = new HueModifier();
                }
                huemodifierFilter.Hue = this.tb_Hue.Value;
                bt   = ApplyFilter(huemodifierFilter, bt);
                xml += this.SaveImageToXml.SaveImgProcess(this.drawArea, this.lb_ImageName.Text, "HueModifier", huemodifierFilter);
                break;

            case "Saturation":
                if (saturationcorrFilter == null)
                {
                    saturationcorrFilter = new SaturationCorrection();
                }
                saturationcorrFilter.AdjustValue = Convert.ToDouble(this.tb_Saturation.Value) / Convert.ToDouble(255);
                bt   = ApplyFilter(saturationcorrFilter, bt);
                xml += this.SaveImageToXml.SaveImgProcess(this.drawArea, this.lb_ImageName.Text, "Saturation", saturationcorrFilter);
                break;

            case "Light":
                if (brightnesscorr == null)
                {
                    brightnesscorr = new BrightnessCorrection();
                }
                brightnesscorr.AdjustValue = Convert.ToDouble(tb_Light.Value) / Convert.ToDouble(255);
                bt   = ApplyFilter(brightnesscorr, bt);
                xml += this.SaveImageToXml.SaveImgProcess(this.drawArea, this.lb_ImageName.Text, "BrightnessCorrection", brightnesscorr);
                break;

            case "Contrast":
                if (contrastCorr == null)
                {
                    contrastCorr = new ContrastCorrection();
                }
                contrastCorr.Factor = Convert.ToDouble(tb_Contrast.Value) / Convert.ToDouble(40);
                bt   = ApplyFilter(contrastCorr, bt);
                xml += this.SaveImageToXml.SaveImgProcess(this.drawArea, this.lb_ImageName.Text, "ContrastCorrection", contrastCorr);
                break;
            }
            this.drawArea.Image = bt;
        }
예제 #20
0
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            label7.Text = trackBar1.Value.ToString();

            Bitmap image = new Bitmap(pictureBox1.Image);
            BrightnessCorrection filter = new BrightnessCorrection(trackBar1.Value - bright);
            filter.ApplyInPlace(image);
            pictureBox1.Image = image;

            image.Save(textBox2.Text, ImageFormat.Jpeg);
            bright = trackBar1.Value;
        }
예제 #21
0
        Pen greenPen  = new Pen(Color.Green, 7);  //is answer


        //
        public Form1()
        {
            InitializeComponent();

            /*---filters---*/
            brightnessFilter = new BrightnessCorrection(brightnessLevel);
            invertFilter     = new Invert();
            smoothFilter     = new AdaptiveSmoothing(smoothFactor);
            thresholdFilter  = new Threshold(thresholdLevel);
            blobFilter       = new BlobsFiltering();

            /*---tools---*/
            blobCounter  = new BlobCounter();
            shapeChecker = new SimpleShapeChecker();
        }
예제 #22
0
 // private ReadBackImageFromXML readBackImage;
 public Light()
 {
     InitializeComponent();
     this.l_track1_L.Text          = "-255";
     this.l_track1_R.Text          = "255";
     this.trackBar_1.Maximum       = 255;
     this.trackBar_1.Minimum       = -255;
     this.trackBar_1.SmallChange   = 1;
     this.trackBar_1.TickFrequency = 10;
     brightnesscorr      = new BrightnessCorrection();
     this.drawArea.Image = (Bitmap)frmImgProcess.imgProcess.drawArea.Image;
     drawArea.Filter     = brightnesscorr;
     saveImgToXml        = new SaveBackImageToXml();
     // readBackImage = new ReadBackImageFromXML(ImgProcess.imgProcess.lb_ImageName.Text);
 }
예제 #23
0
        private void buttonBrightness_Click(object sender, EventArgs e)
        {
            int valueOfBrightness = 0;

            if (int.TryParse(textBoxBrightness.Text, out valueOfBrightness))
            {
                //   valueOfBrightness = Int32.Parse(textBoxBrightness.Text);
                brightness        = new BrightnessCorrection(valueOfBrightness);
                pictureBox2.Image = (Bitmap)pictureBox.Image.Clone();
                brightness.ApplyInPlace((Bitmap)pictureBox2.Image);
            }
            else
            {
                textBoxBrightness.Text = "You must place here number";
            }
        }
예제 #24
0
        void Brightness20ToolStripMenuItemClick(object sender, EventArgs e)
        {
            //jika gambar kosong/null maka akan mengembalikan nilai kosong/null
            if (gambar == null)
            {
                return;
            }
            //membuat filter dari inisiasi class BrightnessCorrection() dengan argumen 20 pada objek brignessCorrection
            BrightnessCorrection brignessCorrection = new BrightnessCorrection(20);

            //clone variable gambar pada variable gambar2
            gambar2 = (Bitmap)gambar.Clone();
            //aplikasikan filter objek brignessCorrection pada gambar2
            brignessCorrection.ApplyInPlace(gambar2);
            //tampilkan hasil gambar2 yang sudah diaplikasikan filter pada pictureBox2
            pictureBox2.Image = gambar2;
        }
예제 #25
0
        private void trackBar1_Scroll(object sender, EventArgs e)
        {
            lbDeger.Text = trackBar1.Value.ToString();

            if (pictureBox1.Image != null)
            {
                BrightnessCorrection brgCrr = new BrightnessCorrection(trackBar1.Value);
                try
                {
                    pictureBox2.Image = brgCrr.Apply((Bitmap)pictureBox1.Image.Clone());
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
예제 #26
0
        private void Brightness_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            BrightnessLabel.Content = Brightness.Value;
            brightness = (int)Brightness.Value;

            if (mainPhoto != null)
            {
                bc = new BrightnessCorrection(brightness);
                System.Drawing.Bitmap tmp = bc.Apply((System.Drawing.Bitmap)mainPhoto.Clone());
                //BitmapImage tmpBmpIs = ToBitmapImage(tmp);

                Photography.Source = ToBitmapImage(tmp);

                UpdateHistograms(tmp);
                UpdateChannelPreviews(tmp);
            }
        }
예제 #27
0
        private void video_NewFrame(object sender, NewFrameEventArgs eventArgs)//get picture from camera
        {
            Bitmap bitmap = (Bitmap)eventArgs.Frame.Clone();

            if (flag == 0)
            {
                //bitmap.Save(img);
                flag   = 1;
                bitmap = new Bitmap(bitmap, new Size(320, 240));
                ContrastCorrection   filter  = new ContrastCorrection(tempform.contrast);
                BrightnessCorrection bfilter = new BrightnessCorrection(tempform.brightness);
                SaturationCorrection sfilter = new SaturationCorrection(tempform.saturation);
                bfilter.ApplyInPlace(bitmap);
                filter.ApplyInPlace(bitmap);
                sfilter.ApplyInPlace(bitmap);
                pictureBox1.Image = bitmap;
            }
        }
예제 #28
0
 private void Form1_Load(object sender, EventArgs e)
 {
     destfolder           = Application.StartupPath;
     textBox1.Text        = destfolder;
     pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
     //b = new Bitmap("d:\\test.jpg");
     bc  = new BrightnessCorrection();
     cc  = new ContrastCorrection();
     fic = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo f in fic)
     {
         comboBox1.Items.Add(f.Name);
     }
     if (comboBox1.Items.Count > 0)
     {
         comboBox1.SelectedIndex = 0;
     }
 }
        private void CameraTwo_NewFrame(object sender, NewFrameEventArgs eventArgs)
        {
            Bitmap bitmap2          = (Bitmap)eventArgs.Frame.Clone();
            BrightnessCorrection br = new BrightnessCorrection(brightess1);
            ContrastCorrection   cr = new ContrastCorrection(contrast1);
            SaturationCorrection sr = new SaturationCorrection(saturation1);

            bitmap2 = br.Apply((Bitmap)bitmap2.Clone());
            bitmap2 = cr.Apply((Bitmap)bitmap2.Clone());
            bitmap2 = sr.Apply((Bitmap)bitmap2.Clone());

            pbCam2.Image = bitmap2;

            if (isRecording2)
            {
                writer.WriteVideoFrame(bitmap2);
            }
        }
예제 #30
0
        public void doBrightness(int bright)
        {
            Bitmap img = new Bitmap(path);
            BrightnessCorrection filter = new BrightnessCorrection((double)bright / 1000);

            img = filter.Apply(img);
            // ImageEView
            if (mov != null)
            {
                this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Close(mov);
            }
            mov = this.WorkItem.SmartParts.AddNew <ImageEView>();
            mov.panAndZoomPictureBox1.Image = img;
            SmartPartInfo spi =
                new SmartPartInfo("Brightness Correction", "MyOwnDescription");

            this.WorkItem.Workspaces[WorkspaceNames.TabWorkspace].Show(mov, spi);
        }
예제 #31
0
    public void displayMessage()
    {
        string filename = @"Testing\card2.tif";
        string inputpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Path.DirectorySeparatorChar + filename;
        string outputpath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + Path.DirectorySeparatorChar + @"Testing\newfile1.tif";
        System.Drawing.Image image1 = System.Drawing.Image.FromFile(inputpath);
        Bitmap image = (Bitmap)image1;

        BrightnessCorrection bfilter = new BrightnessCorrection(40);
        bfilter.ApplyInPlace(image);

        ContrastCorrection cfilter = new ContrastCorrection(180);
        cfilter.ApplyInPlace(image);

        image.Save(outputpath);
    }
예제 #32
0
    public void PreProcess(string filepath, string outputpath, int brightness, int contrast)
    {
        System.Drawing.Image image1 = System.Drawing.Image.FromFile(filepath);
        Bitmap image = (Bitmap)image1;

        BrightnessCorrection bfilter = new BrightnessCorrection(brightness);
        bfilter.ApplyInPlace(image);

        ContrastCorrection cfilter = new ContrastCorrection(contrast);
        cfilter.ApplyInPlace(image);

        image.Save(outputpath);
    }