ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
205
205
EMPFEHLEN
-
Hi Leute,
ich bin schon des laengeren am tueffteln mit fftw, bekomme es aber einfach nicht auf die Reihe.
Moechte einfach die 2D fft ausfuehren. Finde einfach keinen Fehler in meinem Algorithmus. Deshalb mal eine Frage an die Experten. Koennt ihr mal bitte meinen Code ueberfliegen? Meine Bilder von der fft sind nur verrauscht wie ein Fernseher der kein Signal hat. Es sind aber allerdings senkrechte, dunkelgraue Streifen in regelmaessigen Abstaenden angeordnet, falls das hilft.
Hier der Code:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
BYTE* CTransform::FFTForward(BYTE *dataIn) { fftw_complex* in=0; fftw_complex* out=0; int N=width*height; in =(fftw_complex*)fftw_malloc(N*sizeof(fftw_complex)); out =(fftw_complex*)fftw_malloc(N*sizeof(fftw_complex)); int count =0; int index =0; int offset =0; for (int j=0;j<512;j++) // fill fftw_complex input data for fft { offset=j*width; for(int i=0;i<512;i++) { index=offset+i; in[index][0]=(dataIn[count++]; //real in[index][1]=0.0; //imag } } fftw_plan plan=fftw_plan_dft_2d(512,512,in,out,FFTW_FORWARD,FFTW_ESTIMATE); fftw_execute(plan); fftw_destroy_plan(plan); double* temp; temp=new double[DATALENGTH]; double tempi; count = 0; for(int j=0;j<512;j++) { offset=j*width; for(int i=0; i<512; i++) { index=offset+i; tempi=sqrt((out[index][0]*out[index][0])+(out[index][1]*out[index][1])); if(tempi!=(double)0.0) temp[count++]=log(tempi); else temp[count++]=0.0; } } BYTE* dataOut; dataOut=new BYTE[DATALENGTH]; dataOut=Normalize(temp); return dataOut; } BYTE* CTransform::Normalize(double* data) { double max, min; min=max=data[0]; // find min, max amplitude for(int i=0;i<262143;i++) { if(data[i]>max) max=data[i]; if(data[i]<min) min=data[i]; } // normalize in range 0-255 for(int i=0;i<262143;i++) { data[i]=(255.0*(data[i]-min))/(max-min); } return (BYTE*)data; }
Meine Bilderstellungsroutine stimmt auf jeden Fall. Zur Sicherheit hier aber auch nochmal der Code:
Code :1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
bool CGetPrepareDataFiles::CreateBitmap(CString path,BYTE* data) { BITMAPINFO bi; HANDLE fileHandle; BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; DWORD bytes_write; DWORD bytes_written; ZeroMemory(&bmih,sizeof(BITMAPINFOHEADER)); bmih.biSize=sizeof(BITMAPINFOHEADER); bmih.biHeight=COLS; bmih.biWidth=ROWS; bmih.biPlanes=1; bmih.biBitCount=24; bmih.biCompression=BI_RGB; bmih.biSizeImage=((((bmih.biWidth*bmih.biBitCount)+31)& ~31) >> 3)*bmih.biHeight; bmih.biXPelsPerMeter=0; bmih.biYPelsPerMeter=0; bmih.biClrImportant=0; bi.bmiHeader=bmih; ZeroMemory(&bmfh,sizeof(BITMAPFILEHEADER)); bmfh.bfOffBits=sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); bmfh.bfSize=(3*bmih.biHeight*bmih.biWidth)+sizeof( BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER); bmfh.bfType=0x4d42; bmfh.bfReserved1 = 0; bmfh.bfReserved2 = 0; fileHandle=CreateFile(path,GENERIC_READ | GENERIC_WRITE,(DWORD)0,NULL, CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,(HANDLE) NULL); if (fileHandle==INVALID_HANDLE_VALUE) return false; // Write the BITMAPFILEHEADER bytes_write=sizeof(BITMAPFILEHEADER); if (!WriteFile(fileHandle,(void*)&bmfh,bytes_write,&bytes_written,NULL)) return false; //Write the BITMAPINFOHEADER bytes_write=sizeof(BITMAPINFOHEADER); if (!WriteFile(fileHandle,(void*)&bmih,bytes_write,&bytes_written,NULL)) return false; BYTE* dataRGB; dataRGB=new BYTE[ROWS*COLS*3]; int j=0; for(int i=0;i<DATALENGTH;i++) { dataRGB[j++]=data[i]; dataRGB[j++]=data[i]; dataRGB[j++]=data[i]; } //Write the Color Index Array bytes_write=bmih.biSizeImage;//3*bmih.biHeight*bmih.biWidth; if (!WriteFile(fileHandle,(void*)dataRGB,bytes_write,&bytes_written,NULL)) return false; delete[] dataRGB; CloseHandle(fileHandle); return true; }
Vielen Dank schon mal vorab.
Gruss Rainer
Ähnliche Themen
-
2DFFT mit fftw oder Alternativen
Von rainer82 im Forum VisualStudio & MFCAntworten: 3Letzter Beitrag: 30.09.09, 10:30 -
Ergebnis doppelt SQL
Von hury im Forum Relationale DatenbanksystemeAntworten: 1Letzter Beitrag: 03.01.09, 14:18 -
DB Ergebnis in textarea...
Von markberg im Forum PHPAntworten: 3Letzter Beitrag: 24.03.06, 15:05 -
Wie kriege ich so ein Ergebnis?
Von TeeBeeCux im Forum PhotoshopAntworten: 5Letzter Beitrag: 17.06.05, 11:41 -
kein ergebnis?
Von uwee im Forum PHPAntworten: 10Letzter Beitrag: 18.11.04, 15:48





Zitieren
Login






