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);
}