Changeset 1983 for trunk/psLib/src/image/psImageFFT.c
- Timestamp:
- Oct 6, 2004, 11:31:30 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageFFT.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageFFT.c
r1864 r1983 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 3$ $Name: not supported by cvs2svn $8 * @date $Date: 2004- 09-23 18:31:49$7 * @version $Revision: 1.4 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-10-06 21:31:30 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 21 21 #include "psLogMsg.h" 22 22 #include "psImageExtraction.h" 23 #include "psImageIO.h" 23 24 24 25 #include "psImageErrors.h" … … 41 42 } 42 43 44 if ( ((direction & PS_FFT_FORWARD) != 0) ) { 45 if ((direction & PS_FFT_REVERSE) != 0) { 46 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 47 PS_ERR_BAD_PARAMETER_VALUE, true, 48 PS_ERRORTEXT_psImageFFT_FORWARD_REVERSE); 49 psFree(out); 50 return NULL; 51 } 52 if ((direction & PS_FFT_REAL_RESULT) != 0) { 53 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 54 PS_ERR_BAD_PARAMETER_VALUE, true, 55 PS_ERRORTEXT_psImageFFT_REAL_FORWARD_NOTSUPPORTED); 56 psFree(out); 57 return NULL; 58 } 59 } else if ((direction & PS_FFT_REVERSE) == 0) { 60 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 61 PS_ERR_BAD_PARAMETER_VALUE, true, 62 PS_ERRORTEXT_psImageFFT_NO_DIRECTION_OPTION); 63 psFree(out); 64 return NULL; 65 } 66 43 67 type = in->type.type; 44 45 if ((type != PS_TYPE_F32) && (type != PS_TYPE_C32)) {46 char* typeStr;47 PS_TYPE_NAME(typeStr,type);48 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",49 PS_ERR_BAD_PARAMETER_TYPE, true,50 PS_ERRORTEXT_psImageFFT_IMAGE_TYPE_UNSUPPORTED,51 typeStr);52 psFree(out);53 return NULL;54 }55 56 if (type != PS_TYPE_C32 && direction == PS_FFT_REVERSE) {57 char* typeStr;58 PS_TYPE_NAME(typeStr,type);59 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",60 PS_ERR_BAD_PARAMETER_TYPE, true,61 PS_ERRORTEXT_psImageFFT_REVERSE_NOT_COMPLEX,62 typeStr);63 psFree(out);64 return NULL;65 66 }67 68 if (type != PS_TYPE_F32 && direction == PS_FFT_FORWARD) {69 char* typeStr;70 PS_TYPE_NAME(typeStr,type);71 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT",72 PS_ERR_BAD_PARAMETER_TYPE, true,73 PS_ERRORTEXT_psImageFFT_FORWARD_NOT_REAL,74 typeStr);75 psFree(out);76 return NULL;77 }78 68 79 69 /* make sure the system-level wisdom information is imported. */ … … 86 76 numCols = in->numCols; 87 77 88 // n.b. FFTW can perform a in-place transform at the same or faster than out-of-place. 78 // n.b. FFTW can perform a in-place transform at the same rate or faster than out-of-place. 79 int sign = ((direction & PS_FFT_FORWARD) != 0) ? FFTW_FORWARD : FFTW_BACKWARD; 89 80 out = psImageCopy(out, in, PS_TYPE_C32); 90 81 plan = fftwf_plan_dft_2d(numCols, numRows, 91 (fftwf_complex *) out->data.C32[0], 92 (fftwf_complex *) out->data.C32[0], direction, PS_FFTW_PLAN_RIGOR); 93 94 /* check if a plan exists now -- if not, it is a real problem */ 82 out->data.C32[0], 83 out->data.C32[0], 84 sign, 85 PS_FFTW_PLAN_RIGOR); 86 87 /* check if a plan exists now -- if not, it is a real problem at this point */ 95 88 if (plan == NULL) { 96 89 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", … … 105 98 106 99 fftwf_destroy_plan(plan); 100 101 if (direction & PS_FFT_REAL_RESULT) { 102 // n.b., we do this instead of using fftwf_plan_dft_c2r because that 103 // plan requires a half-image, which would require a image reordering 104 // that is not as simple as performing a normal complex transform and 105 // then taking the real part of the result. If performance here 106 // becomes an issue, the use of fftwf_plan_dft_r2c should be considered 107 // as well as fftwf_plan_dft_c2r. 108 psImage* realOut = psImageCopy(NULL,out,PS_TYPE_F32); 109 psFree(out); 110 out = realOut; 111 } 107 112 108 113 return out; … … 424 429 real = creal(inRow[col]); 425 430 imag = cimag(inRow[col]); 426 outRow[col] = real * real + imag * imag/ numElementsSquared;431 outRow[col] = (real * real + imag * imag) / numElementsSquared; 427 432 } 428 433 }
Note:
See TracChangeset
for help on using the changeset viewer.
