www.pudn.com > B-spline.zip > bspline.h, change:2012-03-17,size:1459b


#ifndef _BSPLINE_H 
#define _BSPLINE_H 
 
#include<cv.h> 
#include<cxcore.h> 
#include<highgui.h> 
#include<list> 
 
//B-样条曲线 
 
#define U_UPPER_LIMIT 1.0f					//曲线参数u的上限值 
#define U_LOWER_LIMIT 0.0f					//曲线参数u的下限值 
 
class B_SPLine;								//主要用于描绘B样条曲线 
 
typedef struct _ControlPoint{				//控制点数据结构 
	CvPoint point; 
}ControlPoint; 
 
typedef struct _mouseParam{ 
	B_SPLine *pclass; 
	IplImage *img; 
}mouseParam; 
 
//2k+1<n 
class B_SPLine 
{ 
public: 
	B_SPLine(int k = 3); 
	~B_SPLine(); 
 
	bool GetBSPLine(float u,ControlPoint *result);		//result为根据B样条曲线估计的值 
	std::list<ControlPoint> m_ControlPoints; 
	 
	void DrawBSPLine(IplImage *img);					//在指定的图像上描绘B样条曲线 
 
	mouseParam m_MouseParam; 
	void InitMouseControlPoint(char *windowName,IplImage *img);						//初始化鼠标获取控制点 
	friend void MouseCallback(int mouseEvent,int x,int y,int flags,void *param);			//B样条曲线类的鼠标回调函数 
 
private:	 
	float m_DeltaU;							//区间的宽度 
	float m_LowerBound;						//输入参数u所在区间的下界 
	int m_LowerBoundIdx;					//下界索引 
	float m_UpperBound;						//输入参数u所在区间的上界 
	float *m_Niku; 
	int m_K;								//B样条的k次规范 
	void CalcNiku(float u);							//根据u计算有关联的Nik(u) 
	float GetNiku(int l,int k);							//从内存中获取Ni-l,k(u)的值 
	void SetNiku(int l,int k,float value);				 
	void GetURegion(float u);							//计算输入参数u所在区间的上、下界值 
}; 
 
 
 
#endif