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

📄 rightview.cpp

📁 基于摄影测量学中FORNSTER算子
💻 CPP
字号:
// RightView.cpp : implementation file
//

#include "stdafx.h"
#include "Match.h"
#include "RightView.h"
#include "MatchDoc.h"
#include "MainFrm.h"
#include "MatchView.h"
#include "math.h"

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

/////////////////////////////////////////////////////////////////////////////
// CRightView

IMPLEMENT_DYNCREATE(CRightView, CView)

CRightView::CRightView()
{


	
}

CRightView::~CRightView()
{
}


BEGIN_MESSAGE_MAP(CRightView, CView)
	//{{AFX_MSG_MAP(CRightView)
	ON_WM_LBUTTONDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRightView drawing

void CRightView::OnDraw(CDC* pDC)
{
	CMatchDoc* pDoc = (CMatchDoc *)GetDocument();
	if (pDoc->m_hDIB2 != NULL)
	{
		Draw(pDC, pDoc->m_hDIB2);
	}
	// TODO: add draw code here
}

/////////////////////////////////////////////////////////////////////////////
// CRightView diagnostics

#ifdef _DEBUG
void CRightView::AssertValid() const
{
	CView::AssertValid();
}

void CRightView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRightView message handlers

void CRightView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default

	
	CView::OnLButtonDown(nFlags, point);
}

double CRightView::CalXiShu(int c, int r)
{

	CMatchDoc* pDoc = (CMatchDoc *)GetDocument();
	unsigned   char *lpBits1 = pDoc->m_pBits1 + pDoc->m_nEffectWidth1 * m_nStartY + m_nStartX;
	unsigned   char *lpBits2 = pDoc->m_pBits2 + pDoc->m_nEffectWidth2 * r + c;

	double  S1 = 0 , S2 = 0 , S3 = 0 , S4 =0 , S5 = 0;
	for ( int i = 1 ; i < M ; i++)
	{
		for ( int j = 1 ; j < N ; j++)
		{
			double  temp1 = *(lpBits1 + M * j + i);
			double  temp2 = *(lpBits2 + M * j + i);
			double  a     =  temp1 * temp2;
			double  b     =  temp1 * temp1;
			double  c     =  temp2 * temp2;
			S1 += a;

			S2 += b;

			S3 += c;

			S4 += temp1;

			S5 += temp2;
		}
	}
	S1 /= 10000;
	S2 /= 10000;
	S3 /= 10000;
	S4 /= 10000;
	S5 /= 10000;

	double  a1    = (S4 * S4) / (M * N);
	double  a2    = (S5 * S5) / (M * N);
	double  a3    = (S2 - a1) * (S3 - a2);
	double  te    = sqrt(a3);
	double  a4    = S1 - (S4 * S5) / (M * N);
	double  temp  = a4 / te;
	return  temp;

}

void CRightView::Start(int &c, int &r, double &result)
{
	CMatchDoc* pDoc = (CMatchDoc *)GetDocument();
	CMainFrame *pFrm  =  (CMainFrame *)AfxGetApp()->GetMainWnd();
	CMatchView *pView =  (CMatchView *)(pFrm->m_wndSplitter).GetPane(0, 0);
	M                 =  pView->cx;
	N                 =  pView->cy;
	m_nStartX         =  pView->m_point.x;
	m_nStartY         =  pDoc->m_nHeight1 - pView->m_point.y;

   result          =  CalXiShu(0, 0);
   
   for ( int j = 0 ; j < pDoc->m_nHeight2 - N ; j++ )
   {
	   for ( int i = 0 ; i < pDoc->m_nWidth2 - M ; i++)
	   {
		  double  temp = CalXiShu(i,j);
		  if ( temp > result)
		  {
			  result = temp;
			  c      = i;
			  r      = pDoc->m_nHeight2 - j;
		  }
	   }
   }

}

void CRightView::DrawCross(int x, int y)
{
	CMatchDoc* pDoc = (CMatchDoc *)GetDocument();
    CDC      *pDC   = GetDC();
	CPen* pPenRed = new CPen;
	pPenRed->CreatePen(PS_SOLID,1,RGB(255,0,0));
 	CPen  *oldpen = pDC->SelectObject(pPenRed);
    pDC->MoveTo(x, pDoc->m_nHeight2 - y);
	pDC->LineTo(x + M ,pDoc->m_nHeight2 - y);
	pDC->LineTo(x + M ,pDoc->m_nHeight2 - y - N );
	pDC->LineTo(x, pDoc->m_nHeight2 - y - N);
	pDC->LineTo(x, pDoc->m_nHeight2 - y);
    pDC->SelectObject(oldpen);
    delete  pPenRed;
//	ReleaseDC(pDC);

}

⌨️ 快捷键说明

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