{"record":{"id":"6fca04190cccbeec","repo":"Yalantis/uCrop","slug":"blur-guided-invalid-size-for-specified-guide-im","errorCode":null,"errorMessage":"blur_guided(): Invalid size for specified guide image (%u,%u,%u,%u,%p).","messagePattern":"blur_guided\\(\\): Invalid size for specified guide image \\(%u,%u,%u,%u,%p\\)\\.","errorType":"validation","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":44887,"sourceCode":"    /**\n       \\param guide Image used to guide the smoothing process.\n       \\param radius Spatial radius. If negative, it is expressed as a percentage of the largest image size.\n       \\param regularization Regularization parameter.\n                             If negative, it is expressed as a percentage of the guide value range.\n       \\note This method implements the filtering algorithm described in:\n       He, Kaiming; Sun, Jian; Tang, Xiaoou, \"Guided Image Filtering,\" Pattern Analysis and Machine Intelligence,\n       IEEE Transactions on , vol.35, no.6, pp.1397,1409, June 2013\n    **/\n    template<typename t>\n    CImg<T>& blur_guided(const CImg<t>& guide, const float radius, const float regularization) {\n      return get_blur_guided(guide,radius,regularization).move_to(*this);\n    }\n\n    //! Blur image, with the image guided filter \\newinstance.\n    template<typename t>\n    CImg<Tfloat> get_blur_guided(const CImg<t>& guide, const float radius, const float regularization) const {\n      if (!is_sameXYZ(guide))\n        throw CImgArgumentException(_cimg_instance\n                                    \"blur_guided(): Invalid size for specified guide image (%u,%u,%u,%u,%p).\",\n                                    cimg_instance,\n                                    guide._width,guide._height,guide._depth,guide._spectrum,guide._data);\n      if (is_empty() || !radius) return *this;\n      const int _radius = radius>=0?(int)radius:(int)(-radius*cimg::max(_width,_height,_depth)/100);\n      float _regularization = regularization;\n      if (regularization<0) {\n        T edge_min, edge_max = guide.max_min(edge_min);\n        if (edge_min==edge_max) return *this;\n        _regularization = -regularization*(edge_max - edge_min)/100;\n      }\n      _regularization = std::max(_regularization,0.01f);\n      const unsigned int psize = (unsigned int)(1 + 2*_radius);\n      CImg<Tfloat>\n        mean_p = get_blur_box(psize,true),\n        mean_I = guide.get_blur_box(psize,true).resize(mean_p),\n        cov_Ip = get_mul(guide).blur_box(psize,true)-=mean_p.get_mul(mean_I),\n        var_I = guide.get_sqr().blur_box(psize,true)-=mean_I.get_sqr(),","sourceCodeStart":44869,"sourceCodeEnd":44905,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L44869-L44905","documentation":"The get_blur_guided() new-instance variant of the guided filter requires the guide image to match the source image's width, height and depth. If is_sameXYZ(guide) fails, CImg throws this error; the filter indexes guide pixels at the same coordinates as source pixels.","triggerScenarios":"Calling img.get_blur_guided(guide, radius, regularization) with a guide of different resolution or channel-count-derived dimensions, e.g. a downscaled guidance image or one loaded from another file.","commonSituations":"Using a guidance image (edges map, depth map, flash/no-flash pairs) captured or stored at a different size; mismatch after applying resize to one image only.","solutions":["Resize the guide to the source dimensions before the call","Regenerate the guide from the same geometry as the source image","Check is_sameXYZ in code before invoking get_blur_guided"],"exampleFix":"// before\nCImg<float> out = img.get_blur_guided(guideLowRes, 5, 0.01f);\n// after\nguideLowRes.resize(img.width(), img.height(), img.depth(), -100, 3);\nCImg<float> out = img.get_blur_guided(guideLowRes, 5, 0.01f);","handlingStrategy":"validation","validationCode":"if (!img.is_sameXYZ(guide)) guide.resize(img.width(), img.height(), img.depth(), -100, 3);","typeGuard":"bool guideMatches(const CImg<T>& img, const CImg<t>& guide) { return img.is_sameXYZ(guide); }","tryCatchPattern":"try {\n  auto out = img.get_blur_guided(guide, radius, regularization);\n} catch (cimg_library::CImgArgumentException& e) {\n  guide.resize(img.width(), img.height(), img.depth(), -100, 3);\n  auto out = img.get_blur_guided(guide, radius, regularization);\n}","preventionTips":["Resize guidance images (depth maps, edge maps) to source geometry first","Check XYZ match, not spectrum: channels may differ","Cover guided filtering with a same-size fixture test"],"tags":["cimg","image-processing","guided-filter","dimension-mismatch"],"backgroundTag":"tensor-shape-mismatch","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"}