private void button2_Click(object sender, EventArgs e) { System.Drawing.Bitmap image = new Bitmap(picSource.BackgroundImage); // create filter AForge.Imaging.Filters.Blur filter = new AForge.Imaging.Filters.Blur(); // apply filter System.Drawing.Bitmap newImage = filter.Apply(image); picOutput.BackgroundImage = newImage; }
public static Bitmap Blur(Bitmap bmp) { // create filter Blur filter = new Blur(); // apply the filter filter.ApplyInPlace(bmp); return bmp; }
private void btnEffectApply_Click(object sender, EventArgs e) { resizerControl.Visible = true; IFilter imgeFilter = default(IFilter); Button effect = (Button)sender; Bitmap imgEffect = img; if (effect.Name == "btnGray") { imgeFilter = new GrayscaleBT709(); } else if (effect.Name == "btnSeperia") { imgeFilter = new Sepia(); } else if (effect.Name == "btnInvert") { imgeFilter = new Invert(); } else if (effect.Name == "btnCommon") { imgeFilter = new BurkesDithering(); } else if (effect.Name == "btnBlur") { imgeFilter = new Blur(); } else if (effect.Name == "btnJitter") { imgeFilter = new Texturer(new AForge.Imaging.Textures.MarbleTexture(10, 11), 0.7f, 0.3f); } else if (effect.Name == "btnCyan") { imgeFilter = new ChannelFiltering(new IntRange(0, 0), new IntRange(0, 255), new IntRange(0, 255)); } else if (effect.Name == "btnBlackWhite") { imgeFilter = new YCbCrExtractChannel(AForge.Imaging.YCbCr.CrIndex); } imgEffect = imgeFilter.Apply(img); panelImage.BackgroundImage = imgEffect; //img = imgEffect; }
private void Effect() { IFilter imgeFilter = new BurkesDithering(); Bitmap bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnCommon.Image = bitimg; imgeFilter = new GrayscaleBT709(); btnGray.Image = new Bitmap(imgeFilter.Apply(img), 90, 111); imgeFilter = new Sepia(); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnSeperia.Image = bitimg; imgeFilter = new Invert(); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnInvert.Image = bitimg; imgeFilter = new Blur(); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnBlur.Image = bitimg; imgeFilter = new Texturer(new AForge.Imaging.Textures.MarbleTexture(10, 11), 0.7f, 0.3f); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnJitter.Image = bitimg; imgeFilter = new ChannelFiltering(new IntRange(0, 0), new IntRange(0, 255), new IntRange(0, 255)); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnCyan.Image = bitimg; imgeFilter = new YCbCrExtractChannel(AForge.Imaging.YCbCr.CrIndex); bitimg = new Bitmap(imgeFilter.Apply(img), 90, 111); btnBlackWhite.Image = bitimg; }
/// <summary> /// /// </summary> /// <param name="img"></param> /// <returns></returns> public GameLogic ScrapeBoardFromImage(Bitmap img) { // filter board's color to better identify tiles Blur blur = new Blur(); blur.Threshold = 1; blur.ApplyInPlace(img); BrightnessCorrection brightness_filter = new BrightnessCorrection(-30); brightness_filter.ApplyInPlace(img); HSLFiltering luminance_filter = new HSLFiltering(); luminance_filter.Luminance = new Range(0.50f, 1); luminance_filter.ApplyInPlace(img); img.Save("c:\\users\\breiche\\pictures\\filtered.bmp", ImageFormat.Bmp); DetectBlobsInImage(img); img.Save("c:\\users\\breiche\\pictures\\blobs.bmp", ImageFormat.Bmp); return new GameLogic(0, 0); }
private void Button_Click(object sender, RoutedEventArgs e) { Bitmap image = viewCam.GetCurrentVideoFrame(); ImageStatistics statistics = new ImageStatistics(ObjectExtractorDialog.Value); // create filter EuclideanColorFiltering filter = new EuclideanColorFiltering(); // set center colol and radius filter.CenterColor = new RGB((byte)statistics.Red.Median, (byte)statistics.Green.Median, (byte)statistics.Blue.Median); filter.Radius = 20; // apply the filter filter.ApplyInPlace(image); image = Grayscale.CommonAlgorithms.BT709.Apply(image); Blur blur = new Blur(); blur.ApplyInPlace(image); OtsuThreshold otsu = new OtsuThreshold(); otsu.ApplyInPlace(image); //DifferenceEdgeDetector edgeDetector = new DifferenceEdgeDetector(); //edgeDetector.ApplyInPlace(image); //ColorFiltering colorFilter = new ColorFiltering( // new IntRange(2, 255), // new IntRange(0, 60), // new IntRange(0, 60)); //colorFilter.ApplyInPlace(image); //// create filter //Threshold threshold = new Threshold(100); //// apply the filter //threshold.ApplyInPlace(image); using (image) { BitmapSource bitmapSource = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap( image.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); //imgtest.Source = bitmapSource; } }
public void Detect(CameraImage cameraImage) { var partial = cameraConverter.ToImage(cameraImage); var sourceBitmap = converter.ToBitmap(partial); var blur = new Blur(); blur.ApplyInPlace(sourceBitmap); var points = harris.ProcessImage(sourceBitmap); var featurePoints = points.Select(t => new CornerFeaturePoint(t)).Cast<IFeaturePoint>().ToList(); if (featurePoints.Count > 0 && oldPoints.Count > 0) { try { var matches = matcher.Match(featurePoints, oldPoints); using (var g = Graphics.FromImage(sourceBitmap)) { for (var i = 0; i < matches[0].Length; i++) { g.DrawRectangle(Pens.Blue, matches[0][i].X, matches[0][i].Y, 3, 3); g.DrawRectangle(Pens.Red, matches[1][i].X, matches[1][i].Y, 3, 3); g.DrawLine(Pens.Red, matches[0][i].X + 1, matches[0][i].Y + 1, matches[1][i].X + 1, matches[1][i].Y + 1); } } var resultImage = imageFactory.Create(sourceBitmap); Image = cameraConverter.Convert(resultImage); oldPoints.Clear(); oldPoints.AddRange(featurePoints.AsReadOnly()); } finally { sourceBitmap.Dispose(); } } else { oldPoints.Clear(); oldPoints.AddRange(featurePoints.AsReadOnly()); } }