Yalantis/uCrop · error · CImgInstanceException
CImg<%s>::FFT(): Specified real part is empty.
Error message
CImg<%s>::FFT(): Specified real part is empty.
What it means
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.
Source
Thrown at ucrop/src/main/jni/CImg.h:47656
\param is_inverse Tells if the forward (\c false) or inverse (\c true) FFT is computed.
**/
CImgList<Tfloat> get_FFT(const bool is_inverse=false) const {
CImgList<Tfloat> res(*this,CImg<Tfloat>());
CImg<Tfloat>::FFT(res[0],res[1],is_inverse);
return res;
}
//! Compute 1D Fast Fourier Transform, along a specified axis.
/**
\param[in,out] real Real part of the pixel values.
\param[in,out] imag Imaginary part of the pixel values.
\param axis Axis along which the FFT is computed.
\param is_inverse Tells if the forward (\c false) or inverse (\c true) FFT is computed.
**/
static void FFT(CImg<T>& real, CImg<T>& imag, const char axis, const bool is_inverse=false,
const unsigned int nb_threads=0) {
if (!real)
throw CImgInstanceException("CImg<%s>::FFT(): Specified real part is empty.",
pixel_type());
if (!imag) imag.assign(real._width,real._height,real._depth,real._spectrum,(T)0);
if (!real.is_sameXYZC(imag))
throw CImgInstanceException("CImg<%s>::FFT(): Specified real part (%u,%u,%u,%u,%p) and "
"imaginary part (%u,%u,%u,%u,%p) have different dimensions.",
pixel_type(),
real._width,real._height,real._depth,real._spectrum,real._data,
imag._width,imag._height,imag._depth,imag._spectrum,imag._data);
const char _axis = cimg::lowercase(axis);
if (_axis!='x' && _axis!='y' && _axis!='z')
throw CImgArgumentException("CImgList<%s>::FFT(): Invalid specified axis '%c' for real and imaginary parts "
"(%u,%u,%u,%u) "
"(should be { x | y | z }).",
pixel_type(),axis,
real._width,real._height,real._depth,real._spectrum);
cimg::unused(nb_threads);
#ifdef cimg_use_fftw3
cimg::mutex(12);View on GitHub (pinned to f788b534b4)
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.
Example fix
// before CImg<float> real, imag; CImg<float>::FFT(real, imag, 'x'); // real is empty -> throws // after CImg<float> real(img.width(), img.height(), img.depth(), img.spectrum(), 0); real.copy(img); CImg<float>::FFT(real, imag, 'x');
Defensive patterns
Strategy: validation
Validate before calling
if (!real) { /* load failed or image empty: abort or assign dims */ } Type guard
bool fftRealReady(const CImg<T>& real) {
return (bool)real && real.size() > 0;
} Try / catch
try {
CImg<T>::FFT(real, imag, 'x');
} catch (const CImgInstanceException& e) {
// handle empty real part: load/assign before retrying
} Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- CImgList<%s>::FFT(): Invalid specified axis '%c' for real an
- cimg::fopen(): Specified file path is (null).
- cimg::fopen(): File '%s', specified mode is (null).
- cimg::fread(): Invalid reading request of %u %s%s from file
- cimg::fwrite(): Invalid writing request of %u %s%s from buff
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/f875502f012e46e9.
Report an issue: GitHub.