<pre lang="C#"> <pre>Bitmap map = (Bitmap)pictureBox1.Image; //load the input image /*Image<Bgr, Byte> inputImage = new Image<Bgr, Byte>(map); //create a log mask with a path clearly defined to where the file is Image<Gray, Byte> mask = new Image<Gray, Byte>(inputImage.Width, inputImage.Height); //path to the image mask.SetValue(new Gray(255), new Image<Gray, Byte>("C:\\Users\\99ENT$TECH\\Pictures\\logo2.jpg")); Image<Bgr, Byte> outputImage = inputImage.InPaint(mask, 3); //assign the image to picture box 2 */ //convert image to gray scale; Grayscale grayscaleFilter = new Grayscale(0.2125, 0.7154, 0.0721); Bitmap grayImage = grayscaleFilter.Apply(map); pictureBox2.Image = grayImage; //smoothen the image using a gaussian blur GaussianBlur blurFilter = new GaussianBlur(5, 11); Bitmap blurImage = blurFilter.Apply(grayImage); // Use the Canny edge detection algorithm to detect the edges in the image CannyEdgeDetector edgeFilter = new CannyEdgeDetector(); Bitmap cannyFilter = edgeFilter.Apply(blurImage); // Find the contours in the image BlobCounter blobCounter = new BlobCounter(); blobCounter.MinWidth = 10; blobCounter.MinHeight = 10; blobCounter.FilterBlobs = true; blobCounter.ProcessImage(blurImage); Blob[] blobs = blobCounter.GetObjectsInformation(); // Select the contour that corresponds to the logo int index = 0; // replace with the index of the contour that corresponds to the logo Blob blob = blobs[index]; // Create a mask for the logo blobCounter.ExtractBlobsImage(blurImage,blob, true); // Invert the mask Invert invertFilter = new Invert(); invertFilter.ApplyInPlace(cannyFilter); // Remove the logo from the image by applying the mask to the original image ExtractChannel extractFilter = new ExtractChannel(); Bitmap result = extractFilter.Apply(blurImage); pictureBox2.Image = result;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)