Yalantis/uCrop · error · CImgArgumentException
deriche(): Invalid specified order
Error message
deriche(): Invalid specified order '%d' ('order' can be { 0=smoothing | 1=1st-derivative | 2=2nd-derivative }). What it means
CImg's Deriche filter (deriche()) only supports order 0 (smoothing), 1 (first derivative) or 2 (second derivative). Any order value greater than 2 throws this argument-validation exception; order is checked at the top of the routine before any processing.
Solutions
- Pass order as 0, 1 or 2
- For higher derivatives, chain multiple 1st-derivative calls (deriche twice approximates 2nd order already) or use a different method
- Clamp or validate the order variable before calling
Example fix
// before img.deriche(2.0f, 3, 'x'); // after img.deriche(2.0f, 2, 'x'); // max supported derivative order
Defensive patterns
Strategy: validation
Validate before calling
if (order > 2) order = 2; // clamp before deriche()
Type guard
bool validDerivativeOrder(unsigned order) { return order <= 2; } Try / catch
try {
img.deriche(sigma, order, axis);
} catch (cimg_library::CImgArgumentException& e) {
img.deriche(sigma, 0, axis); // fall back to smoothing
} Prevention
- Treat 'order' as a 0-2 enum, not an arbitrary integer
- Clamp user/config supplied orders
- Note vanvliet shares this constraint
When it happens
Trigger: Calling img.deriche(sigma, order, axis) with order >= 3, e.g. passing a derivative order taken from a loop variable that overruns, or confusing 'order' with a filter size or iteration count.
Common situations: Mapping an arbitrary nth-derivative request onto Deriche (which only implements up to 2nd order); copy-pasting a vanvliet/Haar call pattern with wrong semantics; unsigned underflow is not possible here (order>2 fails, not negative).
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- deriche(): Invalid specified axis '%c'.
- "[" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- "[" cimg_appname "_math_parser] CImg<
- CImg< >::streamline(): Invalid specified integration length…
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/77537ae5262e9392.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:43755
T xp = (T)0; \
if (boundary_conditions) { xp = *ptrX; yb = yp = (double)(coefp*xp); } \
for (int m = 0; m<N; ++m) { \
const T xc = *ptrX; ptrX+=off; \
const double yc = *(ptrY++) = (double)(a0*xc + a1*xp - b1*yp - b2*yb); \
xp = xc; yb = yp; yp = yc; \
} \
T xn = (T)0, xa = (T)0; \
double yn = 0, ya = 0; \
if (boundary_conditions) { xn = xa = *(ptrX - off); yn = ya = (double)coefn*xn; } \
for (int n = N - 1; n>=0; --n) { \
const T xc = *(ptrX-=off); \
const double yc = (double)(a2*xn + a3*xa - b1*yn - b2*ya); \
xa = xn; xn = xc; ya = yn; yn = yc; \
*ptrX = (T)(*(--ptrY)+yc); \
}
if (order>2)
throw CImgArgumentException(_cimg_instance
"deriche(): Invalid specified order '%d' "
"('order' can be { 0=smoothing | 1=1st-derivative | 2=2nd-derivative }).",
cimg_instance,
order);
const char naxis = cimg::lowercase(axis);
if (naxis!='x' && naxis!='y' && naxis!='z' && naxis!='c')
throw CImgArgumentException(_cimg_instance
"deriche(): Invalid specified axis '%c'.",
cimg_instance,
axis);
const double
nsigma = sigma>=0?sigma:-sigma*(naxis=='x'?_width:
naxis=='y'?_height:
naxis=='z'?_depth:_spectrum)/100,
nnsigma = nsigma<0.1f?0.1f:nsigma;
if (is_empty() || (nsigma<0.1f && !order)) return *this;View on GitHub (pinned to f788b534b4)