{"record":{"id":"618331018150347b","repo":"Yalantis/uCrop","slug":"deriche-invalid-specified-axis-c","errorCode":null,"errorMessage":"deriche(): Invalid specified axis '%c'.","messagePattern":"deriche\\(\\): Invalid specified axis '%c'\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":43763,"sourceCode":"  double yn = 0, ya = 0; \\\n  if (boundary_conditions) { xn = xa = *(ptrX - off); yn = ya = (double)coefn*xn; } \\\n  for (int n = N - 1; n>=0; --n) { \\\n    const T xc = *(ptrX-=off); \\\n    const double yc = (double)(a2*xn + a3*xa - b1*yn - b2*ya); \\\n    xa = xn; xn = xc; ya = yn; yn = yc; \\\n    *ptrX = (T)(*(--ptrY)+yc); \\\n  }\n\n      if (order>2)\n        throw CImgArgumentException(_cimg_instance\n                                    \"deriche(): Invalid specified order '%d' \"\n                                    \"('order' can be { 0=smoothing | 1=1st-derivative | 2=2nd-derivative }).\",\n                                    cimg_instance,\n                                    order);\n\n      const char naxis = cimg::lowercase(axis);\n      if (naxis!='x' && naxis!='y' && naxis!='z' && naxis!='c')\n        throw CImgArgumentException(_cimg_instance\n                                    \"deriche(): Invalid specified axis '%c'.\",\n                                    cimg_instance,\n                                    axis);\n      const double\n        nsigma = sigma>=0?sigma:-sigma*(naxis=='x'?_width:\n                                        naxis=='y'?_height:\n                                        naxis=='z'?_depth:_spectrum)/100,\n        nnsigma = nsigma<0.1f?0.1f:nsigma;\n\n      if (is_empty() || (nsigma<0.1f && !order)) return *this;\n      if (boundary_conditions>1) {\n        const int w = width(), h = height(), d = depth(), s = spectrum(), border = (int)cimg::round(1 + 3*nnsigma);\n        switch (naxis) {\n        case 'x' :\n          return draw_image(get_resize(w + 2*border,h,d,s,0,boundary_conditions,0.5).\n                            deriche(nnsigma,order,naxis,1).columns(border,w - 1 + border));\n        case 'y' :\n          return draw_image(get_resize(w,h + 2*border,d,s,0,boundary_conditions,0,0.5).","sourceCodeStart":43745,"sourceCodeEnd":43781,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L43745-L43781","documentation":"CImg's deriche() applies the recursive Deriche filter along one axis ('x','y','z' or 'c', case-insensitive after lowercase()). Any other character throws this error because the filter cannot resolve which image dimension to run along.","triggerScenarios":"Calling img.deriche(sigma, order, axis) with axis like 'X' handled fine but 'w','h','0', or an uninitialized char throwing; passing axis values from an external config mapping that uses different axis names.","commonSituations":"Typo in the axis parameter ('xx', 'X-axis'); axis read from user input or a config file with unexpected values; forgetting that CImg uses x/y/z/c not width/height.","solutions":["Pass one of 'x','y','z','c' (any case) as the axis argument","Validate/normalize the axis string from config or user input before the call","For a 2D image remember 'z' and 'c' are only valid if depth/spectrum > 1 conceptually, though the check here only validates the character"],"exampleFix":"// before\nimg.deriche(2.0f, 1, 'w');\n// after\nimg.deriche(2.0f, 1, 'x');","handlingStrategy":"validation","validationCode":"const char valid[] = {'x','y','z','c'};\nif (!strchr(valid, (char)std::tolower((unsigned char)axis))) axis = 'x';","typeGuard":"bool validAxis(char a) { a = std::tolower((unsigned char)a); return a=='x'||a=='y'||a=='z'||a=='c'; }","tryCatchPattern":"try {\n  img.deriche(sigma, order, axis);\n} catch (cimg_library::CImgArgumentException& e) {\n  img.deriche(sigma, order, 'x');\n}","preventionTips":["Map external axis names ('width','height', 0/1/2) to 'x','y','z','c' at the boundary","Normalize case with tolower since CImg does the same","Cover axis parsing with unit tests"],"tags":["cimg","image-processing","deriche","axis","argument-validation"],"backgroundTag":"invalid-enum-value","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"}