private void Contrast_scretchFunc(ref Bitmap frame) { ContrastStretch filter = new ContrastStretch(); // process image filter.ApplyInPlace(frame); }
private void ContrastStretchDialog_Click(object sender, System.EventArgs e) { if (OriginalImage == null) { MessageBox.Show("No Image in memory"); return; } ContrastStretch cs; _currentProcess = Process.ContrastStretch; using (cs = new ContrastStretch(OriginalImage)) { if (cs.ShowDialog() != DialogResult.OK || cs.Proc == null) { return; } ProcImage = cs.Proc; pBox_ProcImg.Image = ProcImage; if (ProcImage != null) { DrawHistogram(ProcImage, pBoxHistProc); } cs.Close(); } }
/// <summary> /// Apply filter /// </summary> /// <returns>Bitmap - filtered image</returns> public Bitmap Apply() { try { bitmap = Grayscale.CommonAlgorithms.BT709.Apply(bitmap); var normalizer = new ContrastStretch(); normalizer.ApplyInPlace(bitmap); var er = new Erosion(); er.ApplyInPlace(bitmap); var ed = new SobelEdgeDetector(); ed.ApplyInPlace(bitmap); var th = new Threshold(); th.ApplyInPlace(bitmap); return(bitmap); } catch { return(bitmap); } }
public IImage Apply(IImage image) { var filter = new ContrastStretch(); var bmp = filter.Apply(image.ToBgr().Lock().AsAForgeImage()); return(bmp.AsImage()); }
/// <summary> /// Stretches intensity values in a linear way across full pixel range. /// </summary> /// <param name="im">Image.</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[,] StretchContrast <TColor>(this TColor[,] im, bool inPlace = false) where TColor : struct, IColor3 <byte> { ContrastStretch conrastStrech = new ContrastStretch(); return(im.ApplyFilter(conrastStrech, inPlace)); }
private static Image <TColor, TDepth> StretchContrast <TColor, TDepth>(this Image <TColor, TDepth> im, bool inPlace = false) where TColor : IColor where TDepth : struct { ContrastStretch conrastStrech = new ContrastStretch(); return(im.ApplyFilter(conrastStrech, inPlace)); }
public mNormalizeExtents() { BitmapType = mFilter.BitmapTypes.None; Effect = new ContrastStretch(); Sequence.Clear(); Sequence.Add(Effect); }
public Bitmap HistogramStretch(Bitmap image) { ContrastStretch filter = new ContrastStretch(); // process image Bitmap bmp = image; filter.ApplyInPlace(image); return(bmp); }
public BitmapProcessor(Crop crop, Grayscale grayscale, ContrastStretch contrastStretch, ResizeBilinear resizeBilinear, BitmapProcessingParams bitmapProcessingParams) { _crop = crop; _grayscale = grayscale; _contrastStretch = contrastStretch; _resizeBilinear = resizeBilinear; _bitmapProcessingParams = bitmapProcessingParams; _resizeBilinear.NewWidth = _bitmapProcessingParams.ResizeWidth; _resizeBilinear.NewHeight = _bitmapProcessingParams.ResizeHeight; }
public static Bitmap ProcessImage(string imagePath) { var img = AForge.Imaging.Image.FromFile(imagePath); ContrastStretch filterContrastStretch = new ContrastStretch(); filterContrastStretch.ApplyInPlace(img); try { img = Grayscale.CommonAlgorithms.BT709.Apply(img); } catch { System.Windows.Forms.MessageBox.Show("The image should not be grayscale"); } Opening filterOpening = new Opening(); filterOpening.ApplyInPlace(img); SobelEdgeDetector sobel = new SobelEdgeDetector(); sobel.ApplyInPlace(img); Closing filterClosing = new Closing(); filterClosing.ApplyInPlace(img); Threshold threshold = new Threshold(100); threshold.ApplyInPlace(img); FillHoles fillHoles = new FillHoles(); fillHoles.MaxHoleWidth = img.Width; fillHoles.MaxHoleHeight = img.Height; fillHoles.CoupledSizeFiltering = false; fillHoles.ApplyInPlace(img); filterOpening.ApplyInPlace(img); Erosion filterErosion = new Erosion(); filterErosion.ApplyInPlace(img); return(img); }
private void contrastStretch_Click(object sender, RoutedEventArgs e) { if (contrastStretch.IsChecked == true) { ContrastStretch filter = new ContrastStretch(); filter.ApplyInPlace(mainPhoto); Photography.Source = ToBitmapImage(mainPhoto); } else { UpdatePicture(ImageURL); Photography.Source = ToBitmapImage(mainPhoto); } mainPhotoIS = Photography.Source; UpdateHistograms(null); UpdateChannelPreviews(null); }
/// <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 sourceImage = null; DA.GetData(0, ref sourceImage); int C = 0; DA.GetData(1, ref C); int B = 0; DA.GetData(2, ref B); double S = 0; DA.GetData(3, ref S); sourceImage = ImageUtil.convert(sourceImage, System.Drawing.Imaging.PixelFormat.Format32bppArgb); Bitmap filteredImage = sourceImage; if (C >= 0) { IFilter myFilterContrast = new ContrastCorrection(C); filteredImage = myFilterContrast.Apply(sourceImage); } else { IFilter myFilterContrast = new ContrastStretch(); filteredImage = myFilterContrast.Apply(sourceImage); } IFilter myFilterBrightness = new BrightnessCorrection(B); filteredImage = myFilterBrightness.Apply(filteredImage); IFilter mySaturationFilter = new SaturationCorrection(Convert.ToSingle(S)); filteredImage = mySaturationFilter.Apply(filteredImage); DA.SetData(0, filteredImage); }
/// <summary> /// 对比度拉伸 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonConSt_Click(object sender, RoutedEventArgs e) { if (!CheckImage()) { return; } var cho = _image[_fChoose.ChoosedFile]; var a = new RS_Diag.ContrastStr(cho); if (a.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } double lV = a.LeftValue, rV = a.RightValue; var ind = a.BandList; RS_Lib.ContrastStretch[] st = new ContrastStretch[ind.Length]; for (int i = 0; i < ind.Length; i++) { st[i] = new ContrastStretch(cho, ind[i] + 1, lV, rV); } byte[,,] res = new byte[ind.Length, cho.Lines, cho.Samples]; for (int i = 0; i < ind.Length; i++) { for (int j = 0; j < cho.Lines; j++) { for (int k = 0; k < cho.Samples; k++) { res[i, j, k] = st[i].StretchedImg[j, k]; } } } AddNewPic(res, cho.FileName + "-对比度拉伸结果", false); }
private void QRWorkerMethod(object sender, CertificateScanner.WaiteWindow.WaitWindowEventArgs e) { try { var sourceimg = (Bitmap)e.Arguments[0]; ContrastStretch filter = new ContrastStretch(); sourceimg = filter.Apply(sourceimg); sourceimg = filter.Apply(sourceimg); sourceimg = filter.Apply(sourceimg); Median f1 = new Median(); sourceimg = f1.Apply(sourceimg); sourceimg = f1.Apply(sourceimg); sourceimg = f1.Apply(sourceimg); Blur filter2 = new Blur(); sourceimg = filter2.Apply(sourceimg); sourceimg = filter2.Apply(sourceimg); //sourceimg.Save("d:\\tst.jpg", ImageFormat.Jpeg); //System.Diagnostics.Process.Start("d:\\tst.jpg"); com.google.zxing.LuminanceSource source = new RGBLuminanceSource(sourceimg, sourceimg.Width, sourceimg.Height); com.google.zxing.Binarizer binarizer = new com.google.zxing.common.HybridBinarizer(source); com.google.zxing.qrcode.QRCodeReader reader = new com.google.zxing.qrcode.QRCodeReader(); var result = reader.decode(new com.google.zxing.BinaryBitmap(binarizer)); e.Result = result.Text; } catch (Exception ex) { e.Result = "12323123213123"; this.Warn(ex, this.Messages("qrFail")); } }
private void ContrastNormalize(ref Bitmap frame) { ContrastStretch filter = new ContrastStretch(); filter.ApplyInPlace(frame); }
public override Bitmap ApplyFilter(List <Bitmap> bitmap) { ContrastStretch filter = new ContrastStretch(); return(filter.Apply(bitmap[0])); }
public mAdjustContrastStretch() { BitmapType = BitmapTypes.None; filter = new ContrastStretch(); }
/// <summary> /// Stretches intensity values in a linear way across full pixel range. /// </summary> /// <param name="im">Image.</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 Gray <byte>[,] StretchContrast(this Gray <byte>[,] im, bool inPlace = false) { ContrastStretch conrastStrech = new ContrastStretch(); return(im.ApplyFilter(conrastStrech, inPlace)); }
/// <summary> /// Restore Colours on a faded image /// </summary> /// <remarks> /// This a simple image enhancement technique tht attempts to restore the original /// colours of a faded image by improving the contrasts of an image /// </remarks> /// <param name="source">the bitmap that has faded colours</param> public static void FixColours(this Bitmap source) { var filter = new ContrastStretch(); filter.ApplyInPlace(source); }