Skip to content
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 select_by_index method to Feature class #7039

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nicolaloi
Copy link
Contributor

@nicolaloi nicolaloi commented Nov 2, 2024

Type

Motivation and Context

Allow the creation of a new Feature instance with selected features from the current Feature instance, similar to PointCloud::SelectByIndex.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Description

Add a select_by_index method to the Feature class, similar to PointCloud::SelectByIndex and TriangleMesh::SelectByIndex.

No modifications for the tensor module, since it doesn't have a Feature class (functions like ComputeFPFHFeatures are working directly with core::Tensors).

Testing

I have added a unit test.
The following is an extra script for local testing:

import open3d as o3d
import numpy as np

ply_point_cloud = o3d.data.DemoCropPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.point_cloud_path)

fpfh_features = o3d.pipelines.registration.compute_fpfh_feature(
    pcd, o3d.geometry.KDTreeSearchParamHybrid(radius=0.25, max_nn=20))

n_select = 100
selected_indexes = np.random.choice(fpfh_features.num(), n_select, replace=False)
selected_fpfh_features = fpfh_features.select_by_index(selected_indexes)

assert selected_fpfh_features.num() == n_select

np_fpfh_features = np.asarray(fpfh_features.data)

# assert that the selected features are indeed the same as the ones we selected with numpy
assert np.allclose(np_fpfh_features[:, sorted(selected_indexes)], np.asarray(selected_fpfh_features.data))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"select_by_index" to work with the class "open3d.pipelines.registration.Feature"
1 participant