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

Revised slope #140

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions laserchicken/feature_extractor/eigenvals_feature_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def requires(cls):

@classmethod
def provides(cls):
return ['eigenv_1', 'eigenv_2', 'eigenv_3', 'normal_vector_1', 'normal_vector_2', 'normal_vector_3', 'slope']
return ['eigenv_1', 'eigenv_2', 'eigenv_3', 'normal_vector_1', 'normal_vector_2', 'normal_vector_3', 'slope', 'alpha']

@staticmethod
def _get_cov(xyz):
Expand All @@ -29,12 +29,13 @@ def extract(self, sourcepc, neighborhoods, targetpc, targetindex, volume):
xyz_grp = get_xyz(sourcepc, neighborhoods)
self._mask_rows_with_too_few_points(xyz_grp)

#the selected eigenvector need nit be the one corresponding to the samllest eigenvalue as e_vals return is sorted where as the eigvects aren't
e_vals, eigvects = self._get_eigen_vals_and_vects(xyz_grp)
normals = eigvects[:, :, 2] # For all instances, take all elements of the 3th (smallest) vector.(normals, axis=1)
alpha = np.arccos(np.dot(normals, np.array([0., 0., 1.])))
slope = np.tan(alpha)

return e_vals[:, 0], e_vals[:, 1], e_vals[:, 2], normals[:, 0], normals[:, 1], normals[:, 2], slope
return e_vals[:, 0], e_vals[:, 1], e_vals[:, 2], normals[:, 0], normals[:, 1], normals[:, 2], slope, alpha

def _get_eigen_vals_and_vects(self, xyz_grp):
cov_mat = self._get_cov(xyz_grp)
Expand Down