flatpoints 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- flatpoints-0.1.0/LICENSE +33 -0
- flatpoints-0.1.0/LICENSE-rectangular-conformal-map +201 -0
- flatpoints-0.1.0/MANIFEST.in +8 -0
- flatpoints-0.1.0/Method.md +49 -0
- flatpoints-0.1.0/PKG-INFO +250 -0
- flatpoints-0.1.0/README.md +205 -0
- flatpoints-0.1.0/pyproject.toml +65 -0
- flatpoints-0.1.0/setup.cfg +4 -0
- flatpoints-0.1.0/src/flatpoints/__init__.py +8 -0
- flatpoints-0.1.0/src/flatpoints/compressor.py +139 -0
- flatpoints-0.1.0/src/flatpoints/core.py +36 -0
- flatpoints-0.1.0/src/flatpoints/data/seed.npy +0 -0
- flatpoints-0.1.0/src/flatpoints/datasets.py +100 -0
- flatpoints-0.1.0/src/flatpoints/examples.py +171 -0
- flatpoints-0.1.0/src/flatpoints/main.py +290 -0
- flatpoints-0.1.0/src/flatpoints/mesh.py +172 -0
- flatpoints-0.1.0/src/flatpoints/rcm.py +171 -0
- flatpoints-0.1.0/src/flatpoints/utils.py +143 -0
- flatpoints-0.1.0/src/flatpoints/viz.py +366 -0
- flatpoints-0.1.0/src/flatpoints.egg-info/PKG-INFO +250 -0
- flatpoints-0.1.0/src/flatpoints.egg-info/SOURCES.txt +22 -0
- flatpoints-0.1.0/src/flatpoints.egg-info/dependency_links.txt +1 -0
- flatpoints-0.1.0/src/flatpoints.egg-info/requires.txt +17 -0
- flatpoints-0.1.0/src/flatpoints.egg-info/top_level.txt +1 -0
flatpoints-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Armand de Cacqueray
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
Except src/flatpoints/rcm.py, a modified port of
|
|
24
|
+
https://github.com/garyptchoi/rectangular-conformal-map, Copyright (c) 2015-2024
|
|
25
|
+
Gary Pui-Tung Choi, licensed under the Apache License 2.0
|
|
26
|
+
(see LICENSE-rectangular-conformal-map).
|
|
27
|
+
|
|
28
|
+
src/flatpoints/data/seed.npy is a point cloud of the Hyperuniform samples database
|
|
29
|
+
(https://github.com/For-a-few-DPPs-more/hyperuniform-samplers), by R. Bardenet,
|
|
30
|
+
R. Lachièze-Rey and A. de Cacqueray, MIT License.
|
|
31
|
+
|
|
32
|
+
The example point clouds of data/ (not part of the Python package) are derived from
|
|
33
|
+
third-party models and keep their own terms, see data/README.md.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2020 Gary Pui-Tung Choi
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# sdist: the package, licences and docs only. The example point clouds (data/) are
|
|
2
|
+
# third-party and are downloaded on demand (flatpoints.load), the plots stay on GitHub.
|
|
3
|
+
include README.md Method.md LICENSE LICENSE-rectangular-conformal-map
|
|
4
|
+
include src/flatpoints/data/seed.npy
|
|
5
|
+
prune data
|
|
6
|
+
prune plots
|
|
7
|
+
prune data_compressed
|
|
8
|
+
global-exclude __pycache__ *.py[cod]
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Method
|
|
2
|
+
|
|
3
|
+
flatpoints takes a point cloud sampled on a surface and returns one or two square images: each point of the cloud on its own pixel, neighbour pixels holding neighbour points.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
points ──► mesh, cut into disks ──► map onto a square (conformal) ──► gridify (conformal to equal area) ──► image
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
This is the *geometry image* of Gu, Gortler & Hoppe (2002), with one difference: no
|
|
10
|
+
resampling. The pixels are the input points themselves, so `flat.pixels` gives the exact
|
|
11
|
+
point <-> pixel correspondence.
|
|
12
|
+
|
|
13
|
+
## 1. Mesh and cut
|
|
14
|
+
|
|
15
|
+
A square is a topological disk, so the surface must first be cut into disks, the faces.
|
|
16
|
+
|
|
17
|
+
- **Mesh**: mesh the point cloud using screened Poisson reconstruction (open3d)
|
|
18
|
+
- **Cut**: a closed surface is split into two faces, left and right of the median along
|
|
19
|
+
`normal_axis`; an open surface is a single face. Faces grow triangle by triangle and
|
|
20
|
+
only accept triangles that keep them a disk, so handles and holes are left cut open.
|
|
21
|
+
- **Points**: each point is projected onto the mesh and takes the face of its triangle.
|
|
22
|
+
|
|
23
|
+
## 2. Conformal map
|
|
24
|
+
|
|
25
|
+
Each face is mapped onto the unit square by a rectangular conformal map (Meng, Choi & Lui
|
|
26
|
+
2016). Each point takes the uv_conformal of its projection on the mesh.
|
|
27
|
+
|
|
28
|
+
## 3. Grid
|
|
29
|
+
|
|
30
|
+
The points of each face are sorted onto an n x n grid by their uv_conformal (gridpoints). The resulting one to one matching
|
|
31
|
+
```
|
|
32
|
+
point -> pixel = face, row, column
|
|
33
|
+
```
|
|
34
|
+
is the final output of the flatpoints. Due to the one to one assignement, the flattening is by construction an area preserving transformation.
|
|
35
|
+
|
|
36
|
+
## Limits
|
|
37
|
+
|
|
38
|
+
- **Cuts**: points on either side of a cut are neighbours on the surface but not in the images. This apply to the left / right cut of the single_face = False pipeline, but also on further topological closedness of the surface (e.g. for a torus), which will also be cut.
|
|
39
|
+
- **Tears**: the grid cannot follow the uv exactly, so a few adjacent pixels hold points
|
|
40
|
+
several spacings apart (2.7% beyond 3 spacings on the bunny).
|
|
41
|
+
- **Meshing**: since flatpoints operate on point cloud with unkown surface, the overal precision of the flattening will depend on the quality of the meshing performed by open3d.
|
|
42
|
+
|
|
43
|
+
## References
|
|
44
|
+
|
|
45
|
+
X. Gu, S. J. Gortler and H. Hoppe, "Geometry Images", SIGGRAPH 2002.
|
|
46
|
+
[hhoppe.com/proj/gim](https://hhoppe.com/proj/gim/)
|
|
47
|
+
|
|
48
|
+
T. W. Meng, G. P.-T. Choi and L. M. Lui, "TEMPO: Feature-Endowed Teichmüller Extremal
|
|
49
|
+
Mappings of Point Clouds", SIAM J. Imaging Sciences, 9(4), 2016.
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: flatpoints
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Flatten a point cloud into square images where neighbour pixels are neighbour points
|
|
5
|
+
Author: Armand de Cacqueray
|
|
6
|
+
License-Expression: MIT AND Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/neighborhood-grid/flatpoints
|
|
8
|
+
Project-URL: Source, https://github.com/neighborhood-grid/flatpoints
|
|
9
|
+
Project-URL: Documentation, https://github.com/neighborhood-grid/flatpoints/blob/main/Method.md
|
|
10
|
+
Project-URL: Issues, https://github.com/neighborhood-grid/flatpoints/issues
|
|
11
|
+
Keywords: point cloud,geometry images,surface parameterization,conformal map,mesh,flattening,resampling,compression,3D,computer graphics,geometry processing
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering
|
|
24
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
25
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
26
|
+
Requires-Python: >=3.10
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
License-File: LICENSE-rectangular-conformal-map
|
|
30
|
+
Requires-Dist: numpy
|
|
31
|
+
Requires-Dist: scipy
|
|
32
|
+
Requires-Dist: gridpoints>=1.1
|
|
33
|
+
Requires-Dist: open3d
|
|
34
|
+
Provides-Extra: viz
|
|
35
|
+
Requires-Dist: matplotlib; extra == "viz"
|
|
36
|
+
Requires-Dist: Pillow; extra == "viz"
|
|
37
|
+
Provides-Extra: compress
|
|
38
|
+
Requires-Dist: PyWavelets; extra == "compress"
|
|
39
|
+
Requires-Dist: Pillow; extra == "compress"
|
|
40
|
+
Provides-Extra: all
|
|
41
|
+
Requires-Dist: matplotlib; extra == "all"
|
|
42
|
+
Requires-Dist: PyWavelets; extra == "all"
|
|
43
|
+
Requires-Dist: Pillow; extra == "all"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
# flatpoints
|
|
47
|
+
|
|
48
|
+
[](https://pypi.org/project/flatpoints/)
|
|
49
|
+
[](https://github.com/neighborhood-grid/flatpoints)
|
|
50
|
+
|
|
51
|
+
Turn a 3D point cloud sampled on a latent (unknown) surface into something flat.
|
|
52
|
+
|
|
53
|
+
<table>
|
|
54
|
+
<tr>
|
|
55
|
+
<th>INPUT: raw point cloud</th>
|
|
56
|
+
<th>OUTPUT: flat transformation</th>
|
|
57
|
+
</tr>
|
|
58
|
+
<tr>
|
|
59
|
+
<td><img src="https://raw.githubusercontent.com/neighborhood-grid/flatpoints/main/plots/resampling/bunny_points_plot.png" alt="bunny points"></td>
|
|
60
|
+
<td><img src="https://raw.githubusercontent.com/neighborhood-grid/flatpoints/main/plots/animation/bunny.webp" alt="bunny flat"></td>
|
|
61
|
+
</tr>
|
|
62
|
+
</table>
|
|
63
|
+
|
|
64
|
+
[▶️ bunny 🐇 ](https://raw.githubusercontent.com/neighborhood-grid/flatpoints/main/plots/animation/bunny.webp) \
|
|
65
|
+
[▶️ dragon🐉 ](https://raw.githubusercontent.com/neighborhood-grid/flatpoints/main/plots/animation/dragon.webp) \
|
|
66
|
+
[▶️ elephant 🐘 ](https://raw.githubusercontent.com/neighborhood-grid/flatpoints/main/plots/animation/elephant.webp) \
|
|
67
|
+
|
|
68
|
+
flatpoints takes a raw point cloud `(N, 3)` and arranges its points on a square `(n, n)`
|
|
69
|
+
grid of pixels:
|
|
70
|
+
|
|
71
|
+
- **one pixel per point**: each point gets its own pixel, idx -> (row, column)
|
|
72
|
+
- **neighbour pixels hold neighbour points**: two adjacent pixels hold two points close
|
|
73
|
+
on the surface, so the image is a continuous picture of the surface.
|
|
74
|
+
|
|
75
|
+
Any data attached to the points, `(N, *C)`, then becomes an image `(n, n, *C)`: the xyz
|
|
76
|
+
coordinates, normals, colours, features... and the whole 2D toolbox applies to the point
|
|
77
|
+
cloud: convolutions and CNNs, SVD, grid interpolation…
|
|
78
|
+
|
|
79
|
+
This is the idea of the *geometry images* of [Gu, Gortler & Hoppe (2002)](https://hhoppe.com/proj/gim/),
|
|
80
|
+
which remesh a surface onto a completely regular grid. flatpoints applies it directly to a point cloud.
|
|
81
|
+
How it works: see [Method.md](https://github.com/neighborhood-grid/flatpoints/blob/main/Method.md).
|
|
82
|
+
|
|
83
|
+
## Install
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
pip install flatpoints # core: numpy, scipy, gridpoints, open3d
|
|
87
|
+
pip install "flatpoints[viz]" # + matplotlib, Pillow (plots, animations)
|
|
88
|
+
pip install "flatpoints[compress]" # + PyWavelets, Pillow (compression)
|
|
89
|
+
#or pip install "flatpoints[all]" # (everything)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Quickstart
|
|
93
|
+
|
|
94
|
+
Take a raw 3D point cloud `(N, 3)` and turn it into images.
|
|
95
|
+
Available models: bunny, dragon, elephant, airplane, cow, everest… (`fp.datasets()`)
|
|
96
|
+
|
|
97
|
+
```python
|
|
98
|
+
import flatpoints as fp
|
|
99
|
+
fp.exemple_flat("bunny") # prints the shapes, plots the surface and its images
|
|
100
|
+
fp.exemple_flat("bunny", save="plots", animate=True) # + saves plots/bunny.png and plots/animation/bunny.webp
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Usage
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
import numpy as np
|
|
107
|
+
import flatpoints as fp
|
|
108
|
+
|
|
109
|
+
xyz = fp.load("bunny") #raw (N, 3) points, on a latent (unknown) surface
|
|
110
|
+
z = xyz[:, -1] #(N, *C) any data related to the point cloud, e.g. the z coordinate
|
|
111
|
+
|
|
112
|
+
# ==== Build the flat object ============
|
|
113
|
+
|
|
114
|
+
flat = fp.Flat(xyz) # Apply the flattening processing of the surface
|
|
115
|
+
|
|
116
|
+
# ==== Use it: pixels and images ========
|
|
117
|
+
|
|
118
|
+
i = 42 #point with index 42 (xyz[42])
|
|
119
|
+
face, row, col = flat.pixels[i] # face: 0 or 1 (see the Cut section)
|
|
120
|
+
image_z = flat.to_image(z) # full pixel image, (N, *C) to (1, n, n, *C) or (2, n, n, *C)
|
|
121
|
+
fig = flat.plot() # the surface in 3D and its images
|
|
122
|
+
fig = flat.imshow(z) # plot any data on the images
|
|
123
|
+
anim = flat.imshow(z, animate="z.webp") # animated version
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Cut
|
|
127
|
+
|
|
128
|
+
To map the surface properly to a square, flatpoints need to cut it first in two hemispheres \
|
|
129
|
+
if needed. The hemispheric cut will remove some (not all) topological closedness. Residual \
|
|
130
|
+
closedness (e.g. for a torus, which cannot be opened by a single cut) will also be automatically \
|
|
131
|
+
cut by shearing the surface further on each hemisphere.
|
|
132
|
+
|
|
133
|
+
- Use `fp.Flat(points, single_face=True)` for an open surface (e.g. a terrain), \
|
|
134
|
+
to flatten it on a single image.
|
|
135
|
+
- Use `fp.Flat(points, single_face=False)` for a closed surface (e.g. a dragon), \
|
|
136
|
+
to flatten left and right hemispheres independently, on two images.
|
|
137
|
+
|
|
138
|
+
`normal_axis` (fp.Flat(points, single_face=..., normal_axis = "x")) is the axis the \
|
|
139
|
+
surface is seen along. With `single_face = False` (two hemispheres), the surface is cut \
|
|
140
|
+
roughly across it, so it has a strong impact on the result: choose an axis consistent \
|
|
141
|
+
with your point cloud (e.g. the third axis of a PCA). With `single_face = True` (open \
|
|
142
|
+
surface), it only orients the image (which way is up, where the corners go); the mesh \
|
|
143
|
+
itself is built in 3D, without any projection.
|
|
144
|
+
|
|
145
|
+
See `fp.exemple_flat` ([examples.py](https://github.com/neighborhood-grid/flatpoints/blob/main/src/flatpoints/examples.py)).
|
|
146
|
+
|
|
147
|
+
## Application: resampling a point cloud
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
fp.exemple_sampler("bunny", save="plots") # plots/resampling/bunny_resampled.png
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Sampling from a mesh is easy: sample uniformly on each triangle. Resampling from a point
|
|
154
|
+
cloud is harder, because there is no surface to sample from, only points.
|
|
155
|
+
|
|
156
|
+
The images provide that missing surface: `to_image(xyz)` maps the unit square onto the
|
|
157
|
+
cloud. So one can sample points in the unit square and transport them onto the surface by
|
|
158
|
+
bilinear interpolation of the xyz image, (row, col) → xyz.
|
|
159
|
+
|
|
160
|
+
By default, `flat.resample` uses a hyperuniform 2D seed (blue noise), so the new points are
|
|
161
|
+
fairly evenly spread over the surface.
|
|
162
|
+
|
|
163
|
+
```python
|
|
164
|
+
sampler = flat.resample(n_points=512) # n new points in total
|
|
165
|
+
new = sampler.points # (512, 3)
|
|
166
|
+
sampler.plot() # before / after
|
|
167
|
+
other = flat.resample(n_points=512, seed=1) # a new resampling, with different seed
|
|
168
|
+
```
|
|
169
|
+
**To be honest:** if you only need a subset of the input points, farthest point sampling
|
|
170
|
+
(FPS) are more uniform than flatpoints (figure below), this is mainly an exemple usecase to show how to use the images to transport properties (like good spatial repartition) from the simple unit square to an arbitrary surface.
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
## Application: compressing a point cloud
|
|
176
|
+
|
|
177
|
+
needs PyWavelets and Pillow (`pip install "flatpoints[compress]"`)
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
fp.exemple_compression("bunny", save="plots") # plots/compression/bunny.png
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Since neighbour pixels hold neighbour points, the xyz images are smooth, and smooth images
|
|
184
|
+
compress well. `flat.compress` compresses them with one of three methods
|
|
185
|
+
([compressor.py](https://github.com/neighborhood-grid/flatpoints/blob/main/src/flatpoints/compressor.py)):
|
|
186
|
+
|
|
187
|
+
- `"svd"`: truncated SVD
|
|
188
|
+
- `"dct"`: 2D DCT
|
|
189
|
+
- `"wavelet"`: 2D wavelets
|
|
190
|
+
|
|
191
|
+
`factor` is the fraction of the storage saved against the points in float32 (96 bits per
|
|
192
|
+
point).
|
|
193
|
+
|
|
194
|
+
```python
|
|
195
|
+
comp = flat.compress(factor=0.8) # save 80% of the storage, best method
|
|
196
|
+
comp.method # "dct"
|
|
197
|
+
comp.code # what is stored, e.g. quantized DCT coefficients and step
|
|
198
|
+
comp.points # (N, 3) reconstructed points, in the input order
|
|
199
|
+
flat.compress(0.8, method="svd") # a given method
|
|
200
|
+
comp.save("compressed.jp2") #save the compressed structure
|
|
201
|
+
points = fp.Compressor.read("compressed.jp2") #reconstructed (N, 3) point cloud
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+

|
|
205
|
+
|
|
206
|
+
## Licence
|
|
207
|
+
|
|
208
|
+
- code: MIT, except `src/flatpoints/rcm.py`.
|
|
209
|
+
- `src/flatpoints/rcm.py`: Python port (modified) of
|
|
210
|
+
[garyptchoi/rectangular-conformal-map](https://github.com/garyptchoi/rectangular-conformal-map),
|
|
211
|
+
Copyright (c) 2015-2024 Gary Pui-Tung Choi, Apache License 2.0, see
|
|
212
|
+
[LICENSE-rectangular-conformal-map](https://github.com/neighborhood-grid/flatpoints/blob/main/LICENSE-rectangular-conformal-map).
|
|
213
|
+
- `src/flatpoints/data/seed.npy` (shipped in the package): hyperuniform point cloud from the
|
|
214
|
+
[Hyperuniform samples database](https://github.com/For-a-few-DPPs-more/hyperuniform-samplers),
|
|
215
|
+
MIT licence.
|
|
216
|
+
- example point clouds (`data/`, downloaded by `fp.load`, not shipped in the package):
|
|
217
|
+
third-party models, each under its own terms (some research / non-commercial only), see
|
|
218
|
+
[data/README.md](https://github.com/neighborhood-grid/flatpoints/blob/main/data/README.md).
|
|
219
|
+
|
|
220
|
+
## Acknowledgement
|
|
221
|
+
|
|
222
|
+
The concept of a surface stored as a square image comes from the geometry images:
|
|
223
|
+
|
|
224
|
+
```bibtex
|
|
225
|
+
@article{gu2002geometry,
|
|
226
|
+
title = {Geometry Images},
|
|
227
|
+
author = {Gu, Xianfeng and Gortler, Steven J. and Hoppe, Hugues},
|
|
228
|
+
journal = {ACM Transactions on Graphics (SIGGRAPH)},
|
|
229
|
+
volume = {21},
|
|
230
|
+
number = {3},
|
|
231
|
+
pages = {355--361},
|
|
232
|
+
year = {2002},
|
|
233
|
+
doi = {10.1145/566654.566589}
|
|
234
|
+
}
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
The images rely on the rectangular conformal map of:
|
|
238
|
+
|
|
239
|
+
```bibtex
|
|
240
|
+
@article{meng2016tempo,
|
|
241
|
+
title = {{TEMPO}: Feature-Endowed {T}eichm{\"u}ller Extremal Mappings of Point Clouds},
|
|
242
|
+
author = {Meng, Ting Wei and Choi, Gary Pui-Tung and Lui, Lok Ming},
|
|
243
|
+
journal = {SIAM Journal on Imaging Sciences},
|
|
244
|
+
volume = {9},
|
|
245
|
+
number = {4},
|
|
246
|
+
pages = {1922--1962},
|
|
247
|
+
year = {2016},
|
|
248
|
+
doi = {10.1137/15M1049117}
|
|
249
|
+
}
|
|
250
|
+
```
|