Open3D
Open3D copied to clipboard
Add feature to choose voxel color mode when creating VoxelGrid from PointCloud
Type
- [ ] Bug fix (non-breaking change which fixes an issue): Fixes #
- [X] New feature (non-breaking change which adds functionality). Resolves #6934
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #
Motivation and Context
Creating a VoxelGrid with VoxelGrid.create_from_point_cloud or VoxelGrid.create_from_point_cloud_within_bounds currently always averages the colors of each point per voxel.
This is a sane default, yet might not always be desired, for example for MRI reconstruction as described in the linked issue.
This PR adds the feature of choosing a mode of determining the color per voxel when creating a VoxelGrid:
- avg - average color value (default)
- min - minimum color value for each color channel
- max - maximum color value for each color channel
- sum - accumulated color value
Checklist:
- [X] I have run
python util/check_style.py --applyto apply Open3D code style to my code. - [X] This PR changes Open3D behavior or adds new functionality.
- [X] Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is updated accordingly.
- [X] I have added or updated C++ and / or Python unit tests OR included test results (e.g. screenshots or numbers) here.
- [X] I will follow up and update the code if CI fails.
- [X] For fork PRs, I have selected Allow edits from maintainers.
Description
I've made the following changes:
VoxelGrid.create_from_point_cloudandVoxelGrid.create_from_point_cloud_within_boundstake an additional optional parametercolor_mode, defined by the enumVoxelGrid::VoxelColorMode, which determines the way colors are assigned to voxels (default behaviour is unchanged)- for this, I created the color aggregation helper class
AggColorVoxel. This is basicallyAvgColorVoxel, but with the additional functionality of also being able to return the min, max and sum color value of the voxel (I did not removeAvgColorVoxelto not break existing code. However, it seemed unfitting to add min, max and sum functionality to this class considering its name and description. It's my first feature contribution, so I'm unsure of what to do withAvgColorVoxel, since technically this class could now be deprecated and replaced byAggColorVoxel.) - updated C++ and Python documentation
- added a short sentence to the voxelization tutorial to describe this optional feature
Here are some examples (top left: AVG, top right: MIN, bottom left: MAX, bottom right: SUM):
Check out this pull request on ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB