在复数坐标系下,相角减半,幅值不变;画图如下:
由倍角公式:
令:
则
所以
代码实现:
//将相角*0.5,幅值保持不变
void half_angel(Mat &complex_r, Mat &complex_i, Mat &dst)
{
Mat temp[] = {Mat::zeros(complex_r.size(),CV_32FC1), Mat::zeros(complex_r.size(),CV_32FC1)};
float realv=0.0,imaginv=0.0;
for(int i=0;i<complex_r.cols;i++){
for( int j = 0; j < complex_r.rows; j++ ){
realv = complex_r.at<float>(i,j);
imaginv = complex_i.at<float>(i,j);
float distance=sqrt(realv*realv+imaginv*imaginv);
temp[0].at<float>(i,j) =distance*sqrt((distance+realv)/(2*distance));
temp[1].at<float>(i,j) =distance*sqrt((distance-realv)/(2*distance));
}
}
merge(temp, 2, dst);
}
效果如下: