I am projecting a 3D Point Cloud on a 2D image incoming as ROS 2 messages. Now, I want to fill the gaps between pixels from the point cloud, so that I can see an area, instead of single pixels and publish the overlay (point cloud + camera) image. I found here a similar question, but unfortunately it hasn't been answered.

What I am trying to achieve is:

before enter image description here

after enter image description here

I tried at first some voronoi diagram, but I haven't succeeded. My Node is written in C++ using OpenCV for image processing.

Does anyone has an idea, how can I achieve it?


2 Answers 2


I managed to achieve better results with cv::dilate.

As far as I tested, I haven't lost any perfomance and it is really easy to implement.


I think that a good approach could be:

Even easier, if you know that your region are always going to be axis aligned rectangles as in the example image:

  • get the min and max of both X and Y coordinates in each point set

  • draw rectangles on the image with rectangle

For both rectangle and drawContours you can specify a negative thickness value to have the shape filled in the specified color.

A minor comment if you have similar doubts in the future: try to post a minimal working example, and possibly make it ROS-independent (e.g. save the projected points in JSON and the image as JPG) to ask for advice also on StackOverflow (or any other forum).

Hope this helps!

  • $\begingroup$ I achieved better results using the cv::dilate function. Thank you for your input anyway. $\endgroup$
    – renan
    Oct 30, 2023 at 10:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.