-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #149 from eEcoLiDAR/feature_148_intensity
Feature 148 intensity
- Loading branch information
Showing
46 changed files
with
607 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
laserchicken/feature_extractor/density_absolute_mean_norm_z_feature_extractor.py
This file was deleted.
Oops, something went wrong.
47 changes: 47 additions & 0 deletions
47
laserchicken/feature_extractor/entropy_feature_extractor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Shannan entropy calculation. For more info see https://rdrr.io/cran/lidR/man/entropy.html""" | ||
|
||
import numpy as np | ||
from laserchicken import keys | ||
from laserchicken.feature_extractor.base_feature_extractor import FeatureExtractor | ||
|
||
|
||
class EntropyFeatureExtractor(FeatureExtractor): | ||
layer_thickness = 0.5 | ||
min_val = None | ||
max_val = None | ||
|
||
def __init__(self, data_key='z'): | ||
self.data_key = data_key | ||
|
||
@classmethod | ||
def requires(cls): | ||
return [] | ||
|
||
def provides(self): | ||
return ['entropy_' + self.data_key] | ||
|
||
def get_params(self): | ||
p = [self.layer_thickness] | ||
if self.min_val is not None: | ||
p.append(self.min_val) | ||
if self.max_val is not None: | ||
p.append(self.max_val) | ||
return p | ||
|
||
def extract(self, source_pc, neighborhood, target_pc, target_index, volume_description): | ||
if len(neighborhood) == 0: | ||
return 0 | ||
source_data = source_pc[keys.point][self.data_key]["data"][neighborhood] | ||
data_min = np.min(source_data) if self.min_val is None else self.min_val | ||
data_max = np.max(source_data) if self.max_val is None else self.max_val | ||
if data_min == data_max: | ||
return 0 | ||
n_bins = int(np.ceil((data_max - data_min) / self.layer_thickness)) | ||
data = np.histogram(source_data, bins=n_bins, range=(data_min, data_max), density=True)[0] | ||
entropy_func = np.vectorize(_x_log_2x) | ||
norm = np.sum(data) | ||
return -(entropy_func(data / norm)).sum() | ||
|
||
|
||
def _x_log_2x(x): | ||
return 0 if x == 0 else x * np.log2(x) |
12 changes: 0 additions & 12 deletions
12
laserchicken/feature_extractor/entropy_norm_z_feature_extractor.py
This file was deleted.
Oops, something went wrong.
48 changes: 0 additions & 48 deletions
48
laserchicken/feature_extractor/entropy_z_feature_extractor.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 26 additions & 26 deletions
52
...extractor/kurtosis_z_feature_extractor.py → ...e_extractor/kurtosis_feature_extractor.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import numpy as np | ||
import scipy.stats.stats as stat | ||
|
||
from laserchicken.feature_extractor.base_feature_extractor import FeatureExtractor | ||
from laserchicken.keys import point | ||
|
||
|
||
class KurtosisZFeatureExtractor(FeatureExtractor): | ||
"""Calculates the variation on the z axis.""" | ||
DATA_KEY = 'z' | ||
|
||
@classmethod | ||
def requires(cls): | ||
return [] | ||
|
||
@classmethod | ||
def provides(cls): | ||
return ['kurto_z'] | ||
|
||
def extract(self, sourcepc, neighborhood, targetpc, targetindex, volume_description): | ||
if neighborhood: | ||
z = sourcepc[point][self.DATA_KEY]['data'][neighborhood] | ||
kurtosis_z = stat.kurtosis(z) | ||
else: | ||
kurtosis_z = np.NaN | ||
return kurtosis_z | ||
import numpy as np | ||
import scipy.stats.stats as stat | ||
|
||
from laserchicken.feature_extractor.base_feature_extractor import FeatureExtractor | ||
from laserchicken.keys import point | ||
|
||
|
||
class KurtosisFeatureExtractor(FeatureExtractor): | ||
"""Calculates the variation on the z axis.""" | ||
def __init__(self, data_key='z'): | ||
self.data_key = data_key | ||
|
||
@classmethod | ||
def requires(cls): | ||
return [] | ||
|
||
def provides(self): | ||
return ['kurto_' + self.data_key] | ||
|
||
def extract(self, sourcepc, neighborhood, targetpc, targetindex, volume_description): | ||
if neighborhood: | ||
z = sourcepc[point][self.data_key]['data'][neighborhood] | ||
kurtosis_z = stat.kurtosis(z) | ||
else: | ||
kurtosis_z = np.NaN | ||
return kurtosis_z |
11 changes: 0 additions & 11 deletions
11
laserchicken/feature_extractor/kurtosis_norm_z_feature_extractor.py
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.