Changeset 1984 for trunk/psLib/test/image/tst_psImageFFT.c
- Timestamp:
- Oct 6, 2004, 11:40:13 AM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/image/tst_psImageFFT.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/image/tst_psImageFFT.c
r1979 r1984 6 6 * @author Robert DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1. 9$ $Name: not supported by cvs2svn $9 * @date $Date: 2004-10-06 19:36:30$8 * @version $Revision: 1.10 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2004-10-06 21:40:13 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 88 88 return 1; 89 89 } 90 if (img2->numCols != m || img2->numRows != n) { 91 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 92 img2->numCols,img2->numRows,m,n); 93 return 2; 94 } 90 95 91 96 // 3. verify that the only significant component cooresponds to the freqency of the input in step 1. … … 99 104 && ! (row == 0 && (col==1 || col == n-1)) ) { 100 105 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 106 return 3; 101 107 } 102 108 } else … … 104 110 || (row == 0 && (col==1 || col == n-1)) ) { 105 111 psError(__func__,"Result invalid at %d,%d (%.2f)",col,row,mag); 112 return 4; 106 113 } 107 114 } … … 114 121 if (img3->type.type != PS_TYPE_C32) { 115 122 psError(__func__,"FFT didn't produce complex values?"); 116 return 4; 123 return 5; 124 } 125 126 if (img3->numCols != m || img3->numRows != n) { 127 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 128 img3->numCols,img3->numRows,m,n); 129 return 6; 117 130 } 118 131 … … 125 138 psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 126 139 col,row,pixel,imgRow[col]); 127 return 5; 128 } 129 } 140 return 7; 141 } 142 } 143 } 144 145 // 4. perform a reverse transform to real result 146 img3 = psImageFFT(img3,img2,PS_FFT_REVERSE|PS_FFT_REAL_RESULT); 147 148 if (img3->type.type != PS_TYPE_F32) { 149 char* typeStr; 150 PS_TYPE_NAME(typeStr,img3->type.type) 151 psError(__func__,"FFT asked to make real result, but I got a %s type image?",typeStr); 152 return 8; 153 } 154 155 if (img3->numCols != m || img3->numRows != n) { 156 psError(__func__,"FFT didn't produce proper size result (%dx%d vs. expected %dx%d).", 157 img3->numCols,img3->numRows,m,n); 158 return 9; 159 } 160 161 for (unsigned int row=0;row<n;row++) { 162 psF32* img3Row = img3->data.F32[row]; 163 psF32* imgRow = img->data.F32[row]; 164 for (unsigned int col=0;col<m;col++) { 165 psF32 pixel = img3Row[col]/m/n; 166 if (fabsf(pixel-imgRow[col]) > 0.1) { 167 psError(__func__,"Reverse FFT didn't give original image back (%d,%d %.2f vs %.2f)", 168 col,row,pixel,imgRow[col]); 169 return 10; 170 } 171 } 172 } 173 174 // check if error occurs if FORWARD and REVERSE are both given. 175 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 176 if (psImageFFT(NULL,img2,PS_FFT_REVERSE|PS_FFT_FORWARD) != NULL) { 177 psError(__func__,"PS_FFT_REVERSE|PS_FFT_FORWARD option produced something?"); 178 return 11; 179 } 180 181 psLogMsg(__func__,PS_LOG_INFO,"Following should be an error."); 182 if (psImageFFT(NULL,img2,PS_FFT_FORWARD|PS_FFT_REAL_RESULT) != NULL) { 183 psError(__func__,"PS_FFT_FORWARD|PS_FFT_REAL_RESULT option produced something?"); 184 return 12; 130 185 } 131 186
Note:
See TracChangeset
for help on using the changeset viewer.
