public Bitmap ToClosing(Bitmap Im) { AForge.Imaging.Filters.Closing Img = new Closing(); Bitmap bmImage = AForge.Imaging.Image.Clone(new Bitmap(Im), PixelFormat.Format24bppRgb); return(Img.Apply(bmImage)); }
private void reapplyToolStripMenuItem8_Click(object sender, EventArgs e) { //create filter Closing filter = new Closing(); // apply the filter pictureBox2.Image = filter.Apply((Bitmap)pictureBox2.Image); }
private void fillHoles() { Closing close = new Closing(); imageGot = close.Apply(imageGot); imageGot = close.Apply(imageGot); Opening opening = new Opening(); imageGot = opening.Apply(imageGot); FillHoles fillHoles = new FillHoles(); fillHoles.MaxHoleHeight = 20; fillHoles.MaxHoleWidth = 20; fillHoles.CoupledSizeFiltering = false; imageGot = fillHoles.Apply(imageGot); pictureBox1.Image = imageGot; }
public static Bitmap Closing(Bitmap Imagem) { Closing filter = new Closing(); Imagem = Imagem.Clone(new Rectangle(0, 0, Imagem.Width, Imagem.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb); Imagem = filter.Apply(Imagem); return(Imagem); }
private void morphologyBoşlukDoldurmaToolStripMenuItem_Click(object sender, EventArgs e) { // create filter Closing filter = new Closing(); // apply the filter Bitmap morf = filter.Apply((Bitmap)pictureBox8.Image); pictureBox9.Image = morf; }
private void fillHoleToolStripMenuItem_Click(object sender, EventArgs e) { GrayscaleBT709 greyscale = new GrayscaleBT709(); Bitmap grey = greyscale.Apply(skin); Threshold filter = new Threshold(100); filter.ApplyInPlace(grey); Closing close = new Closing(); Bitmap j = close.Apply(grey); Opening open = new Opening(); k = open.Apply(j); pictureBox3.Image = k; }
public static List <Bitmap> CutImages(Bitmap bitmap, Action <Bitmap> act = null) { Bitmap sourceBitmap = bitmap; Bitmap targetBitmap = (Bitmap)sourceBitmap.Clone(); if (!AForge.Imaging.Image.IsGrayscale(targetBitmap)) { targetBitmap = AForge.Imaging.Image.Clone(targetBitmap, PixelFormat.Format24bppRgb); targetBitmap = Grayscale.CommonAlgorithms.BT709.Apply(targetBitmap); } if (act == null) { targetBitmap = new Threshold(50).Apply(targetBitmap); Invert filter = new Invert(); filter.ApplyInPlace(targetBitmap); BlobsFiltering bolbsfilter = new BlobsFiltering(); bolbsfilter.CoupledSizeFiltering = true; bolbsfilter.MinWidth = 4; bolbsfilter.MinHeight = 4; bolbsfilter.ApplyInPlace(targetBitmap); Closing binary = new Closing(); targetBitmap = binary.Apply(targetBitmap); filter.ApplyInPlace(targetBitmap); } else { act(targetBitmap); } var bit1 = Crop_Y(targetBitmap); var bit2 = Crop_X(bit1); return(ToResizeAndCenterIt(bit2)); }
private void fillHoleToolStripMenuItem_Click(object sender, EventArgs e) { // create grayscale filter (BT709) Grayscale filter = new Grayscale(0.2125, 0.7154, 0.0721); // apply the filter Bitmap grayImage = filter.Apply(skinImage); // create filter Threshold filter2 = new Threshold(90); filter2.ApplyInPlace(grayImage); //monoImage = filter2.Apply(grayImage); //pictureBox3.Image = monoImage; Closing close = new Closing(); // apply the filter morphImage = close.Apply(grayImage); // create filter Opening open = new Opening(); // apply the filter k = open.Apply(morphImage); pictureBox3.Image = k; }
public Bitmap Apply(Bitmap originalImage) { //reduce image size so that less, bicubic resizes with less breakage ResizeBicubic resizeObject = new ResizeBicubic(200, 200); Bitmap smallOriginalImage = resizeObject.Apply(originalImage); Bitmap copiedImage = (Bitmap)smallOriginalImage.Clone(); // to get the colour of the pixel passed as parameter for (int x = 0; x < smallOriginalImage.Width; x++) { for (int y = 0; y < smallOriginalImage.Height; y++) { if (!isSkin(copiedImage.GetPixel(x, y))) { copiedImage.SetPixel(x, y, Color.Black); } } } copiedImage = Grayscale.CommonAlgorithms.BT709.Apply(copiedImage); Threshold bwObj = new Threshold(50); copiedImage = bwObj.Apply(copiedImage); //applying closing to remove small black spots(closing holes in the image) i.e dilusion followed by erosion AForge.Imaging.Filters.Closing filter = new Closing(); copiedImage = filter.Apply(copiedImage); //pictureBox2.Image = copiedImage; //extracting the biggest blob or a blob to get only the palms, here we get the bounding box //bounding box is the smallest box having the image, hence we see only the palms ExtractBiggestBlob biggestblobObject = new ExtractBiggestBlob(); copiedImage = biggestblobObject.Apply(copiedImage); //we need to get the coordinates of the bounding box IntPoint point = biggestblobObject.BlobPosition; //create a rectangle to pass to the crop class, it takes x,y,height,width Rectangle rect = new Rectangle(point.X, point.Y, copiedImage.Width, copiedImage.Height); Crop cropObject = new Crop(rect); //we pass the original image because that cohtains noise, we remove the background and have only palms Bitmap croppedImage = cropObject.Apply(smallOriginalImage); //we still have a lot of background which need to be removed as the background between the fingers have background //hence we do a logical and between original image and the cropped image with pixels having white pixel //this operation is called as masking for (int x = 0; x < copiedImage.Width; x++) { for (int y = 0; y < copiedImage.Height; y++) { Color c = copiedImage.GetPixel(x, y); if (c.R == 0 && c.G == 0 && c.B == 0) { croppedImage.SetPixel(x, y, Color.Black); } } } //it takes time because each pixel is checked and the image is huge, //so we need to resize, hence we do smallOriginalImage //we need to resize all objects to a standard size croppedImage = resizeObject.Apply(croppedImage); //pictureBox2.Image = croppedImage; croppedImage = Grayscale.CommonAlgorithms.BT709.Apply(croppedImage); CannyEdgeDetector cannyObj = new CannyEdgeDetector(0, 0, 1.4); croppedImage = cannyObj.Apply(croppedImage); Threshold thresObj = new Threshold(20); croppedImage = thresObj.Apply(croppedImage); return(croppedImage); }
public override Bitmap ApplyFilter(List <Bitmap> bitmap) { Closing filter = new Closing(Matrix); return(filter.Apply(bitmap[0])); }
private void squareCloseToolStripMenuItem_Click(object sender, EventArgs e) { Closing filter = new Closing(square); Image = filter.Apply(Image); }