www.pudn.com > ImgFFT.zip > Pro2Doc.cpp
// Pro2Doc.cpp : implementation of the CPro2Doc class
//
#include "stdafx.h"
#include "Pro2.h"
#include "Pro2Doc.h"
#include "CDib.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPro2Doc
IMPLEMENT_DYNCREATE(CPro2Doc, CDocument)
BEGIN_MESSAGE_MAP(CPro2Doc, CDocument)
//{{AFX_MSG_MAP(CPro2Doc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPro2Doc construction/destruction
CPro2Doc::CPro2Doc()
{
// TODO: add one-time construction code here
}
CPro2Doc::~CPro2Doc()
{
}
BOOL CPro2Doc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
// TODO: add reinitialization code here
// (SDI documents will reuse this document)
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
// CPro2Doc serialization
void CPro2Doc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
// TODO: add storing code here
}
else
{
// TODO: add loading code here
}
}
/////////////////////////////////////////////////////////////////////////////
// CPro2Doc diagnostics
#ifdef _DEBUG
void CPro2Doc::AssertValid() const
{
CDocument::AssertValid();
}
void CPro2Doc::Dump(CDumpContext& dc) const
{
CDocument::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CPro2Doc commands
void CPro2Doc::FFT_1D(complex* pCTData,complex* pCFData,int nLevel)
{
int i;
int j;
int k;
double PI=3.1415926;
int nCount=0;
nCount=(int)pow(2,nLevel);
int nBtFlyLen;
nBtFlyLen=0;
double dAngle;
complex* pCW;
pCW=new complex[nCount/2];
for(i=0;i(cos(dAngle),sin(dAngle));
}
complex* pCWork1,*pCWork2;
pCWork1=new complex[nCount];
pCWork2=new complex[nCount];
complex* pCTmp;
memcpy(pCWork1,pCTData,sizeof(complex)*nCount);
int nInter;
nInter=0;
for(k=0;k* pCTData,int nWidth,int nHeight,complex* pCFData)
{
int x,y;
double dTmpOne;
double dTmpTwo;
int nTransWidth;
int nTransHeight;
dTmpOne=log(nWidth)/log(2);
dTmpTwo=ceil(dTmpOne);
dTmpTwo=pow(2,dTmpTwo);
nTransWidth=(int)dTmpTwo;
dTmpOne=log(nHeight)/log(2);
dTmpTwo=ceil(dTmpOne);
dTmpTwo=pow(2,dTmpTwo);
nTransHeight=(int)dTmpTwo;
int nXLev;
int nYLev;
nXLev=(int)(log(nTransWidth)/log(2)+0.5);
nYLev=(int)(log(nTransHeight)/log(2)+0.5);
for(y=0;y)*nTransHeight*nTransWidth);
}
void CPro2Doc::IFFT_1D(complex* pCFTData,complex* pCTData,int nLevel)
{
int i;
int nCount;
nCount=(int)pow(2,nLevel);
complex* pCWork;
pCWork=new complex[nCount];
memcpy(pCWork,pCFTData,sizeof(complex)* nCount);
for(i=0;i(pCWork[i].real(),-pCWork[i].imag());
}
FFT_1D(pCWork,pCTData,nLevel);
for(i=0;i(pCTData[i].real()/nCount,-pCTData[i].imag()/nCount);
}
delete pCWork;
pCWork=NULL;
}
void CPro2Doc::IFFT_2D(complex* pCFData,int nWidth,int nHeight,complex* pCTData)
{
int x,y;
double dTmpOne;
double dTmpTwo;
int nTransWidth;
int nTransHeight;
dTmpOne=log(nWidth)/log(2);
dTmpTwo=ceil(dTmpOne);
dTmpTwo=pow(2,dTmpTwo);
nTransWidth=(int)dTmpTwo;
dTmpOne=log(nHeight)/log(2);
dTmpTwo=ceil(dTmpOne);
dTmpTwo=pow(2,dTmpTwo);
nTransHeight=(int)dTmpTwo;
complex* pCWork=new complex[nTransWidth*nTransHeight];
complex* pCTmp;
for(y=0;y(pCTmp->real(),-pCTmp->imag());
}
}
FFT_2D(pCWork,nWidth,nHeight,pCTData);
for(y=0;y(pCTmp->real()/(nTransWidth*nTransHeight),-pCTmp->imag()/(nTransWidth*nTransHeight));
}
}
delete pCWork;
pCWork=NULL;
}