mirror of https://github.com/davisking/dlib.git
Fixed a bug in gaussian_blur() that caused messed up outputs when big sigma
values were used on some pixel types.
This commit is contained in:
parent
d3f12d832c
commit
7770225a88
|
@ -1233,15 +1233,25 @@ namespace dlib
|
|||
<< "\n\t is_same_object(in_img,out_img): " << is_same_object(in_img,out_img)
|
||||
);
|
||||
|
||||
if (sigma < 18)
|
||||
{
|
||||
typedef typename pixel_traits<typename image_traits<out_image_type>::pixel_type>::basic_pixel_type type;
|
||||
typedef typename promote<type>::type ptype;
|
||||
|
||||
const matrix<ptype,0,1>& filt = create_gaussian_filter<ptype>(sigma, max_size);
|
||||
|
||||
ptype scale = sum(filt);
|
||||
scale = scale*scale;
|
||||
|
||||
return spatially_filter_image_separable(in_img, out_img, filt, filt, scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For large sigma we need to use a type with a lot of precision to avoid
|
||||
// numerical problems. So we use double here.
|
||||
typedef double ptype;
|
||||
const matrix<ptype,0,1>& filt = create_gaussian_filter<ptype>(sigma, max_size);
|
||||
ptype scale = sum(filt);
|
||||
scale = scale*scale;
|
||||
return spatially_filter_image_separable(in_img, out_img, filt, filt, scale);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue