public MainForm() { InitializeComponent(); // Concatenate and show entire image at start Concatenate concatenate = new Concatenate(img1); pictureBox.Image = concatenate.Apply(img2); }
private void btnSurf_Click(object sender, EventArgs e) { // Step 1: Detect feature points using Surf Corners Detector SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector(); surfPoints1 = surf.ProcessImage(img1).ToArray(); surfPoints2 = surf.ProcessImage(img2).ToArray(); // Show the marked points in the original images Bitmap img1mark = new FeaturesMarker(surfPoints1).Apply(img1); Bitmap img2mark = new FeaturesMarker(surfPoints2).Apply(img2); // Concatenate the two images together in a single image (just to show on screen) Concatenate concatenate = new Concatenate(img1mark); pictureBox.Image = concatenate.Apply(img2mark); }
private void btnFreak_Click(object sender, EventArgs e) { // Step 1: Detect feature points using FREAK Features Detector FastRetinaKeypointDetector freak = new FastRetinaKeypointDetector(); keyPoints1 = freak.ProcessImage(img1).ToArray(); keyPoints2 = freak.ProcessImage(img2).ToArray(); // Show the marked points in the original images Bitmap img1mark = new PointsMarker(keyPoints1).Apply(img1); Bitmap img2mark = new PointsMarker(keyPoints2).Apply(img2); // Concatenate the two images together in a single image (just to show on screen) Concatenate concatenate = new Concatenate(img1mark); pictureBox.Image = concatenate.Apply(img2mark); }
private void btnHarris_Click(object sender, EventArgs e) { // Step 1: Detect feature points using Harris Corners Detector HarrisCornersDetector harris = new HarrisCornersDetector( HarrisCornerMeasure.Harris, 20000f, 1.4f, 5); harrisPoints1 = harris.ProcessImage(img1).ToArray(); harrisPoints2 = harris.ProcessImage(img2).ToArray(); // Show the marked points in the original images Bitmap img1mark = new PointsMarker(harrisPoints1).Apply(img1); Bitmap img2mark = new PointsMarker(harrisPoints2).Apply(img2); // Concatenate the two images together in a single image (just to show on screen) Concatenate concatenate = new Concatenate(img1mark); pictureBox.Image = concatenate.Apply(img2mark); }
private void BtnCorrelation_OnClick(object sender, RoutedEventArgs e) { // Step 2: Match feature points using a correlation measure CorrelationMatching matcher = new CorrelationMatching(9); IntPoint[][] matches = matcher.Match(img1, img2, harrisPoints1, harrisPoints2); // Get the two sets of points correlationPoints1 = matches[0]; correlationPoints2 = matches[1]; // Concatenate the two images in a single image (just to show on screen) Concatenate concat = new Concatenate(img1); Bitmap img3 = concat.Apply(img2); // Show the marked correlations in the concatenated image PairsMarker pairs = new PairsMarker( correlationPoints1, // Add image1's width to the X points to show the markings correctly correlationPoints2.Apply(p => new IntPoint(p.X + img1.Width, p.Y))); PictureBox.Source = pairs.Apply(img3); }
public void ConcatenateConstructorTest() { Bitmap img1 = Properties.Resources.image1; Bitmap img2 = Properties.Resources.image2; Concatenate target = new Concatenate(img1); var img3 = target.Apply(img2); Assert.AreEqual(System.Math.Max(img1.Height, img2.Height), img3.Height); Assert.AreEqual(img1.Width + img2.Width, img3.Width); for (int i = 0; i < 16; i++) for (int j = 0; j < 16; j++) Assert.AreEqual(img1.GetPixel(i, j), img3.GetPixel(i, j)); for (int i = 0; i < 16; i++) for (int j = 0; j < 16; j++) Assert.AreEqual(img2.GetPixel(i, j), img3.GetPixel(i + 16, j)); }
private void btnCorrelation_Click(object sender, EventArgs e) { if (surfPoints1 == null) { MessageBox.Show("Please, click SURF button first! :-)"); return; } // Step 2: Match feature points using a k-NN KNearestNeighborMatching matcher = new KNearestNeighborMatching(5); IntPoint[][] matches = matcher.Match(surfPoints1, surfPoints2); // Get the two sets of points correlationPoints1 = matches[0]; correlationPoints2 = matches[1]; // Concatenate the two images in a single image (just to show on screen) Concatenate concat = new Concatenate(img1); Bitmap img3 = concat.Apply(img2); // Show the marked correlations in the concatenated image PairsMarker pairs = new PairsMarker( correlationPoints1, // Add image1's width to the X points to show the markings correctly correlationPoints2.Apply(p => new IntPoint(p.X + img1.Width, p.Y))); pictureBox.Image = pairs.Apply(img3); }
private void btnRansac_Click(object sender, EventArgs e) { if (correlationPoints1 == null) { MessageBox.Show("Please, click Nearest Neighbor button first! :-)"); return; } if (correlationPoints1.Length < 4 || correlationPoints2.Length < 4) { MessageBox.Show("Insufficient points to attempt a fit."); return; } // Step 3: Create the homography matrix using a robust estimator RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); homography = ransac.Estimate(correlationPoints1, correlationPoints2); // Plot RANSAC results against correlation results IntPoint[] inliers1 = correlationPoints1.Submatrix(ransac.Inliers); IntPoint[] inliers2 = correlationPoints2.Submatrix(ransac.Inliers); // Concatenate the two images in a single image (just to show on screen) Concatenate concat = new Concatenate(img1); Bitmap img3 = concat.Apply(img2); // Show the marked correlations in the concatenated image PairsMarker pairs = new PairsMarker( inliers1, // Add image1's width to the X points to show the markings correctly inliers2.Apply(p => new IntPoint(p.X + img1.Width, p.Y))); pictureBox.Image = pairs.Apply(img3); }
private Bitmap CompareAndDrawImage(Bitmap modelImage, Bitmap observedImage, SurfSettings setting) { Stopwatch watch1 = new Stopwatch(); Stopwatch watch2 = new Stopwatch(); Bitmap returnBitmap; watch2.Start(); watch1.Reset(); watch1.Start(); double hessianThreshold = setting.HessianThresh.HasValue ? setting.HessianThresh.Value : 500; float hessianThreshold2 = (float)hessianThreshold / 1000000; Debug.WriteLine("hessianThreshold2: {0}", hessianThreshold2); SpeededUpRobustFeaturesDetector surf = new SpeededUpRobustFeaturesDetector(hessianThreshold2); List<SpeededUpRobustFeaturePoint> surfPoints1 = surf.ProcessImage(modelImage); List<SpeededUpRobustFeaturePoint> surfPoints2 = surf.ProcessImage(observedImage); Debug.WriteLine("Surf points count: {0}", surfPoints1.Count); Debug.WriteLine("Surf points count: {0}", surfPoints2.Count); //long memoryFootprint = MemorySize.GetBlobSizeinKb(surfPoints2); //Debug.WriteLine("Surf extractor: {0} kb", memoryFootprint); watch1.Stop(); Debug.WriteLine("Surf Detection tooked {0} ms", watch1.ElapsedMilliseconds); watch1.Reset(); watch1.Start(); // Show the marked points in the original images Bitmap img1mark = new FeaturesMarker(surfPoints1, 2).Apply(modelImage); Bitmap img2mark = new FeaturesMarker(surfPoints2, 2).Apply(observedImage); // Concatenate the two images together in a single image (just to show on screen) Concatenate concatenate = new Concatenate(img1mark); returnBitmap = concatenate.Apply(img2mark); watch1.Stop(); Debug.WriteLine("Surf point plotting tooked {0} ms", watch1.ElapsedMilliseconds); //watch1.Reset(); watch1.Start(); //List<IntPoint>[] coretionalMatches = getMatches(surfPoints1, surfPoints2); //watch1.Stop(); //Debug.WriteLine("Correctional Match tooked {0} ms", watch1.ElapsedMilliseconds); //// Get the two sets of points //IntPoint[] correlationPoints11 = coretionalMatches[0].ToArray(); //IntPoint[] correlationPoints22 = coretionalMatches[1].ToArray(); //Debug.WriteLine("Correclation points count: {0}", correlationPoints11.Length); //Debug.WriteLine("Correclation points count: {0}", correlationPoints22.Length); Debug.WriteLine("Threshold: {0}", setting.UniquenessThreshold.Value); watch1.Reset(); watch1.Start(); // Step 2: Match feature points using a k-NN KNearestNeighborMatching matcher = new KNearestNeighborMatching(2); matcher.Threshold = setting.UniquenessThreshold.Value; IntPoint[][] matches = matcher.Match(surfPoints1, surfPoints2); watch1.Stop(); Debug.WriteLine("Knn Match tooked {0} ms", watch1.ElapsedMilliseconds); // Get the two sets of points IntPoint[] correlationPoints1 = matches[0]; IntPoint[] correlationPoints2 = matches[1]; Debug.WriteLine("Knn points count: {0}", correlationPoints1.Length); Debug.WriteLine("Knn points count: {0}", correlationPoints2.Length); //watch1.Reset(); watch1.Start(); //// Show the marked correlations in the concatenated image //PairsMarker pairs = new PairsMarker( // correlationPoints1, // Add image1's width to the X points to show the markings correctly // correlationPoints2.Apply(p => new IntPoint(p.X + modelImage.Width, p.Y)), Color.Blue); //returnBitmap = pairs.Apply(returnBitmap); //watch1.Stop(); //Debug.WriteLine("Match pair marking tooked {0} ms", watch1.ElapsedMilliseconds); if (correlationPoints1.Length < 4 || correlationPoints2.Length < 4) { MessageBox.Show("Insufficient points to attempt a fit."); return null; } watch1.Reset(); watch1.Start(); // Step 3: Create the homography matrix using a robust estimator //RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); MatrixH homography = ransac.Estimate(correlationPoints1, correlationPoints2); watch1.Stop(); Debug.WriteLine("Ransac tooked {0} ms", watch1.ElapsedMilliseconds); watch1.Reset(); watch1.Start(); // Plot RANSAC results against correlation results IntPoint[] inliers1 = correlationPoints1.Submatrix(ransac.Inliers); IntPoint[] inliers2 = correlationPoints2.Submatrix(ransac.Inliers); watch1.Stop(); Debug.WriteLine("Ransac SubMatrix {0} ms", watch1.ElapsedMilliseconds); Debug.WriteLine("Ransac points count: {0}", inliers1.Length); Debug.WriteLine("Ransac points count: {0}", inliers2.Length); watch1.Reset(); watch1.Start(); PairsMarker inlierPairs = new PairsMarker( inliers1, // Add image1's width to the X points to show the markings correctly inliers2.Apply(p => new IntPoint(p.X + modelImage.Width, p.Y)), Color.Red); returnBitmap = inlierPairs.Apply(returnBitmap); watch1.Stop(); Debug.WriteLine("Ransac plotting tooked {0} ms", watch1.ElapsedMilliseconds); watch2.Stop(); return returnBitmap; }
private void BtnRansac_OnClick(object sender, RoutedEventArgs e) { // Step 3: Create the homography matrix using a robust estimator RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); homography = ransac.Estimate(correlationPoints1, correlationPoints2); // Plot RANSAC results against correlation results IntPoint[] inliers1 = correlationPoints1.Submatrix(ransac.Inliers); IntPoint[] inliers2 = correlationPoints2.Submatrix(ransac.Inliers); // Concatenate the two images in a single image (just to show on screen) Concatenate concat = new Concatenate(img1); Bitmap img3 = concat.Apply(img2); // Show the marked correlations in the concatenated image PairsMarker pairs = new PairsMarker( inliers1, // Add image1's width to the X points to show the markings correctly inliers2.Apply(p => new IntPoint(p.X + img1.Width, p.Y))); PictureBox.Source = pairs.Apply(img3); }
private void MainPage_OnLoaded(object sender, RoutedEventArgs e) { var bmpi = new BitmapImage(); bmpi.SetSource(Application.GetResourceStream(new Uri(@"Resources/UFSCar_Lake1.png", UriKind.Relative)).Stream); img1 = ((Bitmap)new WriteableBitmap(bmpi)).Clone(PixelFormat.Format24bppRgb); bmpi.SetSource(Application.GetResourceStream(new Uri(@"Resources/UFSCar_Lake2.png", UriKind.Relative)).Stream); img2 = ((Bitmap)new WriteableBitmap(bmpi)).Clone(PixelFormat.Format24bppRgb); // Concatenate and show entire image at start Concatenate concatenate = new Concatenate(img1); PictureBox.Source = concatenate.Apply(img2); }
private void button2_Click(object sender, EventArgs e) { // Step 3: Create the homography matrix using a robust estimator RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001, 0.99); homography = ransac.Estimate(correlationPoints1, correlationPoints2); // Plot RANSAC results against correlation results IntPoint[] inliers1 = correlationPoints1.Submatrix(ransac.Inliers); IntPoint[] inliers2 = correlationPoints2.Submatrix(ransac.Inliers); // Concatenate the two images in a single image (just to show on screen) Concatenate concat = new Concatenate(img1); Bitmap img3 = concat.Apply(img2); // Show the marked correlations in the concatenated image PairsMarker pairs = new PairsMarker( inliers1, // Add image1's width to the X points to show the markings correctly inliers2.Apply(p => new IntPoint(p.X + img1.Width, p.Y))); pictureBox1.Image = pairs.Apply(img3); numA.Value = (decimal)homography.Elements[0]; numB.Value = (decimal)homography.Elements[1]; numC.Value = (decimal)homography.Elements[2]; numD.Value = (decimal)homography.Elements[3]; numE.Value = (decimal)homography.Elements[4]; numF.Value = (decimal)homography.Elements[5]; numG.Value = (decimal)homography.Elements[6]; numH.Value = (decimal)homography.Elements[7]; }