Exemplo n.º 1
0
Arquivo: MyLib.cpp Projeto: jgmao/MTC
cv::Mat mylib::complexMul(const cv::Mat& A, const cv::Mat& B)
{
	if (A.channels() != B.channels())
		exit(1);
	else
	{
		cv::Mat AA,BB;
		//int ddd = A.channels();
		if (A.channels()!=2 && A.channels()!=6)
		{
			AA = toComplex(A);
			BB = toComplex(B);
		}
		else
		{
			AA = A;
			BB = B;
		}
		//int a = AA.type();
		//int b = A.type();
		//int c = BB.type();
		//int d = B.type();
		cv::Mat rst;
		cv::mulSpectrums(AA,BB,rst,DFT_ROWS,true);
		return rst;
	}
}
Exemplo n.º 2
0
Arquivo: MyLib.cpp Projeto: jgmao/MTC
cv::Mat mylib::toComplex(const cv::Mat& A)
{
	if (A.channels() == 2) //already complex
		return A;
	else
	{
		cv::Mat AZim = cv::Mat::zeros(A.rows,A.cols,A.type());
		return toComplex(A,AZim);
	}
}
Exemplo n.º 3
0
RVector DC1dModellingC::response(const RVector & model) {
    if (model.size() < (nlayers_ * 3 - 1)){
        throwError(1, WHERE_AM_I + " model vector to small: nlayers_ * 2 + 1 = " + toStr(nlayers_ * 3 - 1) + " > " + toStr(model.size()));
    }
    if (model.size() > (nlayers_ * 3 - 1)){
        throwError(1, WHERE_AM_I + " model vector to large: nlayers_ * 2 + 1 = " + toStr(nlayers_ * 3 - 1) + " < " + toStr(model.size()));
    }
    
    RVector thk(model(0,               nlayers_ -1));
    RVector rhoM(model(nlayers_ - 1,    2 * nlayers_ -1));
    RVector rhoP(- model(2 * nlayers_ -1, 3 * nlayers_ -1));
    
//     for (size_t i = 0 ; i < nlayers_ -1 ; i++) thk[i] = model[i];
//     for (size_t i = 0 ; i < nlayers_ ; i++) rhoM[i] = model[nlayers_ + i -1];
//     for (size_t i = 0 ; i < nlayers_ ; i++) rhoP[i] = - model[2 * nlayers_ + i -1];
    CVector rhoC = toComplex(RVector(rhoM * cos(rhoP)), RVector(rhoM * sin(rhoP)));
    
    CVector rhoaC = rhoaT< CVector >(rhoC, thk);
    RVector angPlus = abs(angle(rhoaC));
    
    return cat(abs(rhoaC), angPlus);
}
Exemplo n.º 4
0
// Implicit conversion to complex function.
numeric::operator complex() const { return toComplex(); }