• 大小: 5.44MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-02
  • 语言: C#
  • 标签:

资源简介

1 C#开发 2 将两张有部分重叠的图片,融合成一张图片 3 本人亲试,绝对可行

资源截图

代码片段和文件信息

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

namespace Panorama
{
    public partial class MainForm : Form
    {
        private Bitmap img1 = Panorama.Properties.Resources.UFSCar_Lake1;
        private Bitmap img2 = Panorama.Properties.Resources.UFSCar_Lake2;

        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 btnHarris_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 btnCorrelation_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 btnRansac_Click(object sender EventArgs e)
        {
            // Step 3: Create the homography matrix using a robust estimator
            RansacHomographyEstimator ransac = new RansacHomographyEstimator(0.001 0.99);
           

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2010-10-26 18:37  Externals\
     文件       11264  2010-08-31 23:35  Externals\AForge.dll
     文件      207360  2010-08-31 23:35  Externals\AForge.Imaging.dll
     文件       33280  2010-08-31 23:35  Externals\AForge.Math.dll
     目录           0  2010-10-26 18:16  Samples\
     目录           0  2010-10-26 18:16  Samples\Imaging\
     目录           0  2010-10-26 18:57  Samples\Imaging\Panorama\
     文件        4429  2010-08-24 22:07  Samples\Imaging\Panorama\MainForm.cs
     文件        7526  2010-07-20 19:58  Samples\Imaging\Panorama\MainForm.Designer.cs
     文件      179860  2010-07-10 23:59  Samples\Imaging\Panorama\MainForm.resx
     文件        5774  2010-10-26 18:32  Samples\Imaging\Panorama\Panorama.csproj
     文件         503  2010-07-10 23:59  Samples\Imaging\Panorama\Program.cs
     目录           0  2010-10-26 18:12  Samples\Imaging\Panorama\Properties\
     文件        1402  2010-07-10 23:59  Samples\Imaging\Panorama\Properties\AssemblyInfo.cs
     文件        4441  2010-07-10 23:59  Samples\Imaging\Panorama\Properties\Resources.Designer.cs
     文件        7481  2010-07-10 23:59  Samples\Imaging\Panorama\Properties\Resources.resx
     文件        1089  2010-07-10 23:59  Samples\Imaging\Panorama\Properties\Settings.Designer.cs
     文件         249  2010-07-10 23:59  Samples\Imaging\Panorama\Properties\Settings.settings
     目录           0  2010-10-26 18:12  Samples\Imaging\Panorama\Resources\
     文件     1336999  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\green_nature.jpg
     文件     1266695  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\green_nature1.jpg
     文件     1608979  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\green_nature2.jpg
     文件      154032  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\PICT0107a.jpg
     文件      160311  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\PICT0108a.jpg
     文件      481327  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\PICT0126a.png
     文件      499390  2010-07-10 23:59  Samples\Imaging\Panorama\Resources\PICT0127a.png
     目录           0  2010-10-26 18:21  Sources\
     目录           0  2010-10-26 18:56  Sources\Accord.Imaging\
     文件        4481  2010-10-26 18:31  Sources\Accord.Imaging\Accord.Imaging.csproj
     文件         168  2010-10-26 18:54  Sources\Accord.Imaging\Accord.Imaging.csproj.user
     文件       11773  2010-08-25 20:02  Sources\Accord.Imaging\CorrelationMatching.cs
............此处省略46个文件信息

评论

共有 条评论

相关资源