{"record":{"id":"f875502f012e46e9","repo":"Yalantis/uCrop","slug":"cimg-s-fft-specified-real-part-is-empty","errorCode":null,"errorMessage":"CImg<%s>::FFT(): Specified real part is empty.","messagePattern":"CImg<(.+?)>::FFT\\(\\): Specified real part is empty\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":47656,"sourceCode":"      \\param is_inverse Tells if the forward (\\c false) or inverse (\\c true) FFT is computed.\n    **/\n    CImgList<Tfloat> get_FFT(const bool is_inverse=false) const {\n      CImgList<Tfloat> res(*this,CImg<Tfloat>());\n      CImg<Tfloat>::FFT(res[0],res[1],is_inverse);\n      return res;\n    }\n\n    //! Compute 1D Fast Fourier Transform, along a specified axis.\n    /**\n       \\param[in,out] real Real part of the pixel values.\n       \\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);","sourceCodeStart":47638,"sourceCodeEnd":47674,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L47638-L47674","documentation":"CImg::FFT(real, imag, axis, is_inverse) is a static two-image FFT: `real` holds the real component and must be a non-empty image. If real is empty (default-constructed or assigned()), the function throws CImgInstanceException immediately, before any FFT work.","triggerScenarios":"Calling CImg<T>::FFT(real, imag, 'x') where real was default-constructed, or real.assign() was called, or a failed load left the image empty (operator! true).","commonSituations":"Image load failure (missing file) silently yielding an empty CImg that is then passed to FFT; forgetting to size the real part; using a moved-from image; FFT in a processing chain downstream of a failed crop.","solutions":["Ensure `real` is a valid, non-empty image: construct with dimensions or load successfully before calling FFT.","Check `if (real)` (operator bool) before calling FFT and handle the empty case.","If the real part should be zero, assign it explicitly: real.assign(w,h,d,s,0).","Verify that the preceding load/crop that produced `real` succeeded."],"exampleFix":"// before\nCImg<float> real, imag;\nCImg<float>::FFT(real, imag, 'x'); // real is empty -> throws\n// after\nCImg<float> real(img.width(), img.height(), img.depth(), img.spectrum(), 0);\nreal.copy(img);\nCImg<float>::FFT(real, imag, 'x');","handlingStrategy":"validation","validationCode":"if (!real) { /* load failed or image empty: abort or assign dims */ }","typeGuard":"bool fftRealReady(const CImg<T>& real) {\n  return (bool)real && real.size() > 0;\n}","tryCatchPattern":"try {\n  CImg<T>::FFT(real, imag, 'x');\n} catch (const CImgInstanceException& e) {\n  // handle empty real part: load/assign before retrying\n}","preventionTips":["Always check operator! on images returned by loads before further processing.","Construct the real part with explicit dimensions instead of default ctor.","In chains, propagate load/crop failures instead of passing empty images on."],"tags":["cimg","fft","empty-input","argument-validation"],"backgroundTag":"empty-required-field","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"}