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

📄 setthr.cpp

📁 VC写的harris角点检测程序。又名plessey
💻 CPP
字号:
// SetThr.cpp : implementation file
//

#include "stdafx.h"
#include "ImageCodes.h"
#include "SetThr.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

extern unsigned int **GrayValue;//存放灰度值,8位
extern unsigned int r0,c0; //r0,c0代表总行数和总列数
/////////////////////////////////////////////////////////////////////////////
// CSetThr dialog


CSetThr::CSetThr(CWnd* pParent /*=NULL*/)
	: CDialog(CSetThr::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetThr)
	m_thr = 128;
	//}}AFX_DATA_INIT
}


void CSetThr::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetThr)
	DDX_Text(pDX, IDC_SETTHR_EDIT, m_thr);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetThr, CDialog)
	//{{AFX_MSG_MAP(CSetThr)
	ON_WM_PAINT()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetThr message handlers

void CSetThr::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
	// TODO: Add your message handler code here
	RECT rect;
	GetDlgItem(IDC_ZHIFANGTU)->GetWindowRect(&rect);
	ScreenToClient(&rect);
	dc.MoveTo(rect.left+10,rect.top+10);
	dc.LineTo(rect.left+10,rect.bottom-10);
	dc.LineTo(rect.right-10,rect.bottom-10);
	dc.MoveTo(rect.left+10,rect.top+10);
	dc.LineTo(rect.left+5,rect.top+15);
	dc.MoveTo(rect.left+10,rect.top+10);
	dc.LineTo(rect.left+15,rect.top+15);
	dc.MoveTo(rect.right-10,rect.bottom-10);
	dc.LineTo(rect.right-15,rect.bottom-15);
	dc.MoveTo(rect.right-10,rect.bottom-10);
	dc.LineTo(rect.right-15,rect.bottom-5);//画好了坐标系

unsigned int i,j,n[256],N;
 double p[256];



 for(i=0;i<256;i++)
  n[i]=0;

 for(i=1;i<r0-1;i++)
  for(j=1;j<c0-1;j++)
      n[GrayValue[i][j]]++;
 //统计n[i]
 for(i=0;i<256;i++)
  N=N+n[i];
 //统计N
 for(i=0;i<256;i++)
	p[i]=(double)(n[i])/(double)(N);//得到直方图


 for(i=0;i<256;i++)
	n[i]=(int)(p[i]*20000000000);//放大直方图,以便能够显示

  for(i=0;i<256;i++)
  {
	  if(i%10==0&&i%50!=0)//10个像素画一个小格
		  dc.MoveTo(rect.left+10+i,rect.bottom-7);
	  else if(i%50==0)//50个像素画个大格
		  dc.MoveTo(rect.left+10+i,rect.bottom-2);
	  else//否则不多画格
		  dc.MoveTo(rect.left+10+i,rect.bottom-10);

	  dc.LineTo(rect.left+10+i,rect.bottom-10-n[i]);
  }

	// Do not call CDialog::OnPaint() for painting messages
}

⌨️ 快捷键说明

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