Changeset 1840 for trunk/psLib/src/image/psImageFFT.c
- Timestamp:
- Sep 21, 2004, 12:30:19 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/image/psImageFFT.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/image/psImageFFT.c
r1625 r1840 5 5 * @author Robert DeSonia, MHPCC 6 6 * 7 * @version $Revision: 1. 1$ $Name: not supported by cvs2svn $8 * @date $Date: 2004-0 8-25 21:10:09 $7 * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $ 8 * @date $Date: 2004-09-21 22:30:19 $ 9 9 * 10 10 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 22 22 #include "psImageExtraction.h" 23 23 24 #include "psImageErrors.h" 25 24 26 #define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE 25 27 … … 42 44 43 45 if ((type != PS_TYPE_F32) && (type != PS_TYPE_C32)) { 44 psError(__func__, "Input image must be a 32-bit float or complex image (type=%d)", type); 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); 45 52 psFree(out); 46 53 return NULL; … … 48 55 49 56 if (type != PS_TYPE_C32 && direction == PS_FFT_REVERSE) { 50 psError(__func__, "Input image must be complex image for reverse FFT (type=%d).", type); 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); 51 63 psFree(out); 52 64 return NULL; … … 55 67 56 68 if (type != PS_TYPE_F32 && direction == PS_FFT_FORWARD) { 57 psError(__func__, "Input image must be real image for forward FFT (type=%d).", type); 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); 58 75 psFree(out); 59 76 return NULL; … … 69 86 numCols = in->numCols; 70 87 88 // n.b. FFTW can perform a in-place transform at the same or faster than out-of-place. 71 89 out = psImageCopy(out, in, PS_TYPE_C32); 72 73 90 plan = fftwf_plan_dft_2d(numCols, numRows, 74 91 (fftwf_complex *) out->data.C32[0], 75 92 (fftwf_complex *) out->data.C32[0], direction, P_FFTW_PLAN_RIGOR); 76 93 77 /* check if a plan exists now */94 /* check if a plan exists now -- if not, it is a real problem */ 78 95 if (plan == NULL) { 79 psError(__func__, "Failed to create FFTW plan."); 96 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageFFT", 97 PS_ERR_BAD_PARAMETER_TYPE, true, 98 PS_ERRORTEXT_psImageFFT_FFTW_PLAN_NULL); 80 99 psFree(out); 81 100 return NULL; … … 106 125 numRows = in->numRows; 107 126 108 /* if not a complex number, this is logically just a copy */ 109 if (!PS_IS_PSELEMTYPE_COMPLEX(type)) { 110 // Warn user, as this is probably not expected 111 psLogMsg(__func__, PS_LOG_WARN, "Real portion of a non-Complex type called called for. " 112 "Just an image copy was performed."); 127 /* if not a complex number, this is logically just a copy then */ 128 if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) { 113 129 return psImageCopy(out, in, type); 114 130 } … … 141 157 } 142 158 } else { 143 psError(__func__, "Can not extract real component from given image type (%d).", type); 159 char* typeStr; 160 PS_TYPE_NAME(typeStr,type); 161 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageReal", 162 PS_ERR_BAD_PARAMETER_TYPE, true, 163 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 164 typeStr); 165 144 166 psFree(out); 145 167 return NULL; … … 164 186 numRows = in->numRows; 165 187 166 /* if not a complex number, this is logically just zeroed image of same size */ 167 if (!PS_IS_PSELEMTYPE_COMPLEX(type)) { 168 // Warn user, as this is probably not expected 169 psLogMsg(__func__, PS_LOG_WARN, "Imaginary portion of a non-Complex type called for. " 170 "A zero image was returned."); 188 /* if not a complex image type, this is logically just zeroed image of same size */ 189 if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) { 171 190 out = psImageRecycle(out, numCols, numRows, type); 172 191 memset(out->data.V[0], 0, PSELEMTYPE_SIZEOF(type) * numCols * numRows); … … 201 220 } 202 221 } else { 203 psError(__func__, "Can not extract imaginary component from given image type (%d).", type); 222 char* typeStr; 223 PS_TYPE_NAME(typeStr,type); 224 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageImaginary", 225 PS_ERR_BAD_PARAMETER_TYPE, true, 226 PS_ERRORTEXT_psImage_IMAGE_TYPE_UNSUPPORTED, 227 typeStr); 204 228 psFree(out); 205 229 return NULL; … … 225 249 226 250 if (imag->type.type != type) { 227 psError(__func__, "The inputs to psImageComplex must be the same type."); 251 char* typeStrReal; 252 char* typeStrImag; 253 PS_TYPE_NAME(typeStrReal,type); 254 PS_TYPE_NAME(typeStrImag,imag->type.type); 255 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 256 PS_ERR_BAD_PARAMETER_TYPE, true, 257 PS_ERRORTEXT_psImageFFT_REAL_IMAG_TYPE_MISMATCH, 258 typeStrReal,typeStrImag); 228 259 psFree(out); 229 260 return NULL; … … 231 262 232 263 if (imag->numCols != numCols || imag->numRows != numRows) { 233 psError(__func__, "The inputs to psImageComplex must be the same dimensions."); 234 psFree(out); 235 return NULL; 236 } 237 238 if (PS_IS_PSELEMTYPE_COMPLEX(type)) { 239 psError(__func__, "The inputs to psImageComplex can not be complex."); 240 psFree(out); 241 return NULL; 242 } 243 244 if (type != PS_TYPE_F32 && type != PS_TYPE_F64) { 245 psError(__func__, "The input type to psImageComplex must be a floating point."); 264 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 265 PS_ERR_BAD_PARAMETER_VALUE, true, 266 PS_ERRORTEXT_psImageFFT_REAL_IMAG_SIZE_MISMATCH, 267 numCols, numRows, imag->numCols, imag->numRows); 246 268 psFree(out); 247 269 return NULL; … … 280 302 } 281 303 } else { 282 psError(__func__, "Can not merge real and imaginary portions for given image type (%d).", type); 283 psFree(out); 284 return NULL; 285 } 304 char* typeStr; 305 PS_TYPE_NAME(typeStr,type); 306 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageComplex", 307 PS_ERR_BAD_PARAMETER_TYPE, true, 308 PS_ERRORTEXT_psImageFFT_NONREAL_NOTSUPPORTED, 309 typeStr); 310 psFree(out); 311 return NULL; 312 } 313 286 314 287 315 return out; … … 303 331 numRows = in->numRows; 304 332 305 /* if not a complex number, this is logically just a image copy */ 306 if (!PS_IS_PSELEMTYPE_COMPLEX(type)) { 307 // Warn user, as this is probably not expected 308 psLogMsg(__func__, PS_LOG_WARN, "Complex Conjugate of a non-Complex type called for. " 309 "Image copy was performed instead."); 333 /* if not a complex image, this is logically just a image copy */ 334 if (!PS_IS_PSELEMTYPE_COMPLEX(type) && type != PS_TYPE_PTR) { 310 335 return psImageCopy(out, in, type); 311 336 } … … 338 363 } 339 364 } else { 340 psError(__func__, "Can not compute complex conjugate for given image type (%d).", type); 365 char* typeStr; 366 PS_TYPE_NAME(typeStr,type); 367 psErrorMsg(PS_ERRORNAME_DOMAIN "psImageConjugate", 368 PS_ERR_BAD_PARAMETER_TYPE, true, 369 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 370 typeStr); 341 371 psFree(out); 342 372 return NULL; … … 362 392 numRows = in->numRows; 363 393 numElementsSquared = numCols * numCols * numRows * numRows; 364 365 /* if not a complex number, this is not implemented */366 if (!PS_IS_PSELEMTYPE_COMPLEX(type)) {367 psError(__func__, "Power Spectrum for non-complex inputs is not implemented.");368 psFree(out);369 return NULL;370 }371 394 372 395 if (type == PS_TYPE_C32) { … … 405 428 } 406 429 } else { 407 psError(__func__, "Can not power spectrum for given image type (%d).", type); 408 psFree(out); 409 return NULL; 410 } 411 412 return out; 413 414 } 430 char* typeStr; 431 PS_TYPE_NAME(typeStr,type); 432 psErrorMsg(PS_ERRORNAME_DOMAIN "psImagePowerSpectrum", 433 PS_ERR_BAD_PARAMETER_TYPE, true, 434 PS_ERRORTEXT_psImageFFT_NONCOMPLEX_NOTSUPPORTED, 435 typeStr); 436 psFree(out); 437 return NULL; 438 } 439 440 return out; 441 442 }
Note:
See TracChangeset
for help on using the changeset viewer.
