「phase.cpp」の編集履歴(バックアップ)一覧はこちら

phase.cpp」(2008/09/24 (水) 00:27:58) の最新版変更点

追加された行は緑色になります。

削除された行は赤色になります。

//cpp #include "phase.h" #define _USE_MATH_DEFINES #include "math.h" /** * get the phase of the signal and normalize it to 0-1 range * if we can't get the phase i.e. power=0, set -1 * @param in input data ( frequency domain ) * @param out 0-1 normalized phase ( frequency domain ) * @param rows ( width ) * @param cols ( height ) * @return true if succeed */ int maGetPhase2D( fftw_complex *data, double *out, int rows, int cols ) { int i,j; int idx; if( data==NULL || out==NULL ) return false; if( rows<0 || cols<0 ) return false; for( j=0; j<cols; j++ ){ for( i=0; i<rows; i++ ){ idx = j*rows + i; if( data[idx][0]!=0 || data[idx][1]!=0 ){ // function atan2 returns [-M_PI, M_PI], so normalize it to 0-1 out[idx] = 0.5 + 0.5*atan2( data[idx][1], data[idx][1] )/M_PI; }else{ // if we can't decide phase, return -1 out[idx] = -1; } } } return true; }
//cpp /** * Phase calculation * @author maeda * @date 2008/09/01 */ #include "phase.h" #define _USE_MATH_DEFINES #include "math.h" /** * get the phase of the signal and normalize it to 0-1 range * if we can't get the phase i.e. power=0, set -1 * @param in input data ( frequency domain ) * @param out 0-1 normalized phase ( frequency domain ) * @param rows ( width ) * @param cols ( height ) * @return true if succeed */ int maGetPhase2D( fftw_complex *data, double *out, int rows, int cols ) { int i,j; int idx; if( data==NULL || out==NULL ) return false; if( rows<0 || cols<0 ) return false; for( j=0; j<cols; j++ ){ for( i=0; i<rows; i++ ){ idx = j*rows + i; if( data[idx][0]!=0 || data[idx][1]!=0 ){ // function atan2 returns [-M_PI, M_PI], so normalize it to 0-1 out[idx] = 0.5 + 0.5*atan2( data[idx][1], data[idx][1] )/M_PI; }else{ // if we can't decide phase, return -1 out[idx] = -1; } } } return true; }

表示オプション

横に並べて表示:
変化行の前後のみ表示: