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

📄 imagepr.h

📁 一个基于知识的人脸检测系统
💻 H
字号:
#if !defined(AFX_IMAGEPR_H__C02CE795_2BF1_11D7_B637_000021B00837__INCLUDED_)
#define AFX_IMAGEPR_H__C02CE795_2BF1_11D7_B637_000021B00837__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ImagePr.h : header file
//

#include <sys/timeb.h>
#include <time.h>

#include <Mmsystem.h>


/////////////////////////////////////////////////////////////////////////////
// ImagePr view

class ImagePr : public CView
//既然基类为View类,那么它应该可以通过函数重载实现显示的功能。
{
protected:
	//ImagePr();           // protected constructor used by dynamic creation
	DECLARE_DYNCREATE(ImagePr)

// Attributes
public:
	ImagePr(); 
	COLORREF * myPArray; //store the image matrix that for displayed.
	COLORREF * RGBImage; //backup image matrix.
	int myPHeight;
	int myPWidth;

	BYTE *lpBitmap;
	BYTE *lpBits;
	CString Front;
	CString Rear;

	struct sHSI
	{
		short    H;
		float  S;
		BYTE   I;
	};
	
	sHSI * myHSIArray; //store the HSI values of image.
	//int histo[256];      //for histogram
	typedef struct EYESINFACEREG //eyes decription in every skin region
	{
		int FcRegLabel; //the skin region label
		int numOfEyes;
		int *area; //the area of every eye candidate regions
		int sumOfEyes; //the total number of eyes in this skin region.
		int *pupilRow;
		int *pupilCol;
		bool *eyesLocation;//whether this eye is valid or not.
	}eyeREGIONs;

	eyeREGIONs * eyeRegion;

	typedef struct REG //region decription.
	{
		int Centroidrow;
		int Centroidcol;
		int label;      //the label number of a region.
		int sumOfPixels;//in fact,it is region's area.
		int *row;
		int *col;
	}REGION;

	struct FaceLocation
	{
		int xleftup;
		int yleftup;
		int xrightup;
		int yrightup;
		int xleftdown;
		int yleftdown;
		int xrightdown;
		int yrightdown;
	};
	
// Operations
public:
	void HSItrans(char tp);//HSI-RGB or RGB-HSI
	void ReadDIB ( CString fName);

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(ImagePr)
	protected:
	virtual void OnDraw(CDC* pDC);      // overridden to draw this view
	//}}AFX_VIRTUAL

// Implementation
//protected:
public:
	void Gauss();
	bool Coordinates(int,int,int,int);
	CStdioFile tempfile;
	double *mouth_theta;
	void IntAdjust();
	void MomentSeg(); //segment the image by intensity moment
	short *EqualizInten; //equalized intensity value
	void HistEqulization(); //histogram equalizing
	bool *tflg; //intensity and average intensity filtering
	CString fileName; 
	CStdioFile MyFile;//the file to save the results
	void visionImage(); //the image that propessed by visual rules
	void TestClassify(); //classification of the skin pixel that considered highlights but not good for dark
	double hr,nr,sr;
	int *Region;
	void SecEyeExtract();
	void StaticForImage(int &AvgR,int &AvgG,int &AvgB,	BYTE &Avgi,	short &Avgh,double &Avgs);
	bool *DilateFactor;
	int AvgThreshold(); //select the threshold by iteritive cycle
	void TestSeg(int cellsize);
	void AdaptiveSeg(int size,bool *flag);
	bool Mosaic(int x1, int x2, int y1, int y2, int label,int l);//mosaic for the face candidates
	void TestHueSeg();
	int round(double a);//get the integer
	bool IsOtherEye(int x1, int x2, int y1, int y2,int label,int l,int a1,int a2);
	double *num_lowthresh;
	double *HueSdOfFaceReg;
	short *HueThresh;
	void HueBinarize();
	int *area;//intensity segmentation results
	int *RegionL2;//intensity label.
	void FilterFeature();
	UINT nInfoRead2;// for saving image
	UINT nHeadRead1;
	LONG gOffset;
	BITMAPINFOHEADER tFileInfo;
	BITMAPFILEHEADER tFileHead;
	void SearchSkin(); // get the below 4 value.
	int SkinYmin;  //minimum row value that have skin region
	int SkinXmin;  //minimum column value
	int SkinYmax;  //maximum row value
	int SkinXmax;  //maximum column value
	int NumOfMouthReg;
	int FindInArray(int x,int y); //return the index that (x,y),if (x,y) is in some array.
	//CFile cf;
	int *MouthRegLabel;
	bool IsMouth(int x1, int x2, int y1, int y2,int label);//, FaceLocation *FcLocation
	void GetFace(int x1, int x2, int y1, int y2,FaceLocation &FcLocation);
	int *MouthRsum; //mouth region's area.
	int *MouthBelongReg; 
	int *bMouth; //the long axis of mouth region
	int *aMouth; //short axis
	int *MouthMinInty; //the minimum intensity of a mouth region
	int *MouthMinIntx;
	void GetFeatureMoments(int NumOfFeatureReg,int *FeatureRsum,int *FeatureRegLabel,int *BelongReg,int *aFeature,int *bFeature,double *Feature_theta,int *minIntx,int *minInty, int *meanInt);
	//int  *MouthRegLabel;//the label of the mouth candidate region
	bool *gMouth;//if a pixel is a mouth pixel
	void MouthRegionProcess(); //high_boost filtering for every region
	void RemoveSingle(bool *Flg,int size);//remove single background or foreground pixel
	void postprocess();//for the whole image,watch the results of high_boost filtering
	bool *FilterFlag;//
	short *GrayArray;//used for gray scale dilation and erosion
	int  *gBoost; //the gray level of every pixel after high boost filtering of the image
	void High_Boost();
	int  minangle;//maximium gradient angle
	int  fany[180];
	double sSum;
	void TestProjection();
	int  ptile(); // ratio=10%
	double Point2LineDis(int x0,int y0,int x1,int y1,int ax,int ay);
	double Distance(int x0,int y0,int x1,int y1);
	bool   faceCandCompute(int x1,int x2,int y1,int y2,int label,int thresh);
	int    NumOfValidSkinReg; //finally remained skin region.
	void RegBwDisplay();
	void bwdisplay();
	void EyeRegDescription(); //final result of this system
	void MeanFilter(); //average value filtering
	void ImageEnhance();
	int  *meanInt;
	double *sdOfFaceReg;
	double *SatSdOfFaceReg;
	void stdOfReg();//compute every regions standard deviation
	void EyeErosion(int size);
	void EyeDilation(int size);
	void segmentByHSI();
	int  *EyeRegLabel;
	int  *EyeRegPerFR;
	void EyeLabeling(); //store the final eye regions information
	void  EyeExtraction(); //extract the eye candidate pixels.
	int   binarizeForImage(char c);//show the whole image's binary result.
	short *Thresh;  //the whole image's binary threshhold.
	void  binarize(char c); // binarize for every region
	void  YCbCr(); //test one person's algorithm
	short *eyePixel;//note if a pixel is eye candidate pixel.
	short *gradient;
	int   LabelByPixel(int *RegionL,bool *gFlg); //labeling the region pixel by pixel.
	int   orig_label;
	void  RemoveByMoment(); //remove some regions that do not accord with moment's request.
	int   g_delregion; //the number that deleted by RemoveByMoment()
	void  RegionDescription(); //to save memory,descripted the regions by linklist.
	void  GetMoment(); //get the region's moment.
	double *theta; //the slope angle of region's ellipse.
	int    *b; //the short axis of ellipse of skin region
	int    *a; //the long axis of ellipse
	void   FigureEllipse();//figure out the ellipse that expressed by moment. 
	void   GetCentroid(); //get every region's centroid.
	void   display();
	int    NumOfWhiteReg; //record the number of white regions.
	BYTE   *WhiteRegL;   //record the label of every white region by using the same label.
	void   WhiteRegLabel();//labeling the white regions.
	int    *IntCentdy;//record the  region's Intensity centroid.
	int    *IntCentdx; //x is colomn coordinate,while y is row.
	int    *Rsum;      //record every skin region's area.
	int    *Centroidy; //record the binary region's  centroid.
	int    *Centroidx;
	void   MomentDescription(); //used to descript the region's fit ellipse.
	void   FillHole();  //fill the small holes.
	clock_t finish;  //record the finish time of the program.
	clock_t start;

	int   NumOfLabel;//record the number of skin regions.
	void  RegionLabeling(); //label the skin regions.
	short *RegionLabel; //the tag that labeled the same skin region.
						//every region is a face candidate region.
	void  SmallRegionDel();  //remove the small skin regions.
	static bool IsDebugSkinClassify;
	void FirstClassify( ); //the first time classfication.
	void erosion(int,bool *gFlg);
	void dilate(int,bool *gFlg);
	bool *gFlag;     //the global tag that note if the pixel is skin pixel.
	void IngSheen(); //the algorithm implemented by IngSheen.
	void skinclassify(); //some preprocessing operation.
	void visionSobel( );
	void sobel();

	virtual ~ImagePr();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

	// Generated message map functions
protected:
	//{{AFX_MSG(ImagePr)
		// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_IMAGEPR_H__C02CE795_2BF1_11D7_B637_000021B00837__INCLUDED_)

⌨️ 快捷键说明

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