From 73b08850689899240bc93322acce11e241f48618 Mon Sep 17 00:00:00 2001 From: romulogoncalves Date: Tue, 3 Apr 2018 11:23:48 +0200 Subject: [PATCH] When z_min equal z_max return entropy 0. --- laserchicken/feature_extractor/entropy_feature_extractor.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/laserchicken/feature_extractor/entropy_feature_extractor.py b/laserchicken/feature_extractor/entropy_feature_extractor.py index 8d5ecfa..a3eb5af 100644 --- a/laserchicken/feature_extractor/entropy_feature_extractor.py +++ b/laserchicken/feature_extractor/entropy_feature_extractor.py @@ -31,6 +31,8 @@ def extract(self, source_pc, neighborhood, target_pc, target_index, volume_descr z = source_pc[keys.point]["z"]["data"][neighborhood] _z_min = np.min(z) if self.z_min is None else self.z_min _z_max = np.max(z) if self.z_max is None else self.z_max + if (_z_min == _z_max): + return 0 n_bins = int(np.ceil((_z_max - _z_min) / self.layer_thickness)) data = np.histogram(z, bins=n_bins, range=(_z_min, _z_max), density=True)[0] entropy_func = np.vectorize(_x_log_2x)