# cv::bilateralFilter assertion fails with 3-channel float

**URL:** <https://forum.opencv.org/t/cv-bilateralfilter-assertion-fails-with-3-channel-float/8176>\
**Category:** C++\
**Tags:** imgproc\
**Created:** [March 29, 2022, 11:20pm UTC](https://forum.opencv.org/t/cv-bilateralfilter-assertion-fails-with-3-channel-float/8176 "2022-03-29T23:20:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![h\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/h_c/32/4854_2.png) [@h\_c](https://forum.opencv.org/u/h_c)\
**Post date:** [March 29, 2022, 11:20pm UTC](https://forum.opencv.org/t/cv-bilateralfilter-assertion-fails-with-3-channel-float/8176/1 "2022-03-29T23:20:24Z")

</div>

Hi all! Really hoping to get some help with this issue.

I have an image cv::Mat that contains a 3-channel floating point image buffer and I’d like to run cv::bilateralFilter, however I’m getting an issue with a debug assertion in `bilateral_filter.simd.hpp ` line 993

```auto
CV_DbgAssert(fabs(wsum(j) >= 0);

```

I can’t figure out why this assertion is failing, especially since presumably it checks if the absolute value of a float is \>0?

I’d really like to use bilateralFilter here, especially since most of the other filter types (median, etc…) require 8-bit images but we are trying to preserve as much data integrity as possible at this stage.

If you have any advice it would be greatly appreciated!!!

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [March 30, 2022, 6:18am UTC](https://forum.opencv.org/t/cv-bilateralfilter-assertion-fails-with-3-channel-float/8176/2 "2022-03-30T06:18:35Z")

</div>

related: [c++ - OpenCV 4.5 Error: Assertion failed (fabs(wsum[j]) \>= 0) in cv::opt\_AVX2::`anonymous-namespace'::BilateralFilter\_32f\_Invoker::operator - Stack Overflow](https://stackoverflow.com/questions/71655588/opencv-4-5-error-assertion-failed-fabswsumj-0-in-cvopt-avx2anonym)

---

<div class="post-metadata">

**Author:** ![h\_c](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/h_c/32/4854_2.png) [@h\_c](https://forum.opencv.org/u/h_c)\
**Post date:** [March 30, 2022, 8:41pm UTC](https://forum.opencv.org/t/cv-bilateralfilter-assertion-fails-with-3-channel-float/8176/3 "2022-03-30T20:41:19Z")

</div>

Update from the team for posterity:

Some of the float values in our image matrix were nan’s after being divided by inf in another image processing steps. fabs(nan) is not greater than 0. It sounds like they will be able to solve the rest of the problems from there
