Sei sulla pagina 1di 3

Coding matching on software.

Enjoy.

Coding image mayching :

using System;
using System.Drawing;
using System.Windows.Forms;
using Accord.Imaging;
using Accord.Imaging.Filters;
using Accord.Math;
using AForge;

namespace Image_Matchin_Helmy
{
public partial class MainForm : Form
{
private Bitmap img1 = Image_Matchin_Helmy.Properties.Resources._01Left;
private Bitmap img2 = Image_Matchin_Helmy.Properties.Resources._01Right;

private IntPoint[] harrisPoints1;


private IntPoint[] harrisPoints2;

private IntPoint[] correlationPoints1;


private IntPoint[] correlationPoints2;

private MatrixH homography;

public MainForm()
{
InitializeComponent();

// Concatenate and show entire image at start


Concatenate concatenate = new Concatenate(img1);
pictureBox.Image = concatenate.Apply(img2);
}

private void Harris_Click(object sender, EventArgs e)


{
// Step 1: Detect feature points using Harris Corners Detector
HarrisCornersDetector harris = new HarrisCornersDetector(0.04f, 1000f);
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 correlation_Click(object sender, EventArgs 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.Image = pairs.Apply(img3);

private void imageMatchingToolStripMenuItem_Click(object sender, EventArgs e)


{

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.Image = pairs.Apply(img3);

private void imageMatchingToolStripMenuItem_Click(object sender, EventArgs e)

}
}
}

Potrebbero piacerti anche