{"record":{"id":"6dd1a7692bfe3b3c","repo":"Yalantis/uCrop","slug":"get-hessian-invalid-specified-axes-s","errorCode":null,"errorMessage":"get_hessian(): Invalid specified axes '%s'.","messagePattern":"get_hessian\\(\\): Invalid specified axes '(.+?)'\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":45657,"sourceCode":"    /**\n       \\param axes Axes considered for the hessian computation, as a C-string (e.g \"xy\").\n    **/\n    CImgList<Tfloat> get_hessian(const char *const axes=0) const {\n      CImgList<Tfloat> res;\n      char __axes[12] = {};\n      const char *_axes = axes?axes:__axes;\n      if (!axes) {\n        unsigned int k = 0;\n        if (_width>1) { __axes[k++] = 'x'; __axes[k++] = 'x'; }\n        if (_width>1 && _height>1) { __axes[k++] = 'x'; __axes[k++] = 'y'; }\n        if (_width>1 && _depth>1) { __axes[k++] = 'x'; __axes[k++] = 'z'; }\n        if (_height>1) { __axes[k++] = 'y'; __axes[k++] = 'y'; }\n        if (_height>1 && _depth>1) { __axes[k++] = 'y'; __axes[k++] = 'z'; }\n        if (_depth>1) { __axes[k++] = 'z'; __axes[k++] = 'z'; }\n      }\n      const unsigned int len = (unsigned int)std::strlen(_axes);\n      if (len%2)\n        throw CImgArgumentException(_cimg_instance\n                                    \"get_hessian(): Invalid specified axes '%s'.\",\n                                    cimg_instance,\n                                    axes);\n      CImg<Tfloat> hess;\n      for (unsigned int k = 0; k<len; k+=2) {\n        const char\n          _axis1 = cimg::lowercase(_axes[k]),\n          _axis2 = cimg::lowercase(_axes[k + 1]),\n          axis1 = std::min(_axis1,_axis2),\n          axis2 = std::max(_axis2,_axis2);\n        if (axis1!='x' && axis1!='y' && axis1!='z' &&\n            axis2!='x' && axis2!='y' && axis2!='z')\n          throw CImgArgumentException(_cimg_instance\n                                      \"get_hessian(): Invalid specified axes '%s'.\",\n                                      cimg_instance,\n                                      axes);\n        const longT off = axis1=='x'?1:axis1=='y'?_width:_width*_height;\n","sourceCodeStart":45639,"sourceCodeEnd":45675,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L45639-L45675","documentation":"CImg's get_hessian() computes Hessian components from pairs of axis letters supplied as a string (e.g. 'xx','xy','zz'). It first requires the axes string length to be even; an odd-length string means an incomplete axis pair, so it throws this CImgArgumentException before doing any work.","triggerScenarios":"Calling get_hessian(axes) with a string whose length is not a multiple of 2 - e.g. 'x' (length 1), 'xxy' (length 3), or a typo'd/empty-ish string with a stray character.","commonSituations":"Hand-written axes strings where one letter of a pair was deleted or forgotten ('xyy' instead of 'xyyy'), building the string programmatically and appending a single axis instead of two, or truncation of a longer string.","solutions":["Count the characters of the axes string and make sure it contains complete pairs ('xx','xy','xz','yy','yz','zz')","Fix the string to include both letters of each desired Hessian component, e.g. change 'xxy' to 'xxyy' or 'xy'","Build the string programmatically by always appending two axis characters per component","Note the same error text is reused at line 45670 for invalid axis letters - if the length is even, check for non x/y/z characters instead"],"exampleFix":"// before\nimg.get_hessian(\"xyy\"); // odd length\n// after\nimg.get_hessian(\"xyyy\"); // complete pairs: xy, yy","handlingStrategy":"validation","validationCode":"static bool isEvenAxisPairs(const std::string& axes) {\n  return axes.size() % 2 == 0;\n}\n// only call get_hessian when isEvenAxisPairs(axes) is true","typeGuard":"bool isCompleteHessianComponent(const std::string& s) {\n  return s.size() == 2; // one Hessian component = two axis letters\n}","tryCatchPattern":"try {\n  CImg<float> hess = img.get_hessian(axes);\n} catch (CImgArgumentException& e) {\n  std::fprintf(stderr, \"axes must be pairs (len=%zu): %s\\n\",\n               std::strlen(axes), e.what());\n  CImg<float> hess = img.get_hessian(); // default: all components\n}","preventionTips":["Always append two characters per Hessian component ('xx','xy',...)","Assert strlen(axes) % 2 == 0 before the call","Generate the string programmatically rather than typing it by hand","If length is even but it still throws, check for invalid letters (line 45670 variant)"],"tags":["cimg","argument-validation","axes-string"],"backgroundTag":"invalid-argument-format","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"}