本文整理汇总了C++中ComplexNumber::div方法的典型用法代码示例。如果您正苦于以下问题:C++ ComplexNumber::div方法的具体用法?C++ ComplexNumber::div怎么用?C++ ComplexNumber::div使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComplexNumber
的用法示例。
在下文中一共展示了ComplexNumber::div方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: extractFourierDescriptors
void ExtractDescriptorHelper::extractFourierDescriptors(CvSeq* contour)
{
int x=contour->total;
CvPoint *pt=new CvPoint[contour->total];
for(int i=0; i<contour->total; i++)
{
pt[i] = *(CvPoint*)cvGetSeqElem(contour, i);
//cout<<"x:"<< pt[i].x<<" y:"<<pt[i].y<<endl;
}
//cout<<"Koordinatlar yazildi"<<endl;
vector<ComplexNumber> contoursComplex; //Complex Number vectoru olusturduk
int r1, i1;
for(int j=0; j<contour->total; j++) // contour kordinatlarýný vectorde karmaþýk olarak tuttuk 1+2j gibi
{
ComplexNumber temp(pt[j].x, pt[j].y);
//temp.print();
contoursComplex.push_back(temp);
// copy constructor ve assignment operator implemente et çünkü push_back bunlarý kullanýyor. Ve destructor.
}
//contoursComplex ile chainCode u hesapla...
//<Shifting the contour coordinates to center>
ComplexNumber shiftC;
ComplexNumber total(0,0);
for(int x=0; x<contour->total; x++)
{
total=total.add(contoursComplex[x]);
}
ComplexNumber divisor(contour->total, 0);
shiftC=total.div(divisor);
vector<ComplexNumber> T;
for(int x=0; x<contour->total; x++)
{
ComplexNumber tmp;
tmp=contoursComplex[x].sub(shiftC);
T.push_back(tmp);
//T.at(x)=tmp;
}
//</Shifting the contour coordinates to center>
//BURAYA KADAR TRANSITION OLAYI HALLOLDU, BÜTÜN NOKTALAR SANAL BÝR ORJÝNE GÖRE ALINDI.
sortComplexVector(T);// açýlara gore sýralamayý yapýyor. Ufak tefek sapmalar var, elle yazmak yerine quicksort falan yap.
//FFT KISMINI BURADA YAPIYORUM, MATEMATIKSEL ISLEMLERE GORE. DFT nin MATEMATIKSEL TANIMINA BAKILARAK BURADAKI ISLEM ANLASILABILIR
ComplexNumber tempSum;
vector<ComplexNumber> fourierDesc;
ComplexNumber div(T.size(), 0);
for(int u=0; u<T.size(); u++)
{
tempSum.setReal(0);
tempSum.setImag(0);
for(int k=0; k<T.size(); k++)
{
ComplexNumber tempComplex(cos((2*360*u*k*PI)/(180*T.size())), (-1)*(sin((2*360*u*k*PI)/(T.size()*180))));
tempSum=tempSum.add((T.at(k)).mult(tempComplex));
}
fourierDesc.push_back((tempSum.div(div)));
}
//FFT KISMI BURADA BITIYOR
// NORMALIZATION KISMI YAPILIYOR BURADA, SCALE ,TRANSITION VE ROTATION INVARIANT OLUYOR BOYLECE
vector<ComplexNumber> tmpFourierDesc;
for(int i=0; i<fourierDesc.size(); i++)
tmpFourierDesc.push_back(fourierDesc.at(i));
ComplexNumber zero(0,0);
//Translation Invariance:
tmpFourierDesc.at(0)=zero;
//si=abs(T(1)) sayisini tutuyorum
//Scale Invariance:
ComplexNumber myVarSiDiv(sqrt(pow(tmpFourierDesc.at(1).getReal(),2) + pow(tmpFourierDesc.at(1).getImag(),2)), 0);
//T(i)=T(i)/si iþlemi yapýlýyor.
for(int m=0; m<tmpFourierDesc.size(); m++)
tmpFourierDesc.at(m).div(myVarSiDiv);
//Son olarak tum elemanlarý double vectorunde tutuyorum. Boylece fourier desc lar cýktý.
//vector<double> finalFourierDesc;
//Burada da T=abs(T) yi fourier descriptor olarak tuttum, böylece ROTATION AND CHANGES IN STARTING POINT oldu.
//myFourierDescriptors vectoru, class içinde tuttuðum en sonki fourier descriptorlarý içeren vectordur.
for(int n=0; n<tmpFourierDesc.size(); n++)
{
myFourierDescriptors.push_back(sqrt(pow(tmpFourierDesc.at(n).getReal(),2) + pow(tmpFourierDesc.at(n).getImag(),2)));
//cout<<n<<". element: "<<myFourierDescriptors.at(n)<<endl;
}
/*
//.........这里部分代码省略.........