www.pudn.com > Snakes.rar > SnakesApp.H


// dibapi.h 
 
#ifndef _INC_SNAKESAPP 
#define _INC_SNAKESAPP 
#include "dibapi.h" 
const int INITIAL = 0; 
const int ACTIVE = 1; 
const int EXPANDED = 2; 
 
// added by dewey 
const double SQRT2 = 1.4142135623730950488016887242097; 
const double SQINV = 1.0/SQRT2; 
const double PI=3.1415926; 
 
// The eight filter kernels 
/////////////////////////////////////////////////////////////////////// 
// TODO: put all the correct numbers where they belong in the 3 x 3 filter kernels 
// hint: you may want to make use of one of the constants defined above 
struct Grad 
{ 
	double Ix,Iy,G; 
}; 
struct Vector 
{ 
	double x; 
	double y; 
}; 
struct Node{ 
	CPoint point; 
	Node *next; 
}; 
//Define the class of the CSnakes 
class CSnakes 
{ 
public: 
	LONG	lWidth;	 
	// 图像高度 
	LONG  	lHeight; 
	double MaxCost; 
	bool Is_StartDraw; 
	CPoint *pos; 
	long p_NumPos; 
	long pp; 
private: 
	HDIB hDIB;	 
	Grad *fG; 
	LONG	lLineBytes;	 
		// 指向DIB象素数据区的指针 
	LPSTR   lpDIBBits;	 
	LPSTR	lpDIB; 
	// 指向BITMAPINFO结构的指针(Win3.0) 
	LPBITMAPINFO lpbmi;	 
	CDC*pDC; 
	double *ImageData; 
	long OldIndex; 
 
	 
	CPoint p_OldPos; 
	 
	Node *p,*top; 
	 
public: 
	CSnakes(HDIB m_hDIB); 
	~CSnakes(); 
	void Gauss(); 
void InternalEnergy(CPoint *pos,long num,double &ien); 
void MiniMizeEnergy(); 
void nbrNodeOffset(int &offsetX, int &offsetY, int linkIndex); 
void nbrNodeOffset_Gauss5(int &offsetX, int &offsetY, int linkIndex); 
void GVF(); 
void LButtonDown(CPoint point,CDC*pDC); 
void LButtonUp(CPoint point,CDC*pDC); 
void MouseDownAndMove(CPoint point,CDC*pDC); 
double In(long x,long y,long nWidth,double*lpInPut){return lpInPut[(x)+(y)*nWidth];} 
//梯度函数 
void Gradient(); 
double squ(double x,double y); 
void DrawGV(CDC*pDC); 
 
//************************************************************** 
//Snakes FUnction 
double *alpha,*beta,*gamma;/* Weights for energies */ 
double *curvature; 
bool termination_point; 
int no_of_snake_points; 
CPoint *Snake_points; 
int m_Cols; /* Number of Columns */ 
int m_Rows; /* Number of Rows */ 
double *grad_mag; 
double threshold_curvature;  
bool neighbor3by3; /* true means 3x3 neighborhood, false means 5x5 neighborhood */ 
int threshold_movement; 
double dmax,dmin; 
 
void Snake_algorithm(); 
void Snake_interp(); 
double find_distance(int no, CPoint point); 
CPoint find_min_energy(int no, CPoint point, double avg_distance); 
double find_curvature(int no, CPoint point); 
double find_continuity(int no, CPoint point, double avg_distance); 
 
}; 
 
#endif//INC_INFSCISSOR