{"record":{"id":"13f8a518164f3a22","repo":"Yalantis/uCrop","slug":"atxyz-empty-instance","errorCode":null,"errorMessage":"atXYZ(): Empty instance.","messagePattern":"atXYZ\\(\\): Empty instance\\.","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":15737,"sourceCode":"      return (x<0 || y<0 || z<0 || x>=width() || y>=height() || z>=depth())?\n        (cimg::temporary(out_value)=out_value):(*this)(x,y,z,c);\n    }\n\n    //! Access to a pixel value, using Dirichlet boundary conditions for the X,Y and Z-coordinates \\const.\n    T atXYZ(const int x, const int y, const int z, const int c, const T& out_value) const {\n      return (x<0 || y<0 || z<0 || x>=width() || y>=height() || z>=depth())?out_value:(*this)(x,y,z,c);\n    }\n\n    //! Access to a pixel value, using Neumann boundary conditions for the X,Y and Z-coordinates.\n    /**\n       Similar to atX(int,int,int,int), except that boundary checking is performed both on X,Y and Z-coordinates.\n       \\note\n       - If you know your image instance is \\e not empty, you may rather use the slightly faster method\n         \\c _atXYZ(int,int,int,int).\n    **/\n    T& atXYZ(const int x, const int y, const int z, const int c=0) {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"atXYZ(): Empty instance.\",\n                                    cimg_instance);\n      return _atXYZ(x,y,z,c);\n    }\n\n    T& _atXYZ(const int x, const int y, const int z, const int c=0) {\n      return (*this)(cimg::cut(x,0,width() - 1),\n                     cimg::cut(y,0,height() - 1),\n                     cimg::cut(z,0,depth() - 1),c);\n    }\n\n    //! Access to a pixel value, using Neumann boundary conditions for the X,Y and Z-coordinates \\const.\n    const T& atXYZ(const int x, const int y, const int z, const int c=0) const {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"atXYZ(): Empty instance.\",\n                                    cimg_instance);\n      return _atXYZ(x,y,z,c);","sourceCodeStart":15719,"sourceCodeEnd":15755,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L15719-L15755","documentation":"Thrown by CImg<T>::atXYZ(int,int,int,int,const T&) when the image is empty (null data / zero dimensions): even though atXYZ normally returns out_value for out-of-bounds coordinates, there is no pixel buffer at all to index, so the access is rejected.","triggerScenarios":"Calling img.atXYZ(x,y,z,c) on an empty (zero-size) image, typically a default-constructed CImg or one from a failed load.","commonSituations":"Volumetric/3D sampling code where the volume failed to load or a crop produced zero depth.","solutions":["Check img.is_empty() before calling atXYZ().","Verify the volume-producing step (load/assign/crop) returned non-zero dimensions.","Note the C coordinate is still unchecked - validate it yourself."],"exampleFix":"// before\nfloat v = vol.atXYZ(x, y, z); // throws if vol empty\n// after\nif (!vol.is_empty()) { float v = vol.atXYZ(x, y, z); }","handlingStrategy":"validation","validationCode":"if (!vol.is_empty() && c >= 0 && c < vol.spectrum()) {\n  T v = vol.atXYZ(x, y, z, c);\n}","typeGuard":null,"tryCatchPattern":"try {\n  T v = vol.atXYZ(x, y, z);\n} catch (CImgInstanceException& e) {\n  // empty volume fallback\n}","preventionTips":["Check is_empty() on volumes before 3D sampling.","Validate the C coordinate yourself - atXYZ clamps only X, Y, Z.","Verify load()/crop() produced non-zero depth before volumetric loops."],"tags":["cimg","empty-image","bounds-check","pixel-access"],"backgroundTag":"empty-required-field","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}