IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 21, 2004, 12:30:19 PM (22 years ago)
Author:
desonia
Message:

Changed the image code to the new psErrorMsg error handling specification.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImageFFT.c

    r1625 r1840  
    55 *  @author Robert DeSonia, MHPCC
    66 *
    7  *  @version $Revision: 1.1 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2004-08-25 21:10:09 $
     7 *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2004-09-21 22:30:19 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2222#include "psImageExtraction.h"
    2323
     24#include "psImageErrors.h"
     25
    2426#define P_FFTW_PLAN_RIGOR FFTW_ESTIMATE
    2527
     
    4244
    4345    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);
    4552        psFree(out);
    4653        return NULL;
     
    4855
    4956    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);
    5163        psFree(out);
    5264        return NULL;
     
    5567
    5668    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);
    5875        psFree(out);
    5976        return NULL;
     
    6986    numCols = in->numCols;
    7087
     88    // n.b. FFTW can perform a in-place transform at the same or faster than out-of-place.
    7189    out = psImageCopy(out, in, PS_TYPE_C32);
    72 
    7390    plan = fftwf_plan_dft_2d(numCols, numRows,
    7491                             (fftwf_complex *) out->data.C32[0],
    7592                             (fftwf_complex *) out->data.C32[0], direction, P_FFTW_PLAN_RIGOR);
    7693
    77     /* check if a plan exists now */
     94    /* check if a plan exists now -- if not, it is a real problem */
    7895    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);
    8099        psFree(out);
    81100        return NULL;
     
    106125    numRows = in->numRows;
    107126
    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) {
    113129        return psImageCopy(out, in, type);
    114130    }
     
    141157        }
    142158    } 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
    144166        psFree(out);
    145167        return NULL;
     
    164186    numRows = in->numRows;
    165187
    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) {
    171190        out = psImageRecycle(out, numCols, numRows, type);
    172191        memset(out->data.V[0], 0, PSELEMTYPE_SIZEOF(type) * numCols * numRows);
     
    201220        }
    202221    } 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);
    204228        psFree(out);
    205229        return NULL;
     
    225249
    226250    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);
    228259        psFree(out);
    229260        return NULL;
     
    231262
    232263    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);
    246268        psFree(out);
    247269        return NULL;
     
    280302        }
    281303    } 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
    286314
    287315    return out;
     
    303331    numRows = in->numRows;
    304332
    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) {
    310335        return psImageCopy(out, in, type);
    311336    }
     
    338363        }
    339364    } 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);
    341371        psFree(out);
    342372        return NULL;
     
    362392    numRows = in->numRows;
    363393    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     }
    371394
    372395    if (type == PS_TYPE_C32) {
     
    405428        }
    406429    } 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.