{"record":{"id":"7e9c9d87472eaf30","repo":"Yalantis/uCrop","slug":"cimglist-s-fft-invalid-specified-axis-c-f","errorCode":null,"errorMessage":"CImgList<%s>::FFT(): Invalid specified axis '%c' for real and imaginary parts (%u,%u,%u,%u) (should be { x | y | z }).","messagePattern":"CImgList<(.+?)>::FFT\\(\\): Invalid specified axis '%c' for real and imaginary parts \\(%u,%u,%u,%u\\) \\(should be (.+?)\\)\\.","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":47667,"sourceCode":"       \\param[in,out] imag Imaginary part of the pixel values.\n       \\param axis Axis along which the FFT is computed.\n       \\param is_inverse Tells if the forward (\\c false) or inverse (\\c true) FFT is computed.\n    **/\n    static void FFT(CImg<T>& real, CImg<T>& imag, const char axis, const bool is_inverse=false,\n                    const unsigned int nb_threads=0) {\n      if (!real)\n        throw CImgInstanceException(\"CImg<%s>::FFT(): Specified real part is empty.\",\n                                    pixel_type());\n      if (!imag) imag.assign(real._width,real._height,real._depth,real._spectrum,(T)0);\n      if (!real.is_sameXYZC(imag))\n        throw CImgInstanceException(\"CImg<%s>::FFT(): Specified real part (%u,%u,%u,%u,%p) and \"\n                                    \"imaginary part (%u,%u,%u,%u,%p) have different dimensions.\",\n                                    pixel_type(),\n                                    real._width,real._height,real._depth,real._spectrum,real._data,\n                                    imag._width,imag._height,imag._depth,imag._spectrum,imag._data);\n      const char _axis = cimg::lowercase(axis);\n      if (_axis!='x' && _axis!='y' && _axis!='z')\n        throw CImgArgumentException(\"CImgList<%s>::FFT(): Invalid specified axis '%c' for real and imaginary parts \"\n                                    \"(%u,%u,%u,%u) \"\n                                    \"(should be { x | y | z }).\",\n                                    pixel_type(),axis,\n                                    real._width,real._height,real._depth,real._spectrum);\n      cimg::unused(nb_threads);\n#ifdef cimg_use_fftw3\n      cimg::mutex(12);\n#ifndef cimg_use_fftw3_singlethread\n      fftw_plan_with_nthreads(nb_threads?nb_threads:cimg::nb_cpus());\n#endif\n      fftw_complex *data_in = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)*real._width*real._height*real._depth);\n      if (!data_in)\n        throw CImgInstanceException(\"CImgList<%s>::FFT(): Failed to allocate memory (%s) \"\n                                    \"for computing FFT of image (%u,%u,%u,%u) along the X-axis.\",\n                                    pixel_type(),\n                                    cimg::strbuffersize(sizeof(fftw_complex)*real._width*real._height*real._depth),\n                                    real._width,real._height,real._depth,real._spectrum);\n      double *const ptrf = (double*)data_in;","sourceCodeStart":47649,"sourceCodeEnd":47685,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L47649-L47685","documentation":"CImgList<T>::FFT() validates its axis argument by lowercasing it and requiring it to be 'x', 'y' or 'z'. Any other character is rejected because FFT can only be computed along one of the three image dimensions. This is an argument-validation guard in ucrop/src/main/jni/CImg.h before any FFT work starts.","triggerScenarios":"Calling CImgList<T>::FFT() or the static CImg<T>::FFT(real, imag, is_inverse, nb_threads) variant with an axis character other than 'x', 'y', or 'z' (case-insensitive), e.g. axis='w', a typo like 'X ' with trailing whitespace, or a variable holding an uninitialized char.","commonSituations":"Typo in the axis literal, passing a user-supplied axis string without validating it, porting code that used a numeric axis index (0/1/2) where CImg expects a character, or reading the axis from config where an empty/invalid value slips through.","solutions":["Pass one of the literal characters 'x', 'y' or 'z' (case does not matter; it is lowercased internally).","Validate/normalize the axis string before the call, rejecting anything not in {x,y,z}.","If you have a numeric axis, map it: 0->'x', 1->'y', 2->'z'."],"exampleFix":"// before\nimg.FFT(true, false, 'X');  // or FFT(..., 'w')\n// after\nimg.FFT(true, false, 'x');  // only 'x', 'y' or 'z' allowed","handlingStrategy":"validation","validationCode":"char a = std::tolower(axis);\nif (a != 'x' && a != 'y' && a != 'z') throw std::invalid_argument(\"axis must be x, y or z\");","typeGuard":"bool isValidAxis(char c) { return c=='x'||c=='X'||c=='y'||c=='Y'||c=='z'||c=='Z'; }","tryCatchPattern":"try { img.FFT(is_inverse, /*axis*/'x'); }\ncatch (CImgArgumentException& e) { std::cerr << \"Bad FFT axis: \" << e.what() << std::endl; }","preventionTips":["Always pass the axis as a character literal 'x', 'y' or 'z', never a numeric index","Normalize user/config-supplied axis strings with tolower and whitelist before calling","Trim whitespace from any axis value sourced from strings"],"tags":["cimg","fft","argument-validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}