Yalantis/uCrop · warning
FFT(): Instance has more than 2 images
Error message
FFT(): Instance has more than 2 images
What it means
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.
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.
Example fix
// before
CImgList<float> res = frames.get_FFT('x'); // frames.width() == N > 2
// after
CImgList<float> res;
for (CImg<float>& img : frames) res.insert(img.get_FFT('x')); Defensive patterns
Strategy: validation
Validate before calling
if (list.width() > 2)
throw std::invalid_argument("CImgList::FFT expects 1 or 2 images, got " + std::to_string(list.width())); Type guard
bool is_fft_pair(const CImgList<float>& l) {
return l.width() == 1 || l.width() == 2;
} Try / catch
if (!is_fft_pair(list)) {
// split or truncate before FFT
list.remove(2, list.width()-1);
}
list.FFT('x'); Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: Tensor shape mismatch errors ("must have shape", "expected shape ... got ..."): when tensor dimensions disagree with what an op or layer was told to expect — this error's family across 6 libraries.
Related errors
- CImg< >::FFT(): Specified real part is empty.
- CImg< >::FFT(): Specified real part (%u,%u,%u,%u,%p) and…
- CImgList< >::FFT(): Empty specified real part.
- CImgList< >::FFT(): Failed to allocate memory ( ) for…
- CImgList< >::FFT(): Failed to allocate memory ( ) for…
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/1d8d01fff81db2e2.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:69034
if (' ' + 256<font.size()) font[' ' + 256].resize(font[(int)'f']._width,-100,-100,-100,0);
}
font.insert(256,0);
cimglist_for_in(font,0,255,l) font[l].assign(font[l + 256]._width,font[l + 256]._height,1,1,255);
}
cimg::mutex(11,0);
return font;
}
//! Compute a 1D Fast Fourier Transform, along specified axis.
/**
\param axis Axis along which the Fourier transform is computed.
\param invert Tells if the direct (\c false) or inverse transform (\c true) is computed.
**/
CImgList<T>& FFT(const char axis, const bool invert=false) {
if (is_empty()) return *this;
if (_width==1) insert(1);
if (_width>2)
cimg::warn(_cimglist_instance
"FFT(): Instance has more than 2 images",
cimglist_instance);
CImg<T>::FFT(_data[0],_data[1],axis,invert);
return *this;
}
//! Compute a 1-D Fast Fourier Transform, along specified axis \newinstance.
CImgList<Tfloat> get_FFT(const char axis, const bool invert=false) const {
return CImgList<Tfloat>(*this,false).FFT(axis,invert);
}
//! Compute n-D Fast Fourier Transform.
/**
\param invert Tells if the direct (\c false) or inverse transform (\c true) is computed.
**/
CImgList<T>& FFT(const bool invert=false) {
if (is_empty()) return *this;
if (_width==1) insert(1);View on GitHub (pinned to f788b534b4)