{"record":{"id":"63de967cf1b62f84","repo":"Yalantis/uCrop","slug":"blur-bilateral-invalid-size-for-specified-guide","errorCode":null,"errorMessage":"blur_bilateral(): Invalid size for specified guide image (%u,%u,%u,%u,%p).","messagePattern":"blur_bilateral\\(\\): 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":44534,"sourceCode":"         Defaults (0) to sigma_x.\n       \\param sampling_y Amount of downsampling along the Y-axis used for the approximation.\n         Defaults (0) to sigma_y.\n       \\param sampling_z Amount of downsampling along the Z-axis used for the approximation.\n         Defaults (0) to sigma_z.\n       \\param sampling_r Amount of downsampling along the value axis used for the approximation.\n         Defaults (0) to sigma_r.\n       \\note This algorithm uses the optimisation technique proposed by S. Paris and F. Durand, in ECCV'2006\n       (extended for 3D volumetric images).\n       It is based on the reference implementation http://people.csail.mit.edu/jiawen/software/bilateralFilter.m\n    **/\n    template<typename t>\n    CImg<T>& blur_bilateral(const CImg<t>& guide,\n                            const float sigma_x, const float sigma_y,\n                            const float sigma_z, const float sigma_r,\n                            const float sampling_x, const float sampling_y,\n                            const float sampling_z, const float sampling_r) {\n      if (!is_sameXYZ(guide))\n        throw CImgArgumentException(_cimg_instance\n                                    \"blur_bilateral(): 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() || (!sigma_x && !sigma_y && !sigma_z)) return *this;\n      T edge_min, edge_max = guide.max_min(edge_min);\n      if (edge_min==edge_max) return blur(sigma_x,sigma_y,sigma_z);\n      const float\n        edge_delta = (float)(edge_max - edge_min),\n        _sigma_x = sigma_x>=0?sigma_x:-sigma_x*_width/100,\n        _sigma_y = sigma_y>=0?sigma_y:-sigma_y*_height/100,\n        _sigma_z = sigma_z>=0?sigma_z:-sigma_z*_depth/100,\n        _sigma_r = sigma_r>=0?sigma_r:-sigma_r*edge_delta/100,\n        _sampling_x = sampling_x?sampling_x:std::max(_sigma_x,1.f),\n        _sampling_y = sampling_y?sampling_y:std::max(_sigma_y,1.f),\n        _sampling_z = sampling_z?sampling_z:std::max(_sigma_z,1.f),\n        _sampling_r = sampling_r?sampling_r:std::max(_sigma_r,edge_delta/256),\n        derived_sigma_x = _sigma_x / _sampling_x,\n        derived_sigma_y = _sigma_y / _sampling_y,","sourceCodeStart":44516,"sourceCodeEnd":44552,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L44516-L44552","documentation":"CImg's blur_bilateral() requires the guide (range/edge) image to have exactly the same width, height and depth as the source image (spectrum may differ). The bilateral filter pairs every source pixel with a guide pixel, so mismatched sizes throw this argument-validation error.","triggerScenarios":"Calling img.blur_bilateral(guide, ...) where guide is a grayscale downsample or differently cropped version of img; passing a guide built from another image with different dimensions.","commonSituations":"Using a luminance/edge guide computed after resizing; loading the guide from disk with different resolution; forgetting that guide XYZ (not necessarily spectrum) must match.","solutions":["Resize the guide to match the source: guide.resize(img.width(), img.height(), img.depth(), -100, 3)","Recompute the guide from the same-resolution source image","Assert img.is_sameXYZ(guide) before calling"],"exampleFix":"// before\nimg.blur_bilateral(guideSmall, 8, 8, 0, 10);\n// after\nguideSmall.resize(img.width(), img.height(), img.depth(), -100, 3);\nimg.blur_bilateral(guideSmall, 8, 8, 0, 10);","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  img.blur_bilateral(guide, sx, sy, sz, sr);\n} catch (cimg_library::CImgArgumentException& e) {\n  guide.resize(img.width(), img.height(), img.depth(), -100, 3);\n  img.blur_bilateral(guide, sx, sy, sz, sr);\n}","preventionTips":["Keep guide images in the same geometry as the source","Call is_sameXYZ before pairing images","Avoid resizing one image in a paired pipeline without the other"],"tags":["cimg","image-processing","blur-bilateral","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-14T11:17:12.474Z"}