1、求闭合线Feature的傅里叶算子及信息量
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geometry;
using System.Collections;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class Fourier
{
//点集
private IPointCollection pointCol = null;
//还原点集?(截至2017-11-08未使用)
private IPointCollection newPointCol = null;
//点的数量
private long m_PointNum = 0;
//算子数量
private long nTerm = 0;
//Si
private double[] m_accuDist = null;
//点i-1到点Si的距离
private double[] m_dis_betPoint = null;
//总长度
private double m_totalS = 0.0;
//Ax,Bx,Ay,By系数数组
private double[] Ax = null;
private double[] Bx = null;
private double[] Ay = null;
private double[] By = null;
//傅里叶算子
private double[] d = null;
//每个算子所占比例
private double[] ratio = null;
//清除距离过近的点
public Fourier(IPointCollection pointcollection, long nTerm)
{
this.nTerm = nTerm;
while (true)
{
bool bOK = true;
pointCol = pointcollection;
for (int i = 1; i < pointCol.PointCount; i++)
{
IPoint p1 = pointCol.get_Point(i - 1);
IPoint p2 = pointCol.get_Point(i);
if (Math.Abs(p1.X - p2.X) < 0.1 && Math.Abs(p1.Y - p2.Y) < 0.1)
{
pointCol.RemovePoints(i, 1);
i--;
bOK = false;
}
}
if (bOK)
{
m_PointNum = pointCol.PointCount;
break;
}
}
}
public double GetAx(int index)
{
return Ax[index];
}
public double GetBx(int index)
{
return Bx[index];
}
public double GetAy(int index)
{
return Ay[index];
}
public double GetBy(int index)
{
return By[index];
}
public double GetShapeVector(int index)
{
return d[index];
}
public double GetRatio(int index)
{
return ratio[index];
}
public double[] ArrayAx()
{
return Ax;
}
public double[] ArrayBx()
{
return Bx;
}
public double[] ArrayAy()
{
return Ay;
}
public double[] ArrayBy()
{
return By;
}
public void CalculateAllValue()
{
GetAllDist();
GetFourierXparameter();
GetFourierYparameter();
CalculateShapeVector();
}
//public void GetAllDist()
//{
// m_dis_betPoint = new double[m_PointNum - 1];
// m_accuDist = new double[m_PointNum];
// for (int i = 0; i < m_PointNum - 1; i++)
// {
// IPoint p2 = pointCol.get_Point(i + 1);
// IPoint p1 = pointCol.get_Point(i);
// double detx = p2.X - p1.X;
// double dety = p2.Y - p1.Y; ;
// double squareSum = detx * detx + dety * dety;
// m_dis_betPoint[i] = Math.Sqrt(squareSum);
// }
// double s = 0.0;
// m_accuDist[0] = 0.0;
// for (int i = 0; i < m_PointNum - 1; i++)
// {
// m_accuDist[i + 1] = s + m_dis_betPoint[i];
// s = m_accuDist[i + 1];
// }
// m_totalS = m_accuDist[m_PointNum - 1];
//}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.Geometry;
using System.Collections;
using System.Windows.Forms;
namespace ClassLibrary1
{
public class Fourier
{
//点集
private IPointCollection pointCol = null;
//还原点集?(截至2017-11-08未使用)
private IPointCollection newPointCol = null;
//点的数量
private long m_PointNum = 0;
//算子数量
private long nTerm = 0;
//Si
private double[] m_accuDist = null;
//点i-1到点Si的距离
private double[] m_dis_betPoint = null;
//总长度
private double m_totalS = 0.0;
//Ax,Bx,Ay,By系数数组
private double[] Ax = null;
private double[] Bx = null;
private double[] Ay = null;
private double[] By = null;
//傅里叶算子
private double[] d = null;
//每个算子所占比例
private double[] ratio = null;
//清除距离过近的点
public Fourier(IPointCollection pointcollection, long nTerm)
{
this.nTerm = nTerm;
while (true)
{
bool bOK = true;
pointCol = pointcollection;
for (int i = 1; i < pointCol.PointCount; i++)
{
IPoint p1 = pointCol.get_Point(i - 1);
IPoint p2 = pointCol.get_Point(i);
if (Math.Abs(p1.X - p2.X) < 0.1 && Math.Abs(p1.Y - p2.Y) < 0.1)
{
pointCol.RemovePoints(i, 1);
i--;
bOK = false;
}
}
if (bOK)
{
m_PointNum = pointCol.PointCount;
break;
}
}
}
public double GetAx(int index)
{
return Ax[index];
}
public double GetBx(int index)
{
return Bx[index];
}
public double GetAy(int index)
{
return Ay[index];
}
public double GetBy(int index)
{
return By[index];
}
public double GetShapeVector(int index)
{
return d[index];
}
public double GetRatio(int index)
{
return ratio[index];
}
public double[] ArrayAx()
{
return Ax;
}
public double[] ArrayBx()
{
return Bx;
}
public double[] ArrayAy()
{
return Ay;
}
public double[] ArrayBy()
{
return By;
}
public void CalculateAllValue()
{
GetAllDist();
GetFourierXparameter();
GetFourierYparameter();
CalculateShapeVector();
}
//public void GetAllDist()
//{
// m_dis_betPoint = new double[m_PointNum - 1];
// m_accuDist = new double[m_PointNum];
// for (int i = 0; i < m_PointNum - 1; i++)
// {
// IPoint p2 = pointCol.get_Point(i + 1);
// IPoint p1 = pointCol.get_Point(i);
// double detx = p2.X - p1.X;
// double dety = p2.Y - p1.Y; ;
// double squareSum = detx * detx + dety * dety;
// m_dis_betPoint[i] = Math.Sqrt(squareSum);
// }
// double s = 0.0;
// m_accuDist[0] = 0.0;
// for (int i = 0; i < m_PointNum - 1; i++)
// {
// m_accuDist[i + 1] = s + m_dis_betPoint[i];
// s = m_accuDist[i + 1];
// }
// m_totalS = m_accuDist[m_PointNum - 1];
//}