{"record":{"id":"1d8d01fff81db2e2","repo":"Yalantis/uCrop","slug":"fft-instance-has-more-than-2-images","errorCode":null,"errorMessage":"FFT(): Instance has more than 2 images","messagePattern":"FFT\\(\\): Instance has more than 2 images","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":69034,"sourceCode":"          if (' ' + 256<font.size()) font[' ' + 256].resize(font[(int)'f']._width,-100,-100,-100,0);\n        }\n        font.insert(256,0);\n        cimglist_for_in(font,0,255,l) font[l].assign(font[l + 256]._width,font[l + 256]._height,1,1,255);\n      }\n      cimg::mutex(11,0);\n      return font;\n    }\n\n    //! Compute a 1D Fast Fourier Transform, along specified axis.\n    /**\n       \\param axis Axis along which the Fourier transform is computed.\n       \\param invert Tells if the direct (\\c false) or inverse transform (\\c true) is computed.\n    **/\n    CImgList<T>& FFT(const char axis, const bool invert=false) {\n      if (is_empty()) return *this;\n      if (_width==1) insert(1);\n      if (_width>2)\n        cimg::warn(_cimglist_instance\n                   \"FFT(): Instance has more than 2 images\",\n                   cimglist_instance);\n      CImg<T>::FFT(_data[0],_data[1],axis,invert);\n      return *this;\n    }\n\n    //! Compute a 1-D Fast Fourier Transform, along specified axis \\newinstance.\n    CImgList<Tfloat> get_FFT(const char axis, const bool invert=false) const {\n      return CImgList<Tfloat>(*this,false).FFT(axis,invert);\n    }\n\n    //! Compute n-D Fast Fourier Transform.\n    /**\n      \\param invert Tells if the direct (\\c false) or inverse transform (\\c true) is computed.\n    **/\n    CImgList<T>& FFT(const bool invert=false) {\n      if (is_empty()) return *this;\n      if (_width==1) insert(1);","sourceCodeStart":69016,"sourceCodeEnd":69052,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L69016-L69052","documentation":"CImgList::FFT(char axis, bool invert) expects a list of exactly 1 or 2 images (a real/imaginary pair; a single image gets a zero pair inserted). When the list holds more than 2 images, cimg::warn is emitted and only the first two images (_data[0], _data[1]) are transformed; the rest are left untouched. It is a warning, not an exception.","triggerScenarios":"Calling list.FFT('y') (axis variant) on a CImgList whose _width > 2, e.g. a list of several frames or slices, expecting per-image FFTs but getting only the first pair transformed.","commonSituations":"Confusing CImgList::FFT (which treats the list as one complex pair) with per-image CImg::FFT; passing a whole image sequence instead of a real/imaginary pair; leftover images in the list from earlier processing.","solutions":["Reduce the list to at most 2 images before calling FFT (e.g. extract a real/imag pair).","If you want per-image transforms, loop and call FFT on each CImg element instead of the list.","Clear or slice the list (list.remove(2, list.width()-1)) if extra images are accidental."],"exampleFix":"// before\nCImgList<float> res = frames.get_FFT('x'); // frames.width() == N > 2\n// after\nCImgList<float> res;\nfor (CImg<float>& img : frames) res.insert(img.get_FFT('x'));","handlingStrategy":"validation","validationCode":"if (list.width() > 2)\n  throw std::invalid_argument(\"CImgList::FFT expects 1 or 2 images, got \" + std::to_string(list.width()));","typeGuard":"bool is_fft_pair(const CImgList<float>& l) {\n  return l.width() == 1 || l.width() == 2;\n}","tryCatchPattern":"if (!is_fft_pair(list)) {\n  // split or truncate before FFT\n  list.remove(2, list.width()-1);\n}\nlist.FFT('x');","preventionTips":["Remember CImgList::FFT operates on one real/imaginary pair, not per-frame","Use CImg::FFT on each element for element-wise transforms","Assert list width <= 2 where complex pairs are constructed"],"tags":["cimg","fft","cimglist","warning","shape"],"backgroundTag":"tensor-shape-mismatch","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}