private string reconhecerCaptcha(Image img) { Bitmap imagem = new Bitmap(img); imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Erosion erosion = new Erosion(); Dilatation dilatation = new Dilatation(); Invert inverter = new Invert(); ColorFiltering cor = new ColorFiltering(); cor.Blue = new AForge.IntRange(200, 255); cor.Red = new AForge.IntRange(200, 255); cor.Green = new AForge.IntRange(200, 255); Opening open = new Opening(); BlobsFiltering bc = new BlobsFiltering(); Closing close = new Closing(); GaussianSharpen gs = new GaussianSharpen(); ContrastCorrection cc = new ContrastCorrection(); bc.MinHeight = 10; FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter); imagem = seq.Apply(imagem); //imagem.Save(Directory.GetCurrentDirectory() + "\\Captcha2.png", System.Drawing.Imaging.ImageFormat.Png); string reconhecido = OCR(imagem); //string reconhecido = ocr.Principal(Directory.GetCurrentDirectory() + "\\Captcha2.png"); return(reconhecido); }
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 { } }
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))); }
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 ToContrastCorrection(Bitmap Im) { AForge.Imaging.Filters.ContrastCorrection Img = new ContrastCorrection(); Bitmap bmImage = AForge.Imaging.Image.Clone(new Bitmap(Im), PixelFormat.Format24bppRgb); return(Img.Apply(bmImage)); }
private void button13_Click(object sender, EventArgs e) { ContrastCorrection filter = new ContrastCorrection(15); filter.ApplyInPlace(holdImagePreview); pictureBox1.Image = holdImagePreview; }
public static Task <(Bitmap, string)> DeCaptchAsync(Image img) { return((Task <(Bitmap, string)>)Task.Run(() => { string value; Bitmap bmp = new Bitmap(img); bmp = bmp.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Erosion erosion = new Erosion(); Dilatation dilatation = new Dilatation(); Invert inverter = new Invert(); ColorFiltering cor = new ColorFiltering(); //cor.Blue = new AForge.IntRange(200, 255); cor.Red = new AForge.IntRange(50, 255); //cor.Green = new AForge.IntRange(200, 255); Opening open = new Opening(); BlobsFiltering bc = new BlobsFiltering() { MinHeight = 10 }; Closing close = new Closing(); GaussianSharpen gs = new GaussianSharpen(); ContrastCorrection cc = new ContrastCorrection(); FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter, dilatation); Image image = seq.Apply(bmp); value = OCR((Bitmap)image); return ((Bitmap)image, value); })); }
/// <summary> /// Adjusts pixels' contrast value by increasing RGB values of bright pixel and decreasing /// pixel values of dark pixels (or vise versa if contrast needs to be decreased). /// </summary> /// <param name="im">Image.</param> /// <param name="factor">Factor which is used to adjust contrast. Factor values greater than /// 0 increase contrast making light areas lighter and dark areas darker. Factor values /// less than 0 decrease contrast - decreasing variety of contrast.</param> /// <param name="inPlace">Process in place or make not. If in place is set to true, returned value may be discarded.</param> /// <returns>Corrected image.</returns> public static TColor[,] CorrectContrast <TColor>(this TColor[,] im, int factor = 10, bool inPlace = false) where TColor : struct, IColor3 <byte> { ContrastCorrection conrastCorrection = new ContrastCorrection(factor); return(im.ApplyFilter(conrastCorrection, inPlace)); }
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)))); }
public static Bitmap ApplyFilters(Image img) { Bitmap imagem = new Bitmap(img); imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Erosion erosion = new Erosion(); Dilatation dilatation = new Dilatation(); Invert inverter = new Invert(); ColorFiltering cor = new ColorFiltering(); cor.Blue = new AForge.IntRange(200, 255); cor.Red = new AForge.IntRange(200, 255); cor.Green = new AForge.IntRange(200, 255); Opening open = new Opening(); BlobsFiltering bc = new BlobsFiltering(); Closing close = new Closing(); GaussianSharpen gs = new GaussianSharpen(); ContrastCorrection cc = new ContrastCorrection(); bc.MinHeight = 10; FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter); var filteredImage = seq.Apply(imagem); return(filteredImage); }
private string reconhecerCaptcha(Image img) { Bitmap _bitmap = new Bitmap(img); _bitmap = _bitmap.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Erosion erosion = new Erosion(); Dilatation dilatation = new Dilatation(); Invert inverter = new Invert(); ColorFiltering cor = new ColorFiltering(); cor.Blue = new AForge.IntRange(200, 255); cor.Red = new AForge.IntRange(200, 255); cor.Green = new AForge.IntRange(200, 255); Opening open = new Opening(); BlobsFiltering bc = new BlobsFiltering(); Closing close = new Closing(); GaussianSharpen gs = new GaussianSharpen(); ContrastCorrection cc = new ContrastCorrection(); bc.MinHeight = 10; FiltersSequence seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter); pictureBox1.Image = seq.Apply(_bitmap); string recognedString = OCR((Bitmap)pictureBox1.Image); return(recognedString); }
private Bitmap LimparImagem(Image img) { var imagem = new Bitmap(img); imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); var inverter = new Invert(); var cor = new ColorFiltering { Blue = new AForge.IntRange(200, 255), Red = new AForge.IntRange(200, 255), Green = new AForge.IntRange(200, 255) }; var open = new Opening(); var bc = new BlobsFiltering(); var gs = new GaussianSharpen(); var cc = new ContrastCorrection(); bc.MinHeight = 10; var seq = new FiltersSequence(gs, inverter, open, inverter, bc, inverter, open, cc, cor, bc, inverter); imagem = seq.Apply(imagem); return(imagem); }
private string reconhecerCaptcha(Image img) { Bitmap imagem = new Bitmap(img); imagem = imagem.Clone(new Rectangle(0, 0, img.Width, img.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Erosion erosion = new Erosion(); Dilatation dilatation = new Dilatation(); Invert inverter = new Invert(); ColorFiltering cor = new ColorFiltering(); cor.Blue = new AForge.IntRange(200, 255); cor.Red = new AForge.IntRange(200, 255); cor.Green = new AForge.IntRange(200, 255); Opening open = new Opening(); BlobsFiltering bc = new BlobsFiltering(); Closing close = new Closing(); GaussianSharpen gs = new GaussianSharpen(); ContrastCorrection cc = new ContrastCorrection(); bc.MinHeight = 10; GrayscaleRMY gray = new GrayscaleRMY(); Threshold thr = new Threshold(200); Difference diff = new Difference(dilatation.Apply(imagem)); FiltersSequence seq = new FiltersSequence(diff, inverter, erosion, gray, thr, cc); pictureBox.Image = seq.Apply(imagem); string reconhecido = OCR((Bitmap)pictureBox.Image); return(reconhecido); }
private void damarBulToolStripMenuItem_Click(object sender, EventArgs e) { ApplyFilter(new ExtractChannel(RGB.G)); if (orginalBitmap.PixelFormat != PixelFormat.Format24bppRgb) { MessageBox.Show("Contrast filter using HSL color space is available for color images only", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ContrastCorrection filter = new ContrastCorrection(); filter.Factor = 15; ApplyFilter(filter); GaussianBlur filter2 = new GaussianBlur(); // GaussianSharpen filter = new GaussianSharpen(); filter2.Size = 5; filter2.Sigma = 0.6; ApplyFilter(filter2); resultBitmap = Filtreler.Canny(resultBitmap); maskBitmap = (Bitmap)imageCollection1Mask.Images[index];// combobox ta seçilmiş image in mask image ini getiriyor resultBitmap = Filtreler.Maskeleme(resultBitmap, maskBitmap); Dilatation filter3 = new Dilatation(); ApplyFilter(filter3); pictureBox1.Image = resultBitmap; }
private void InitializeFilters() { grayscaleFilter = new Grayscale(0.299, 0.587, 0.114); bradleyLocalFilter = new BradleyLocalThresholding(); bradleyLocalFilter.WindowSize = 9; bradleyLocalFilter.PixelBrightnessDifferenceLimit = 0.01f; plateBlobsFiltering = new BlobsFiltering(10, 20, 80, 66); blobCounter = new BlobCounter(); blobCounter.FilterBlobs = true; blobCounter.MinWidth = 50; blobCounter.MinHeight = 10; blobCounter.MaxWidth = 520; blobCounter.MaxHeight = 110; plateBlobCounter = new BlobCounter(); shapeChecker = new SimpleShapeChecker(); otsuThresholdFilter = new OtsuThreshold(); fillHoles = new FillHoles(); fillHoles.MaxHoleWidth = 100; fillHoles.MaxHoleHeight = 40; pen = new Pen(Color.GreenYellow, 4); openingFilter = new Opening(); contrastCorrectionFilter = new ContrastCorrection(80); colorFiltering = new ColorFiltering(); colorFiltering.Red = new IntRange(150, 255); colorFiltering.Green = new IntRange(150, 255); colorFiltering.Blue = new IntRange(150, 255); colorFiltering.FillOutsideRange = true; invert = new Invert(); }
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) { } }
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!"); } }
/// <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); }
public mAdjustContrast(int factor) { Factor = factor; BitmapType = BitmapTypes.None; filter = new ContrastCorrection(Factor); }
public static Bitmap ContrastCorrection(Bitmap Imagem) { ContrastCorrection filter = new ContrastCorrection(); Imagem = Imagem.Clone(new Rectangle(0, 0, Imagem.Width, Imagem.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Imagem = filter.Apply(Imagem); return(Imagem); }
public static BitmapImage Contrast(this BitmapImage bitmapimage, int factor) { Bitmap bitmap = bitmapimage.BitmapImage2Bitmap(); ContrastCorrection contrastCorrection = new ContrastCorrection(factor); contrastCorrection.ApplyInPlace(bitmap); return(bitmap.ToBitmapImage()); }
private void sbContrast_ValueChanged(object sender, EventArgs e) { Bitmap img = new Bitmap(image); ContrastCorrection filter = new ContrastCorrection(sbContrast.Value); filter.ApplyInPlace(img); pictureBox2.Image = img; }
/// <summary> /// Adjusts pixels' contrast value by increasing RGB values of bright pixel and decreasing /// pixel values of dark pixels (or vise versa if contrast needs to be decreased). /// </summary> /// <param name="im">Image.</param> /// <param name="factor">Factor which is used to adjust contrast. Factor values greater than /// 0 increase contrast making light areas lighter and dark areas darker. Factor values /// less than 0 decrease contrast - decreasing variety of contrast.</param> /// <param name="inPlace">Process in place or make not. If in place is set to true, returned value may be discarded.</param> /// <returns>Corrected image.</returns> private static Image <TColor, TDepth> CorrectContrast <TColor, TDepth>(this Image <TColor, TDepth> im, int factor = 10, bool inPlace = false) where TColor : IColor where TDepth : struct { ContrastCorrection conrastCorrection = new ContrastCorrection(factor); return(im.ApplyFilter(conrastCorrection, inPlace)); }
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(); } }
/// <summary> /// Adjust the contrast of the image /// </summary> /// <param name="source">the bitmap source</param> /// <param name="contrastValue">contrast value in the range of -127 to 127 </param> public static void Contrast(this Bitmap source, Int32 contrastValue) { if (contrastValue < -127 || contrastValue > 127) { throw new ArgumentOutOfRangeException("contrastValue", "should be between -127 and 127"); } var filter = new ContrastCorrection(contrastValue); filter.ApplyInPlace(source); }
private Bitmap ProcessSingleImage(Bitmap _src) { double fValue = 1.6; ContrastCorrection filter = new ContrastCorrection(fValue); filter.ApplyInPlace(_src); return(_src); }
private void contrastCorrection() { // Declare variables Bitmap bitmap = new Bitmap(pictureBox1.Image); // create filter ContrastCorrection filter = new ContrastCorrection(15); // apply the filter filter.ApplyInPlace(bitmap); pictureBox1.Image = bitmap; }
private void Contrast() { if (orginalBitmap.PixelFormat != PixelFormat.Format24bppRgb) { MessageBox.Show("Contrast filter using HSL color space is available for color images only", "Message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ContrastCorrection filter = new ContrastCorrection(); filter.Factor = 15; ApplyFilter(filter); }
public void processImage() { //Snaps an image from videoSourcePlayer1 and adjusts gama and contrast based on slider bars(gamaSlider and contrastSlider) Bitmap capturedImage = videoSourcePlayer1.GetCurrentVideoFrame(); workingImage = capturedImage; GammaCorrection gamaFilter = new GammaCorrection((gamaSlider.Value) / 100.0); ContrastCorrection contrastFilter = new ContrastCorrection((contrastSlider.Value)); workingImage = gamaFilter.Apply(workingImage); workingImage = contrastFilter.Apply(workingImage); }
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; }
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); }
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); }