private void button4_Click(object sender, EventArgs e) { Bitmap b = new Bitmap(pictureBox2.Image); b = new Sharpen().Apply(b); this.pictureBox2.Image = b; }
protected void surfRansacBlendStraight(List <Bitmap> imgs) { MatrixH homography; List <SpeededUpRobustFeaturePoint[]> surfPoints = new List <SpeededUpRobustFeaturePoint[]>(); //Calculate all the Surf Points SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector(); double lastAngle = 0; for (int i = 0; i < imgs.Count; i++) { //Grayscale to find the edges and adjust the normal to point up AForge.Imaging.Filters.GrayscaleBT709 grayscale = new AForge.Imaging.Filters.GrayscaleBT709(); AForge.Imaging.DocumentSkewChecker skew = new AForge.Imaging.DocumentSkewChecker(); double angle = skew.GetSkewAngle(grayscale.Apply(imgs[i])); //Less than 5 deg change in angle to account for wobble, ignore big shifts if (Math.Abs(angle - lastAngle) < 5) { AForge.Imaging.Filters.RotateBilinear rotate = new AForge.Imaging.Filters.RotateBilinear(angle); rotate.FillColor = Color.FromArgb(0, 255, 255, 255); imgs[i] = rotate.Apply(imgs[i]); lastAngle = angle; } showImage(imgs[i]); surfPoints.Add(surf.ProcessImage(imgs[i]).ToArray()); } Bitmap final = imgs[0]; for (int i = 1; i < imgs.Count; i++) { SpeededUpRobustFeaturePoint[] surfFinal = surf.ProcessImage(final).ToArray(); //Correlate the Harris pts between imgs KNearestNeighborMatching matcher = new KNearestNeighborMatching(5); matcher.Threshold = 0.05; IntPoint[][] matches = matcher.Match(surfFinal, surfPoints[i]); //Create the homography matrix using RANSAC RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.015, 1); homography = ransac.Estimate(matches[0], matches[1]); Blend blend = new Blend(homography, final); blend.Gradient = true; final = blend.Apply(imgs[i]); } //Smooth/Sharpen if I wanted to AForge.Imaging.Filters.Sharpen filter = new AForge.Imaging.Filters.Sharpen(); //AForge.Imaging.Filters.Gaussian filter = new AForge.Imaging.Filters.Guassian(5); //filter.ApplyInPlace(final); showImage(final); }
private void button3_Click(object sender, EventArgs e) { System.Drawing.Bitmap image = new Bitmap(picSource.BackgroundImage); // create filter AForge.Imaging.Filters.Sharpen filter = new AForge.Imaging.Filters.Sharpen(); // apply filter System.Drawing.Bitmap newImage = filter.Apply(image); picOutput.BackgroundImage = newImage; }
public static Bitmap DoIt(Bitmap bmp) { GaussianBlur blur = new GaussianBlur(10, 50); Bitmap blurred = blur.Apply(bmp); Bitmap ret = new Bitmap(blurred.Width, blurred.Height, blurred.PixelFormat); for (int y = 0; y < blurred.Height; y++) { for (int x = 0; x < blurred.Width; x++) { Color blurredColor = blurred.GetPixel(x, y); Color orinalColor = bmp.GetPixel(x, y); Color newColor = Color.FromArgb((blurredColor.R + orinalColor.R * 2) / 3, (blurredColor.G + orinalColor.G * 2) / 3, (blurredColor.B + orinalColor.B * 2) / 3); ret.SetPixel(x, y, newColor); } } GammaCorrection gc = new GammaCorrection(.8); gc.ApplyInPlace(ret); Sharpen sharpen = new Sharpen(); sharpen.ApplyInPlace(ret); Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721); Bitmap gray = filter.Apply(ret); CannyEdgeDetector canny = new CannyEdgeDetector(); gray = canny.Apply(gray); for (int y = 0; y < gray.Height; y++) { for (int x=0;x < gray.Width; x++) { if(gray.GetPixel(x,y).R > 0) { Color retColor = ret.GetPixel(x, y); Color newColor = Color.FromArgb( (int)(retColor.R * .7), (int)(retColor.G * .7), (int)(retColor.B * .7)); ret.SetPixel(x, y, newColor); } } } return ret; }
public Processor() { initGlyphs(); // resizeFilter = new ResizeNearestNeighbor(1920, 1080); // resizeFilter = new ResizeBicubic(1920, 1080); resizeFilter = new ResizeBilinear(1920, 1080); gaussianFilter = new GaussianSharpen(4, 11); sharpenFilter = new Sharpen(); brightnessFilter = new ContrastCorrection(15); autoEvent = new AutoResetEvent(false); Thread thread = new Thread(process); thread.Start(); }
protected void surfRansacBlend(List <Bitmap> imgs) { MatrixH homography; List <SpeededUpRobustFeaturePoint[]> surfPoints = new List <SpeededUpRobustFeaturePoint[]>(); //Calculate all the Surf Points SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector(); for (int i = 0; i < imgs.Count; i++) { surfPoints.Add(surf.ProcessImage(imgs[i]).ToArray()); } Bitmap final = imgs[0]; for (int i = 1; i < imgs.Count; i++) { SpeededUpRobustFeaturePoint[] surfFinal = surf.ProcessImage(final).ToArray(); //Correlate the Harris pts between imgs KNearestNeighborMatching matcher = new KNearestNeighborMatching(5); matcher.Threshold = 0.05; IntPoint[][] matches = matcher.Match(surfFinal, surfPoints[i]); RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.015, 1); homography = ransac.Estimate(matches[0], matches[1]); Blend blend = new Blend(homography, final); blend.Gradient = true; final = blend.Apply(imgs[i]); } //Smooth/Sharpen if I wanted to AForge.Imaging.Filters.Sharpen filter = new AForge.Imaging.Filters.Sharpen(); //AForge.Imaging.Filters.Gaussian filter = new AForge.Imaging.Filters.Guassian(5); //filter.ApplyInPlace(final); showImage(final); }
protected void freakRansacBlend(List <Bitmap> imgs) { MatrixH homography; List <FastRetinaKeypoint[]> freakPoints = new List <FastRetinaKeypoint[]>(); //Calculate all the FREAK Points FastRetinaKeypointDetector freak = new FastRetinaKeypointDetector(); foreach (Bitmap img in imgs) { freakPoints.Add(freak.ProcessImage(img).ToArray()); } //Map them and draw them! Bitmap final = imgs[0]; for (int i = 1; i < imgs.Count; i++) { FastRetinaKeypoint[] freakFinal = freak.ProcessImage(final).ToArray(); KNearestNeighborMatching matcher = new KNearestNeighborMatching(500); matcher.Threshold = 0.005; IntPoint[][] matches = matcher.Match(freakFinal, freakPoints[i]); RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.015, 1); homography = ransac.Estimate(matches[0], matches[1]); Blend blend = new Blend(homography, final); blend.Gradient = true; final = blend.Apply(imgs[i]); } //Smooth/Sharpen if I wanted to AForge.Imaging.Filters.Sharpen filter = new AForge.Imaging.Filters.Sharpen(); //AForge.Imaging.Filters.Gaussian filter = new AForge.Imaging.Filters.Guassian(5); //filter.ApplyInPlace(final); showImage(final); }
public static Bitmap Sharpen(Bitmap bmp) { Sharpen filter = new Sharpen(); filter.ApplyInPlace(bmp); return bmp; }
private Bitmap imgCut(Bitmap cutthis) { Bitmap b = new Bitmap(15, 20, PixelFormat.Format24bppRgb); Graphics g = Graphics.FromImage(b); g.Clear(Color.White); g.DrawImage(cutthis, 0, 0); b = new Grayscale(0.299, 0.587, 0.114).Apply(b); b = new Sharpen().Apply(b); b = new Sharpen().Apply(b); b = new Threshold(50).Apply(b); return b; }