# How to filter rain and fog

**URL:** <https://community.ouster.com/t/how-to-filter-rain-and-fog/157>\
**Category:** Software\
**Tags:** ros\
**Created:** [July 31, 2024, 8:35am UTC](https://community.ouster.com/t/how-to-filter-rain-and-fog/157 "2024-07-31T08:35:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![deep\_reflexio](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@deep\_reflexio](https://community.ouster.com/u/deep_reflexio)\
**Post date:** [July 31, 2024, 8:35am UTC](https://community.ouster.com/t/how-to-filter-rain-and-fog/157/1 "2024-07-31T08:35:05Z")

</div>

Hello,

I am currently using the ouster in my algo for plane detection. I am facing a problem because of my application. I am trying to fix the ouster on a spraying drone, the problem is: when I activate the plane detection at the same time as my spraying, it happens that my algo detects the plane on the spray cloud instead of detecting it on a target surface for example, something that I would like to avoid.

My question is the following. Do you have any solutions that can be used via ROS that I could implement in my algo concerning the filtering of spray clouds, rain or fog?

I am open to any other proposals that could solve my problem.

---

<div class="post-metadata">

**Author:** ![Samahu](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.ouster.com/samahu/32/39_2.png) [@Samahu](https://community.ouster.com/u/Samahu)\
**Post date:** [August 1, 2024, 5:09pm UTC](https://community.ouster.com/t/how-to-filter-rain-and-fog/157/2 "2024-08-01T17:09:23Z")

</div>

> [@deep\_reflexio](#):
>
> instead of detecting it on a target surface for example, something that I would like to avoid.

Hi @deep_reflexio , you can refer to this [thread](https://github.com/ouster-lidar/ouster-ros/issues/248) for some leads on the topic. The simplest approach would be to implement a threshold based on intensity/reflectivity since fog and rain have lower intensity values than regular surfaces.

A [StatisticalOutlierFilter](https://pcl.readthedocs.io/projects/tutorials/en/latest/statistical_outlier.html) could potentially help in this area. For an example on how to use it along with the ros-driver (using python) refer to [ouster-ros-extras/scripts/ros2\_pcl\_filters.py at ros2 · ouster-lidar/ouster-ros-extras · GitHub](https://github.com/ouster-lidar/ouster-ros-extras/blob/ros2/scripts/ros2_pcl_filters.py)

There is definitely more advanced techniques that involve fusing the signal from multiple sensors or building a deep learning model that act as a filter for water droplets that you can also check.

Hope this helps

---

<div class="post-metadata">

**Author:** ![Samahu](https://yyz2.discourse-cdn.com/flex004/user_avatar/community.ouster.com/samahu/32/39_2.png) [@Samahu](https://community.ouster.com/u/Samahu)\
**Post date:** [August 1, 2024, 5:48pm UTC](https://community.ouster.com/t/how-to-filter-rain-and-fog/157/3 "2024-08-01T17:48:57Z")

</div>

also consider filtering points closest to the sensor using a spatial filter since this is where rain droplets have the largest impact.

---

<div class="post-metadata">

**Author:** ![deep\_reflexio](https://avatars.discourse-cdn.com/v4/letter/d/ed655f/32.png) [@deep\_reflexio](https://community.ouster.com/u/deep_reflexio)\
**Post date:** [August 29, 2024, 8:43am UTC](https://community.ouster.com/t/how-to-filter-rain-and-fog/157/4 "2024-08-29T08:43:14Z")

</div>

Hi @Samahu thanks for your reply. I have used the StatisticalOutlierFilter as you mentioned it and it perfectly works. Thank you for your help really appreciate it.
