{"record":{"id":"cea41ba72d72bc03","repo":"Yalantis/uCrop","slug":"cimg-instance-minabs-empty-instance","errorCode":null,"errorMessage":"_cimg_instance \"minabs(): Empty instance.\"","messagePattern":"_cimg_instance \"minabs\\(\\): Empty instance\\.\"","errorType":"exception","errorClass":"CImgInstanceException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":31775,"sourceCode":"\n    //! Return a reference to the minimum pixel value \\const.\n    const T& min() const {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"min(): Empty instance.\",\n                                    cimg_instance);\n      const T *ptr_min = _data;\n      T min_value = *ptr_min;\n      cimg_for(*this,ptrs,T) if (*ptrs<min_value) min_value = *(ptr_min=ptrs);\n      return *ptr_min;\n    }\n\n    //! Return a reference to the minimum pixel value in absolute value.\n    /**\n     **/\n    T& minabs() {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"minabs(): Empty instance.\",\n                                    cimg_instance);\n      T *ptr_minabs = _data;\n      T minabs_value = *ptr_minabs;\n      cimg_for(*this,ptrs,T) {\n        const T ma = cimg::abs(*ptrs);\n        if (ma<minabs_value) { minabs_value = ma; ptr_minabs = ptrs; }\n      }\n      return *ptr_minabs;\n    }\n\n    //! Return a reference to the minimum pixel value in absolute value \\const.\n    const T& minabs() const {\n      if (is_empty())\n        throw CImgInstanceException(_cimg_instance\n                                    \"minabs(): Empty instance.\",\n                                    cimg_instance);\n      const T *ptr_minabs = _data;","sourceCodeStart":31757,"sourceCodeEnd":31793,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L31757-L31793","documentation":"CImg<T>::minabs() returns a reference to the pixel with the smallest absolute value; on an empty instance there is no pixel to inspect, so CImgInstanceException is thrown instead of dereferencing invalid memory.","triggerScenarios":"Calling img.minabs() on a zero-size CImg (default-constructed, cleared, or produced by an empty crop/load).","commonSituations":"Signal/statistics code assuming the input was loaded; pipelines where a previous threshold or channel extraction emptied the buffer.","solutions":["Check img.is_empty() before calling minabs()","Fix the step that produced the empty image (load path, ROI bounds)"],"exampleFix":"// before\nfloat v = img.minabs();\n// after\nif (!img.is_empty()) { float v = img.minabs(); }","handlingStrategy":"validation","validationCode":"if (!img.is_empty()) { ... img.minabs() ... }","typeGuard":null,"tryCatchPattern":"try { T v = img.minabs(); } catch (const CImgInstanceException& e) { /* handle empty */ }","preventionTips":["Validate non-emptiness before any min/max/abs statistics call","Check that ROI computations never yield zero-size regions"],"tags":["cimg","empty-instance","image-processing"],"backgroundTag":"empty-result-set","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"}