or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

complex-construction.mdcubical-complexes.mdindex.mdpersistent-homology.mdpoint-cloud.mdrepresentations.mdwitness-complexes.md

point-cloud.mddocs/

0

# Point Cloud Processing

1

2

Specialized tools for analyzing and processing point clouds including distance-to-measure computations, subsampling algorithms, nearest neighbor queries, and time delay embedding for time series data.

3

4

## Capabilities

5

6

### Distance to Measure

7

8

Robust distance computation that provides outlier-resistant alternatives to standard distance functions by computing distances to empirical measures.

9

10

```python { .api }

11

class DistanceToMeasure:

12

def __init__(self, k: int, q: float = 2.0):

13

"""

14

Initialize Distance to Measure estimator.

15

16

Parameters:

17

- k: Number of neighbors for distance computation

18

- q: Power parameter for Lq norm

19

"""

20

21

def fit_transform(self, X):

22

"""

23

Compute distance to measure for point cloud.

24

25

Parameters:

26

- X: Point cloud as array-like

27

28

Returns:

29

array: DTM values for each point

30

"""

31

32

def compute_distance_to_measure(self, X):

33

"""

34

Compute DTM values.

35

36

Parameters:

37

- X: Input point cloud

38

39

Returns:

40

array: Distance to measure values

41

"""

42

```

43

44

### K-Nearest Neighbors

45

46

Efficient nearest neighbor queries for point clouds with support for various distance metrics.

47

48

```python { .api }

49

class KNearestNeighbors:

50

def __init__(self, k: int, metric: str = "euclidean"):

51

"""

52

Initialize k-nearest neighbors estimator.

53

54

Parameters:

55

- k: Number of neighbors

56

- metric: Distance metric ("euclidean", "manhattan", etc.)

57

"""

58

59

def fit(self, X):

60

"""

61

Fit the estimator to point cloud.

62

63

Parameters:

64

- X: Training point cloud

65

"""

66

67

def transform(self, X):

68

"""

69

Find k-nearest neighbors.

70

71

Parameters:

72

- X: Query points

73

74

Returns:

75

tuple: (distances, indices) of k-nearest neighbors

76

"""

77

```

78

79

### Time Delay Embedding

80

81

Transforms time series data into point clouds using time delay embedding for topological analysis of dynamical systems.

82

83

```python { .api }

84

class TimeDelayEmbedding:

85

def __init__(self, dim: int = 3, delay: int = 1, skip: int = 1):

86

"""

87

Initialize time delay embedding.

88

89

Parameters:

90

- dim: Embedding dimension

91

- delay: Time delay between coordinates

92

- skip: Subsampling parameter

93

"""

94

95

def fit_transform(self, X):

96

"""

97

Transform time series to embedded point cloud.

98

99

Parameters:

100

- X: Time series data

101

102

Returns:

103

array: Embedded point cloud

104

"""

105

```

106

107

### Subsampling Functions

108

109

Algorithms for reducing point cloud size while preserving topological and geometric properties.

110

111

```python { .api }

112

def choose_n_farthest_points(points, nb_points: int, starting_point: int = None):

113

"""

114

Farthest point sampling for point cloud subsampling.

115

116

Parameters:

117

- points: Input point cloud

118

- nb_points: Number of points to select

119

- starting_point: Index of starting point (random if None)

120

121

Returns:

122

list: Indices of selected points

123

"""

124

125

def pick_n_random_points(points, nb_points: int):

126

"""

127

Random subsampling of point cloud.

128

129

Parameters:

130

- points: Input point cloud

131

- nb_points: Number of points to select

132

133

Returns:

134

list: Indices of randomly selected points

135

"""

136

137

def sparsify_point_set(points, min_squared_distance: float):

138

"""

139

Sparsify point cloud by minimum distance constraint.

140

141

Parameters:

142

- points: Input point cloud

143

- min_squared_distance: Minimum squared distance between points

144

145

Returns:

146

list: Indices of points in sparsified set

147

"""

148

```

149

150

## Usage Examples

151

152

### Distance to Measure Computation

153

154

```python

155

import gudhi

156

import numpy as np

157

158

# Generate noisy point cloud

159

points = np.random.random((100, 2))

160

# Add some outliers

161

outliers = np.random.random((10, 2)) * 5

162

noisy_points = np.vstack([points, outliers])

163

164

# Compute distance to measure

165

dtm = gudhi.point_cloud.DistanceToMeasure(k=10)

166

dtm_values = dtm.fit_transform(noisy_points)

167

168

print(f"DTM values shape: {dtm_values.shape}")

169

```

170

171

### Farthest Point Sampling

172

173

```python

174

import gudhi

175

import numpy as np

176

177

# Generate dense point cloud

178

points = np.random.random((1000, 3))

179

180

# Subsample using farthest point sampling

181

subsampled_indices = gudhi.choose_n_farthest_points(points, 100)

182

subsampled_points = points[subsampled_indices]

183

184

print(f"Original: {len(points)} points, Subsampled: {len(subsampled_points)} points")

185

```

186

187

### Time Delay Embedding

188

189

```python

190

import gudhi

191

import numpy as np

192

193

# Generate time series (sine wave with noise)

194

t = np.linspace(0, 4*np.pi, 1000)

195

time_series = np.sin(t) + 0.1 * np.random.randn(1000)

196

197

# Create time delay embedding

198

embedding = gudhi.point_cloud.TimeDelayEmbedding(dim=3, delay=10)

199

embedded_points = embedding.fit_transform(time_series)

200

201

print(f"Time series length: {len(time_series)}")

202

print(f"Embedded point cloud shape: {embedded_points.shape}")

203

204

# Analyze topology of embedded attractor

205

rips = gudhi.RipsComplex(points=embedded_points, max_edge_length=0.5)

206

st = rips.create_simplex_tree(max_dimension=1)

207

persistence = st.persistence()

208

```

209

210

### K-Nearest Neighbors

211

212

```python

213

import gudhi

214

import numpy as np

215

216

# Generate point cloud

217

points = np.random.random((200, 2))

218

219

# Find k-nearest neighbors

220

knn = gudhi.point_cloud.KNearestNeighbors(k=5)

221

knn.fit(points)

222

223

# Query neighbors for subset of points

224

query_points = points[:10]

225

distances, indices = knn.transform(query_points)

226

227

print(f"Distances shape: {distances.shape}")

228

print(f"Indices shape: {indices.shape}")

229

```