⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prof.hpp

📁 这是个人脸识别程序
💻 HPP
字号:
// $masm\prof.hpp 1.5 milbo$// Warning: this is raw research code -- expect it to be quite messy.// milbo durban jan06#if !defined(prof_hpp)#define prof_hpp//-----------------------------------------------------------------------------//TODO move these to masmconfig.hpp?// for finding out which shapes are causing pixel out-of-range errors#define CONF_fFindOffRangePixels	0#define CONF_fPrintOffRangePixels	0//-----------------------------------------------------------------------------// Profile specifications// We OR bits defined below to get a full specification of the profile type//// Layout is 2.ww.... Byte2 Byte1 Byte0//// where .		unused bits (always 0)//		 2      is 2d/1d field//		 ww     is window field (2d profs only)//// Byte2, Byte1, and Byte0 specify the profile type for up to 3 sub prof types per landmark.// If there is only one sub profile type for a landmark then Byte2 and Byte1 are 0.// See nSubProfsForProfSpecs() for some code.//// Bits in Byte2, Byte1, and Byte0 are//       nn     is normalization field e.g. PROF_Flat//		 F		FBit filter bit://					0 means uses filter specified by TypeField tttt bits (see defs below)//						these are specialized filters optimized for speed//						e.g. PROF_Grad//					1 means use gImMasks array where ttt is an index into gImMasks//					    these are general purpose filters for experimentation//		 tttt	TBits: meaning depends on F bit above e.g. PROF_MaskGray//// For classic Cootes 1-dimensional profiles use PROF_Flat|PROF_Grad//// For a given ProfSpec you can have either (i)  a single one-dimensional subprofile// 									     or (ii) 1 to 3 two-dimensional subprofiles// Mixing 1d and 2d profiles isn't allowed// More than one 1d profile isn't allowed (the code doesn't support it// even though the defines below allow it)#define CONF_nMaxSubProfs			3			// up to 3 subprofs per profile												// (limited by len of unsigned ProfSpec)#define PROF_1d						0x00000000	// one classic 1D profile along whisker#define PROF_2d						0x80000000	// two dimensional profile#define PROF_WindowEquallyWeighted	0x00000000	// windows are for use with PROF_2d only#define PROF_WindowGaussian			0x10000000#define PROF_WindowCircle			0x20000000#define PROF_WindowField			0x30000000	// all of the above// Defs for Byte2, Byte1, Byte0#define PROF_SigmLen		 		0x00	// use sigmoid equalization, variation 1											//     (was PROF_NoNormalize in old code TODO)#define PROF_Flat			 		0x40	// normalize#define PROF_SigmAbsSum 			0x80	// use sigmoid equalization#define PROF_NormalizationField		0xC0	// all of the above#define PROF_FBit					0x10 	// 2D: if 1, tttt bits are a PROF_Mask											//				 i.e. an index into gImMask											//     if 0, tttt bits are defined below// defs if F bit is 0#define PROF_Grad					0x1		// 1D: signed grad between this pixel and next											//		 	(not supported for 2D profiles)#define PROF_GradMagBelowRight		0x2 	// Called "Mask021Mag" in my master's thesis											// 2D: unsigned grad between this pix and pixels											//		to right and below, always non-negative											// 1D: unsigned grad between this pixel and pixel											// 		to right, always non-negative#define PROF_Edgeness				0x3 	// 2D: edgeness as defined in ScottCootesTaylor											//		"Improving Appearance Model..."#define PROF_Cornerness				0x4 	// 2D: cornerness, as defined in ditto (note: code is											//		quicker if SubProfs for edgeness and											//		cornerness are adjacent)#define PROF_GradBelowRight			0x5 	// Called "Mask021" in my dissertation											// Equivalent to PROF_Mask021 (but quicker)											// 2D: similar to PROF_GradMagBelowRight but											// 		doesn't use root-mean-square#define PROF_HarrisStephens			0x6 	// 2D: Harris Stephens detector#define PROF_TBits					0x7		// 1D,2D: all of the above#define PROF_NO_NORMALIZE_BMP		0		// debug: values for fNormalizeBmp parameter#define PROF_NORMALIZE_BMP			1#define CONF_UnusedGradVal			0		// both: used for parts of gradient image											// where grad can't be calculated//-----------------------------------------------------------------------------// We use these defs if F bit is 1, the ttt bits are an index into gImMasks.// Note that PROF_Mask021 is the same as PROF_GradBelowRight.typedef double tImMask33[3][3];	// 3 by 3 mask#define PROF_MaskGray 	0		// must match PROF_Masks below#define PROF_Mask021 	1		// names based on the middle horizontal elements#define PROF_Mask141 	2#define PROF_Mask181 	3#define PROF_Mask000 	4#define PROF_Mask202 	5#define PROF_Mask011 	6#define PROF_Mask010 	7static const tImMask33 gImMasks[] =	// must match eImMasks above{	{ 0,  0,  0,		// PROF_MaskGray: gray level	  0,  1,  0,	  0,  0,  0 },	{ 0,  0,  0,		// PROF_Mask021: same as PROF_GradBelowRight	  0, -2,  1,	  0,  1,  0 },	{ 0,  1,  0,		// PROF_Mask141: 4 connected Laplacian	  1, -4,  1,	  0,  1,  0 },	{ 1,  1,  1,		// PROF_Mask181: 8 connected Laplacian	  1, -8,  1,	  1,  1,  1 },	{ -1, -2, -1,		// PROF_Mask000: vertical Sobel	   0,  0,  0,	   1,  2,  1 },	{ -1, 0, 1,			// PROF_Mask202: horizontal Sobel	  -2, 0, 2,	  -1, 0, 1 },	{ 0,  0,  0,		// PROF_Mask011: horizontal part of PROF_Mask021	  0, -1,  1,	  0,  0,  0 },	{ 0,  0,  0,		// PROF_Mask010: vertical part of PROF_Mask021	  0, -1,  0,	  0,  1,  0 },};#if 0 // no longer used, give lousy results	{ -2, -2, 0,		// PROF_Mask_202: Mask000 + Mask202	  -2,  0, 2,		//  i.e. sum of vert and horizontal Sobel	   0,  2, 2 },	{ 0,  1,  0,		// PROF_Mask121: "similar" to Mask021, note that sum of elements != 0	  1, -2,  1,	  0,  1,  0 },#endif//-----------------------------------------------------------------------------extern bool fgExplicitPrevNext;extern double gNormalizedProfLen;extern const char *pgCurImageName;		// for debuggingextern int  igCurShape;unsigned GetSubProfSpec(unsigned Prof, unsigned iSub);unsigned nSubProfsForProfSpec(unsigned SubProfSpec);void GetProfStepSize(double *pDeltaX, double *pDeltaY, 			// out		  	const SHAPE &Shape, int iPoint, double ProfAngle,			const tLand Lands[], const SHAPE &AlignedAvShape);bool fProfileNormalizationCausesLinearDependence(unsigned SubProfSpec);void PrepareProf1D(const Image &Img, const Mat &Shape, unsigned SubProfSpec,					const tLand Lands[],					const SHAPE &AlignedAvShape,					// in					int iPoint, int nProfWidth, double ProfAngle,	// in					int iOrthOffset);								// invoid Get1dProf(Vec &Prof,											// out			unsigned SubProfSpec, const Image &Img, int iPoint,			int iOffset, int iRowInGlobal, bool fDumpRawProf);		// invoid Get2dProf (Vec &Prof, 											// out				 	const unsigned ProfSpec, const int iSubProf,	// in					const Image &Img, const MatVec &Grads, 			// in					const SHAPE &Shape, const int iPoint,					const int ixOffset, const int iyOffset,					const int nProfWidth, const bool fDumpRawProf);	// invoid InitGrads(MatVec &Grads, const Image &Img, unsigned ProfSpec);void PrintBmpAsMat(const Image &Img, const char sMsg[]=NULL, const char sFormat[]=NULL); // invoid Write2dProfAsBmp(const Vec &Prof, char sPath[], bool fNormalizeBmp, bool fVerbose); // invoid WriteProfSpecs(int iLev, int nPoints, FILE *pFile);int nGenelemsPerSubProf(unsigned ProfSpec);void ReadProfSpecs(cvec<unsigned> &ProfSpecs, 								// out					  int nPoints, const char sAsmFile[], FILE *pAsmFile);	// inint nGetProfWidth(int ncols, unsigned ProfSpec);void InitGradsIfNeededForModelGeneration(MatVec &Grads, 	// out:		const Image &Img, int iLev, int nPoints);	// in: Img already scaled to this pyr levvoid InitGradsIfNeededForModelSearch(MatVec &Grads, // out		const cvec<unsigned> &ProfSpecs,			// in		const Image &Img, int nPoints,				// in: Img already scaled to this pyr lev		const char sPath[]);						// in: if not "" then write grad image													//        for debugging#endif // prof_hpp

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -