-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add feature to choose voxel color mode when creating VoxelGrid from PointCloud #6937
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
cpp/open3d/geometry/VoxelGrid.h
Outdated
/// \enum VoxelColorMode | ||
/// | ||
/// \brief Possible ways of determining voxel color from PointCloud. | ||
enum class VoxelColorMode { AVG, MIN, MAX, SUM }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible nitpick: can we call this "VoxelPoolingMode" or "VoxelPoolingMethod" instead of "VoxelColorMode"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback! I'd tend to agree that "VoxelPoolingMode" is probably the better name, but I'll wait until a maintainer has had the chance to review the PR to get their feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rxba Thanks for this feature contribution! It looks very useful.
@IDoCodingStuffs I agree, "VoxelPoolingMode" it is
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):