public IImage Apply(IImage image) { var filter = new ContrastStretch(); var bmp = filter.Apply(image.ToBgr().Lock().AsAForgeImage()); return(bmp.AsImage()); }
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")); } }
/// <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); }
public override Bitmap ApplyFilter(List <Bitmap> bitmap) { ContrastStretch filter = new ContrastStretch(); return(filter.Apply(bitmap[0])); }
private Bitmap ApplyContrastStrect(Bitmap bitmap) { return(_contrastStretch.Apply(bitmap)); }