边缘特征点提取
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
边缘特征点提取
这个是主程序:界面和代这
using System;
using System.Collections.Generic;using ponentModel;using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;using System.IO;
namespace 这这这这这影量作1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private string curFileName;
private System.Drawing.Bitmap curBitmap;
int a =0;
int b =0;
int n = 0;
int count = 0;
private void button2_Click(object sender, EventArgs e)
{
OpenFileDialog of = new OpenFileDialog();
of.Filter = "JPG这像(*.jpg)|*.jpg|BMP这像(*.bmp)|*.bmp|所有文件(*.*)|*.*";
of.Title = "打文件这这这";
of.ShowDialog();
curFileName = of.FileName;
try
{
curBitmap = (Bitmap)Image.FromFile(curFileName);
}
catch(Exception ex)
{
MessageBox.Show("出这!" + ex.Message);
}
pictureBox1.Image = Image.FromFile(curFileName );
}
private void button1_Click(object sender, EventArgs e)
{
button4.Visible = true;
int i,j,k,m;
double V1 = 0, V2 = 0,V3 =0, V4 = 0;
double [,]V= new double [curBitmap.Width, curBitmap.Height];
double [,] VV = new double[curBitmap.Width, curBitmap.Height];
int [,] Gray = new int[curBitmap.Width, curBitmap.Height];
for (i=0;i for (j = 0; j < curBitmap.Height; j++) { Color pixelColor = this.curBitmap.GetPixel(i,j); Gray[i, j] = (int )(pixelColor.R * 0.299 + pixelColor.G * 0.587 + pixelColor.B * 0.114);//灰度算公式这这这这 } for (i=2;i for (j = 2; j < curBitmap.Height-2; j++) { for (k = -2; k < 2; k++) { V1 += (Gray[i + k, j] - Gray[i + k + 1, j]) * (Gray[i + k, j] - Gray[i + k + 1, j]); V2 += (Gray[i + k, j + k] - Gray[i + k + 1, j + k + 1]) * (Gray[i + k, j + k] - Gray[i + k + 1, j + k + 1]); V3 += (Gray[i, j + k] - Gray[i, j + k + 1]) * (Gray[i, j + k] - Gray[i, j + k + 1]); V4 += (Gray[i - k, j + k] - Gray[i - k - 1, j + k + 1]) * (Gray[i - k, j + k] - Gray[i - k - 1, j + k + 1]); } V[i, j] = MaxMin.MyMin(V1, V2, V3, V4); V1 = 0; V2 = 0; V3 = 0; V4 = 0; } for (i = 2; i < curBitmap.Width - 2; i++) for (j = 2; j < curBitmap.Height - 2; j++) { try { if (V[i, j] >= Convert.ToDouble(textBox1.Text)) { VV[i, j] = 1; } else { VV[i, j] = 0;