www.pudn.com > 用形态学方法提取骨架线.rar > Morphology.h


// Morphology.h: interface for the CMorphology class. 
// 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_MORPHOLOGY_H__A996C535_5FE4_4B42_A217_291F5635D9FD__INCLUDED_) 
#define AFX_MORPHOLOGY_H__A996C535_5FE4_4B42_A217_291F5635D9FD__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
const int STRUCTURE_ELEMENT =100;			//结构元素初始 
const int SE_SQUARE =STRUCTURE_ELEMENT+1;	//方形结构元素	3×3 
const int SE_RHOMBUS =STRUCTURE_ELEMENT+2;	//菱形结构元素	3×3 
const int SE_CRICLE =STRUCTURE_ELEMENT+3;	//圆形结构元素	5×5 
const int STRUCTURE_ELEMENT_END =STRUCTURE_ELEMENT+4;	//结构元素结束 
 
#define _COLOR_BLACK //黑色为0的情况下 
#ifdef _COLOR_BLACK 
const BYTE COLOR_BLACK=0; 
const BYTE COLOR_WHITE=255; 
#else 
const BYTE COLOR_BLACK=255; 
const BYTE COLOR_WHITE=0; 
#endif 
 
class CMorphology   
{ 
public: 
	bool Thinning(BYTE* pBuf,int nWidth,int nHeight);//标准细化算法 
	bool Skeleton(BYTE *pBuf, int nSEType, int nWidth, int nHeight); 
	/*骨架化 
	功能:对二值图像进行骨架化 
	输入:pBuf 
	输出:pBuf 
	参数:nSEType:结构元素类型,nWidth:图像宽度,nHeight:图像高度 
	*/ 
	bool Open(BYTE* pSrcBuf,BYTE* pDestBuf,int nSEType,int nWidth,int nHeight,BYTE* pSEType=NULL,int nSEWidth=0);//开运算 
	bool Dilate(BYTE* pSrcBuf,BYTE* pDestBuf,int nSEType,int nWidth,int nHeight,BYTE* pSEType=NULL,int nSEWidth=0); 
	/*扩张 
	功能:对二值图像进行扩张操作 
	输入:pSrcBuf 
	输出:pDestBuf 
	参数:nSEType:结构元素类型,nWidth:图像宽度,nHeight:图像高度 
	*/ 
	bool Erode(BYTE* pSrcBuf,BYTE* pDestBuf,int nSEType,int nWidth,int nHeight,BYTE* pSEType=NULL,int nSEWidth=0);//腐蚀运算 
	bool Skeletonizing(BYTE *pBuf, int nSEType, int nWidth, int nHeight); 
	 
	CMorphology(); 
	virtual ~CMorphology(); 
 
private: 
	BYTE* m_pSE;	//结构元素,默认核点为中心元素 
	int m_nSEWidth;	//结构元素宽度 
protected: 
	void XOR(BYTE *pSrcBuf1, BYTE *pSrcBuf2, BYTE *pDestBuf, int nWidth, int nHeight);//差运算 
	void OR(BYTE *pSrcBuf1, BYTE *pSrcBuf2, BYTE *pDestBuf, int nWidth, int nHeight);//并运算 
	void AND(BYTE *pSrcBuf1,BYTE* pSrcBuf2,BYTE* pDestBuf, int nWidth, int nHeight); 
	void SetSE(const int nDefSEType,BYTE* pSEType=NULL,int nSEWidth=0);	//设置结构元素,参数为结构元素类型,值1代表有元素 
}; 
 
#endif // !defined(AFX_MORPHOLOGY_H__A996C535_5FE4_4B42_A217_291F5635D9FD__INCLUDED_)