Add feature to choose voxel color mode when creating VoxelGrid from PointCloud #6937
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type
VoxelGrid.create_from_point_cloud
should allow for choosing color reduction method other than avg #6934Motivation and Context
Creating a VoxelGrid with
VoxelGrid.create_from_point_cloud
orVoxelGrid.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:
Checklist:
python util/check_style.py --apply
to apply Open3D code styleto my code.
updated accordingly.
results (e.g. screenshots or numbers) here.
Description
I've made the following changes:
VoxelGrid.create_from_point_cloud
andVoxelGrid.create_from_point_cloud_within_bounds
take an additional optional parametercolor_mode
, defined by the enumVoxelGrid::VoxelColorMode
, which determines the way colors are assigned to voxels (default behaviour is unchanged)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 removeAvgColorVoxel
to 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
.)Here are some examples (top left: AVG, top right: MIN, bottom left: MAX, bottom right: SUM):