sem2surface 0.2.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.
- sem2surface-0.2.0/LICENSE +30 -0
- sem2surface-0.2.0/PKG-INFO +306 -0
- sem2surface-0.2.0/README.md +267 -0
- sem2surface-0.2.0/pyproject.toml +60 -0
- sem2surface-0.2.0/setup.cfg +4 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/PKG-INFO +306 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/SOURCES.txt +17 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/dependency_links.txt +1 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/entry_points.txt +5 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/requires.txt +13 -0
- sem2surface-0.2.0/src/sem2surface.egg-info/top_level.txt +3 -0
- sem2surface-0.2.0/src/sem2surface.py +724 -0
- sem2surface-0.2.0/src/sem2surface_cli.py +108 -0
- sem2surface-0.2.0/src/sem2surface_gui.py +473 -0
- sem2surface-0.2.0/tests/test_cli.py +18 -0
- sem2surface-0.2.0/tests/test_core.py +60 -0
- sem2surface-0.2.0/tests/test_fft.py +55 -0
- sem2surface-0.2.0/tests/test_gui_preview.py +24 -0
- sem2surface-0.2.0/tests/test_reference_example.py +38 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-2026, Vladislav A. Yastrebov
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
10
|
+
this list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
23
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
|
24
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
25
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
26
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
27
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
28
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
29
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
30
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sem2surface
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: 3D surface reconstruction from multi-detector SEM/BSE images
|
|
5
|
+
Author: Vladislav A. Yastrebov
|
|
6
|
+
License-Expression: BSD-3-Clause
|
|
7
|
+
Project-URL: Homepage, https://github.com/vyastreb/sem2surface
|
|
8
|
+
Project-URL: Repository, https://github.com/vyastreb/sem2surface
|
|
9
|
+
Project-URL: Issues, https://github.com/vyastreb/sem2surface/issues
|
|
10
|
+
Keywords: SEM,BSE,surface reconstruction,metrology,microscopy
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Environment :: X11 Applications
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Operating System :: MacOS
|
|
16
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
17
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Topic :: Scientific/Engineering :: Image Processing
|
|
24
|
+
Requires-Python: >=3.10
|
|
25
|
+
Description-Content-Type: text/markdown
|
|
26
|
+
License-File: LICENSE
|
|
27
|
+
Requires-Dist: numpy>=1.23
|
|
28
|
+
Requires-Dist: matplotlib>=3.7
|
|
29
|
+
Requires-Dist: scipy>=1.10
|
|
30
|
+
Requires-Dist: scikit-image>=0.21
|
|
31
|
+
Requires-Dist: pillow>=9.0
|
|
32
|
+
Provides-Extra: vtk
|
|
33
|
+
Requires-Dist: vtk>=9.2; extra == "vtk"
|
|
34
|
+
Provides-Extra: test
|
|
35
|
+
Requires-Dist: build>=1.2; extra == "test"
|
|
36
|
+
Requires-Dist: pytest>=8; extra == "test"
|
|
37
|
+
Requires-Dist: twine>=5; extra == "test"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# sem2surface
|
|
41
|
+
|
|
42
|
+
`sem2surface` reconstructs a three-dimensional surface from three to five
|
|
43
|
+
multi-detector SEM/BSE images. It extracts two normalized principal images,
|
|
44
|
+
identifies their orientation with a Radon transform, and integrates the resulting
|
|
45
|
+
gradients using the Frankot-Chellappa FFT method.
|
|
46
|
+
|
|
47
|
+
<!-- PyPI cannot resolve repository-relative images. Keep this absolute URL. -->
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
The reconstruction can be used qualitatively with an arbitrary vertical scale.
|
|
51
|
+
Quantitative measurements require a calibrated Z scaling factor for the imaging
|
|
52
|
+
configuration. The included Vickers-indentation example demonstrates that
|
|
53
|
+
calibration procedure.
|
|
54
|
+
|
|
55
|
+
## Installation
|
|
56
|
+
|
|
57
|
+
Python 3.10 or newer is required. An isolated virtual environment is strongly
|
|
58
|
+
recommended so the application does not conflict with system Python packages.
|
|
59
|
+
|
|
60
|
+
### Linux and macOS
|
|
61
|
+
|
|
62
|
+
Create an environment and install a released version:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python3 -m venv .venv
|
|
66
|
+
source .venv/bin/activate
|
|
67
|
+
python -m pip install --upgrade pip
|
|
68
|
+
python -m pip install sem2surface
|
|
69
|
+
sem2surface-gui
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Until a release is uploaded to PyPI, run the final installation command from
|
|
73
|
+
this source checkout instead:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
python -m pip install .
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
On Linux, Tkinter may be packaged separately. For example, Ubuntu and Debian
|
|
80
|
+
users can install it with their system package manager as `python3-tk` before
|
|
81
|
+
creating the environment.
|
|
82
|
+
|
|
83
|
+
### Windows
|
|
84
|
+
|
|
85
|
+
Install Python 3.10 or newer from
|
|
86
|
+
[python.org](https://www.python.org/downloads/windows/). Keep the standard
|
|
87
|
+
`pip`, Tcl/Tk, and Python Launcher components enabled. Then open PowerShell in
|
|
88
|
+
the folder where you want the environment and run:
|
|
89
|
+
|
|
90
|
+
```powershell
|
|
91
|
+
py -3 -m venv .venv
|
|
92
|
+
.\.venv\Scripts\Activate.ps1
|
|
93
|
+
python -m pip install --upgrade pip
|
|
94
|
+
python -m pip install sem2surface
|
|
95
|
+
sem2surface-gui
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If PowerShell blocks the activation script, allow it only for the current
|
|
99
|
+
PowerShell process and retry activation:
|
|
100
|
+
|
|
101
|
+
```powershell
|
|
102
|
+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
103
|
+
.\.venv\Scripts\Activate.ps1
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
In Command Prompt, activate the same environment with:
|
|
107
|
+
|
|
108
|
+
```bat
|
|
109
|
+
.venv\Scripts\activate.bat
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Activation is optional. The GUI can always be launched directly:
|
|
113
|
+
|
|
114
|
+
```powershell
|
|
115
|
+
.\.venv\Scripts\sem2surface-gui.exe
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Before the PyPI release, install either from a source checkout with
|
|
119
|
+
`python -m pip install .` or from the provided wheel:
|
|
120
|
+
|
|
121
|
+
```powershell
|
|
122
|
+
python -m pip install "C:\path\to\sem2surface-0.2.0-py3-none-any.whl"
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Use `deactivate` to leave the environment on any platform. Do not copy a
|
|
126
|
+
virtual environment between computers or move it after creation; create a new
|
|
127
|
+
one and reinstall the package instead.
|
|
128
|
+
|
|
129
|
+
VTK export is optional because VTK is a large dependency:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
python -m pip install "sem2surface[vtk]"
|
|
133
|
+
# From this source checkout instead: python -m pip install ".[vtk]"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The application does not require ImageMagick or a LaTeX installation. Tkinter is
|
|
137
|
+
included with the standard Python installers on Windows and macOS.
|
|
138
|
+
|
|
139
|
+
## Desktop application
|
|
140
|
+
|
|
141
|
+
After installation, launch the graphical interface from a terminal:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
sem2surface-gui
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Select three to five detector images, confirm the pixel size and scaling factor,
|
|
148
|
+
choose an output directory, and start the reconstruction. TIFF, PNG, JPEG, and
|
|
149
|
+
BMP images are supported. The work runs in the background so the window remains
|
|
150
|
+
responsive.
|
|
151
|
+
|
|
152
|
+
The GUI intentionally provides only the FFT reconstruction. Atomic-number
|
|
153
|
+
correction and direct profile integration have been removed.
|
|
154
|
+
|
|
155
|
+
## Command line
|
|
156
|
+
|
|
157
|
+
Installation also provides a `sem2surface` executable:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
sem2surface detector_A.tif detector_B.tif detector_C.tif \
|
|
161
|
+
--z-scale 217.27243 \
|
|
162
|
+
--save npz \
|
|
163
|
+
--output-dir results
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Pixel size is read from the first TIFF by default. For images without compatible
|
|
167
|
+
SEM metadata, provide it in micrometres:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
sem2surface detector_A.png detector_B.png detector_C.png \
|
|
171
|
+
--pixel-size-um 0.325521 \
|
|
172
|
+
--curvature none
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Run `sem2surface --help` for the complete list of options. VTK output requires
|
|
176
|
+
the optional `vtk` installation described above.
|
|
177
|
+
|
|
178
|
+
## Python API
|
|
179
|
+
|
|
180
|
+
```python
|
|
181
|
+
from pathlib import Path
|
|
182
|
+
|
|
183
|
+
from sem2surface import construct_surface
|
|
184
|
+
|
|
185
|
+
images = [Path("detector_A.tif"), Path("detector_B.tif"), Path("detector_C.tif")]
|
|
186
|
+
preview, X, Y, Z, warning = construct_surface(
|
|
187
|
+
images,
|
|
188
|
+
z_scaling_factor_per_pixel=217.27243,
|
|
189
|
+
remove_curvature=True,
|
|
190
|
+
save_file_type="NPZ",
|
|
191
|
+
output_dir="results",
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Pixel size and manual curvature radii use metres in the Python API. Returned
|
|
196
|
+
coordinate and height arrays use micrometres. The old `constructSurface`
|
|
197
|
+
function remains as a compatibility wrapper for version 0.1 scripts, but only
|
|
198
|
+
FFT reconstruction is accepted and the old atomic-number arguments are ignored.
|
|
199
|
+
|
|
200
|
+
## Outputs
|
|
201
|
+
|
|
202
|
+
Every reconstruction creates:
|
|
203
|
+
|
|
204
|
+
- a colour PNG of the reconstructed surface;
|
|
205
|
+
- a grayscale PNG suitable for further image analysis;
|
|
206
|
+
- a UTF-8 log containing parameters, input names, angles, and surface RMS.
|
|
207
|
+
|
|
208
|
+
Surface arrays can additionally be saved as CSV, compressed NumPy NPZ, or VTK
|
|
209
|
+
structured-grid data. Optional diagnostic output includes the detector/PCA
|
|
210
|
+
decomposition, Radon search, and oriented gradients.
|
|
211
|
+
|
|
212
|
+
When timestamps are disabled, an existing output with the same name is replaced.
|
|
213
|
+
Choose a dedicated output folder or enable timestamps when results must be kept.
|
|
214
|
+
|
|
215
|
+
## Reference examples and scaling
|
|
216
|
+
|
|
217
|
+
The [examples directory](https://github.com/vyastreb/sem2surface/tree/master/examples)
|
|
218
|
+
contains the reference analyses:
|
|
219
|
+
|
|
220
|
+
- `Surface_1` and `Surface_2`: representative reconstructed surfaces;
|
|
221
|
+
- `Vickers_imprint`: reconstruction of a Vickers indentation;
|
|
222
|
+
- `Vickers_imprint_scaling`: identification of the Z scaling factor from the
|
|
223
|
+
known Vickers geometry.
|
|
224
|
+
|
|
225
|
+
After installing the package with the VTK extra, an example can be run from any
|
|
226
|
+
working directory:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
python examples/Surface_1/test_without_gui.py
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
<!-- PyPI cannot resolve repository-relative images. Keep this absolute URL. -->
|
|
233
|
+

|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
Create an isolated environment and install the editable project with its test
|
|
238
|
+
tools:
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
python -m venv .venv
|
|
242
|
+
source .venv/bin/activate
|
|
243
|
+
python -m pip install -e ".[test]"
|
|
244
|
+
python -m pytest
|
|
245
|
+
python -m build
|
|
246
|
+
python -m twine check dist/*
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
Continuous integration tests Python 3.10 and 3.13 on Linux, Windows, and macOS,
|
|
250
|
+
and verifies both the source distribution and universal wheel.
|
|
251
|
+
|
|
252
|
+
### Maintainer release checklist
|
|
253
|
+
|
|
254
|
+
Use a clean virtual environment and update the version in both
|
|
255
|
+
`pyproject.toml` and `src/sem2surface.py`. PyPI does not allow an uploaded file
|
|
256
|
+
or release version to be replaced.
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
python -m pytest -q
|
|
260
|
+
python -m build
|
|
261
|
+
python -m twine check dist/*
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
For a first trial, create a separate account and API token on
|
|
265
|
+
[TestPyPI](https://test.pypi.org/), then upload only the files for the new
|
|
266
|
+
version:
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
python -m twine upload --repository testpypi dist/sem2surface-0.2.0*
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
When prompted, use `__token__` as the username and the complete TestPyPI token,
|
|
273
|
+
including its `pypi-` prefix, as the password. Test the uploaded wheel in a new
|
|
274
|
+
environment without resolving dependencies from TestPyPI:
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps sem2surface==0.2.0
|
|
278
|
+
sem2surface --version
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
For the real release, create a PyPI account and API token at
|
|
282
|
+
[pypi.org](https://pypi.org/), then run:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
python -m twine upload dist/sem2surface-0.2.0*
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
PyPI and TestPyPI use separate accounts and tokens. Never commit a token or put
|
|
289
|
+
one directly in a command. For later automated releases, prefer
|
|
290
|
+
[PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/).
|
|
291
|
+
|
|
292
|
+
## Method references
|
|
293
|
+
|
|
294
|
+
1. Neggers, J. et al. (2021). Principal image decomposition for multi-detector
|
|
295
|
+
backscatter electron topography reconstruction. *Ultramicroscopy*, 227,
|
|
296
|
+
113200. [DOI](https://doi.org/10.1016/j.ultramic.2020.113200)
|
|
297
|
+
2. Frankot, R. T. and Chellappa, R. (1988). A method for enforcing integrability
|
|
298
|
+
in shape from shading algorithms. *IEEE Transactions on Pattern Analysis and
|
|
299
|
+
Machine Intelligence*, 10(4), 439-451.
|
|
300
|
+
[DOI](https://doi.org/10.1109/34.3909)
|
|
301
|
+
|
|
302
|
+
## Author and license
|
|
303
|
+
|
|
304
|
+
Developed by Vladislav A. Yastrebov, CNRS, Mines Paris – PSL, Centre des
|
|
305
|
+
matériaux. Distributed under the
|
|
306
|
+
[BSD 3-Clause License](https://github.com/vyastreb/sem2surface/blob/master/LICENSE).
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
# sem2surface
|
|
2
|
+
|
|
3
|
+
`sem2surface` reconstructs a three-dimensional surface from three to five
|
|
4
|
+
multi-detector SEM/BSE images. It extracts two normalized principal images,
|
|
5
|
+
identifies their orientation with a Radon transform, and integrates the resulting
|
|
6
|
+
gradients using the Frankot-Chellappa FFT method.
|
|
7
|
+
|
|
8
|
+
<!-- PyPI cannot resolve repository-relative images. Keep this absolute URL. -->
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
The reconstruction can be used qualitatively with an arbitrary vertical scale.
|
|
12
|
+
Quantitative measurements require a calibrated Z scaling factor for the imaging
|
|
13
|
+
configuration. The included Vickers-indentation example demonstrates that
|
|
14
|
+
calibration procedure.
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
Python 3.10 or newer is required. An isolated virtual environment is strongly
|
|
19
|
+
recommended so the application does not conflict with system Python packages.
|
|
20
|
+
|
|
21
|
+
### Linux and macOS
|
|
22
|
+
|
|
23
|
+
Create an environment and install a released version:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
python3 -m venv .venv
|
|
27
|
+
source .venv/bin/activate
|
|
28
|
+
python -m pip install --upgrade pip
|
|
29
|
+
python -m pip install sem2surface
|
|
30
|
+
sem2surface-gui
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Until a release is uploaded to PyPI, run the final installation command from
|
|
34
|
+
this source checkout instead:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python -m pip install .
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
On Linux, Tkinter may be packaged separately. For example, Ubuntu and Debian
|
|
41
|
+
users can install it with their system package manager as `python3-tk` before
|
|
42
|
+
creating the environment.
|
|
43
|
+
|
|
44
|
+
### Windows
|
|
45
|
+
|
|
46
|
+
Install Python 3.10 or newer from
|
|
47
|
+
[python.org](https://www.python.org/downloads/windows/). Keep the standard
|
|
48
|
+
`pip`, Tcl/Tk, and Python Launcher components enabled. Then open PowerShell in
|
|
49
|
+
the folder where you want the environment and run:
|
|
50
|
+
|
|
51
|
+
```powershell
|
|
52
|
+
py -3 -m venv .venv
|
|
53
|
+
.\.venv\Scripts\Activate.ps1
|
|
54
|
+
python -m pip install --upgrade pip
|
|
55
|
+
python -m pip install sem2surface
|
|
56
|
+
sem2surface-gui
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If PowerShell blocks the activation script, allow it only for the current
|
|
60
|
+
PowerShell process and retry activation:
|
|
61
|
+
|
|
62
|
+
```powershell
|
|
63
|
+
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
|
|
64
|
+
.\.venv\Scripts\Activate.ps1
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
In Command Prompt, activate the same environment with:
|
|
68
|
+
|
|
69
|
+
```bat
|
|
70
|
+
.venv\Scripts\activate.bat
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Activation is optional. The GUI can always be launched directly:
|
|
74
|
+
|
|
75
|
+
```powershell
|
|
76
|
+
.\.venv\Scripts\sem2surface-gui.exe
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Before the PyPI release, install either from a source checkout with
|
|
80
|
+
`python -m pip install .` or from the provided wheel:
|
|
81
|
+
|
|
82
|
+
```powershell
|
|
83
|
+
python -m pip install "C:\path\to\sem2surface-0.2.0-py3-none-any.whl"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Use `deactivate` to leave the environment on any platform. Do not copy a
|
|
87
|
+
virtual environment between computers or move it after creation; create a new
|
|
88
|
+
one and reinstall the package instead.
|
|
89
|
+
|
|
90
|
+
VTK export is optional because VTK is a large dependency:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python -m pip install "sem2surface[vtk]"
|
|
94
|
+
# From this source checkout instead: python -m pip install ".[vtk]"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The application does not require ImageMagick or a LaTeX installation. Tkinter is
|
|
98
|
+
included with the standard Python installers on Windows and macOS.
|
|
99
|
+
|
|
100
|
+
## Desktop application
|
|
101
|
+
|
|
102
|
+
After installation, launch the graphical interface from a terminal:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
sem2surface-gui
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Select three to five detector images, confirm the pixel size and scaling factor,
|
|
109
|
+
choose an output directory, and start the reconstruction. TIFF, PNG, JPEG, and
|
|
110
|
+
BMP images are supported. The work runs in the background so the window remains
|
|
111
|
+
responsive.
|
|
112
|
+
|
|
113
|
+
The GUI intentionally provides only the FFT reconstruction. Atomic-number
|
|
114
|
+
correction and direct profile integration have been removed.
|
|
115
|
+
|
|
116
|
+
## Command line
|
|
117
|
+
|
|
118
|
+
Installation also provides a `sem2surface` executable:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
sem2surface detector_A.tif detector_B.tif detector_C.tif \
|
|
122
|
+
--z-scale 217.27243 \
|
|
123
|
+
--save npz \
|
|
124
|
+
--output-dir results
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Pixel size is read from the first TIFF by default. For images without compatible
|
|
128
|
+
SEM metadata, provide it in micrometres:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
sem2surface detector_A.png detector_B.png detector_C.png \
|
|
132
|
+
--pixel-size-um 0.325521 \
|
|
133
|
+
--curvature none
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Run `sem2surface --help` for the complete list of options. VTK output requires
|
|
137
|
+
the optional `vtk` installation described above.
|
|
138
|
+
|
|
139
|
+
## Python API
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from pathlib import Path
|
|
143
|
+
|
|
144
|
+
from sem2surface import construct_surface
|
|
145
|
+
|
|
146
|
+
images = [Path("detector_A.tif"), Path("detector_B.tif"), Path("detector_C.tif")]
|
|
147
|
+
preview, X, Y, Z, warning = construct_surface(
|
|
148
|
+
images,
|
|
149
|
+
z_scaling_factor_per_pixel=217.27243,
|
|
150
|
+
remove_curvature=True,
|
|
151
|
+
save_file_type="NPZ",
|
|
152
|
+
output_dir="results",
|
|
153
|
+
)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Pixel size and manual curvature radii use metres in the Python API. Returned
|
|
157
|
+
coordinate and height arrays use micrometres. The old `constructSurface`
|
|
158
|
+
function remains as a compatibility wrapper for version 0.1 scripts, but only
|
|
159
|
+
FFT reconstruction is accepted and the old atomic-number arguments are ignored.
|
|
160
|
+
|
|
161
|
+
## Outputs
|
|
162
|
+
|
|
163
|
+
Every reconstruction creates:
|
|
164
|
+
|
|
165
|
+
- a colour PNG of the reconstructed surface;
|
|
166
|
+
- a grayscale PNG suitable for further image analysis;
|
|
167
|
+
- a UTF-8 log containing parameters, input names, angles, and surface RMS.
|
|
168
|
+
|
|
169
|
+
Surface arrays can additionally be saved as CSV, compressed NumPy NPZ, or VTK
|
|
170
|
+
structured-grid data. Optional diagnostic output includes the detector/PCA
|
|
171
|
+
decomposition, Radon search, and oriented gradients.
|
|
172
|
+
|
|
173
|
+
When timestamps are disabled, an existing output with the same name is replaced.
|
|
174
|
+
Choose a dedicated output folder or enable timestamps when results must be kept.
|
|
175
|
+
|
|
176
|
+
## Reference examples and scaling
|
|
177
|
+
|
|
178
|
+
The [examples directory](https://github.com/vyastreb/sem2surface/tree/master/examples)
|
|
179
|
+
contains the reference analyses:
|
|
180
|
+
|
|
181
|
+
- `Surface_1` and `Surface_2`: representative reconstructed surfaces;
|
|
182
|
+
- `Vickers_imprint`: reconstruction of a Vickers indentation;
|
|
183
|
+
- `Vickers_imprint_scaling`: identification of the Z scaling factor from the
|
|
184
|
+
known Vickers geometry.
|
|
185
|
+
|
|
186
|
+
After installing the package with the VTK extra, an example can be run from any
|
|
187
|
+
working directory:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
python examples/Surface_1/test_without_gui.py
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
<!-- PyPI cannot resolve repository-relative images. Keep this absolute URL. -->
|
|
194
|
+

|
|
195
|
+
|
|
196
|
+
## Development
|
|
197
|
+
|
|
198
|
+
Create an isolated environment and install the editable project with its test
|
|
199
|
+
tools:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
python -m venv .venv
|
|
203
|
+
source .venv/bin/activate
|
|
204
|
+
python -m pip install -e ".[test]"
|
|
205
|
+
python -m pytest
|
|
206
|
+
python -m build
|
|
207
|
+
python -m twine check dist/*
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
Continuous integration tests Python 3.10 and 3.13 on Linux, Windows, and macOS,
|
|
211
|
+
and verifies both the source distribution and universal wheel.
|
|
212
|
+
|
|
213
|
+
### Maintainer release checklist
|
|
214
|
+
|
|
215
|
+
Use a clean virtual environment and update the version in both
|
|
216
|
+
`pyproject.toml` and `src/sem2surface.py`. PyPI does not allow an uploaded file
|
|
217
|
+
or release version to be replaced.
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
python -m pytest -q
|
|
221
|
+
python -m build
|
|
222
|
+
python -m twine check dist/*
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
For a first trial, create a separate account and API token on
|
|
226
|
+
[TestPyPI](https://test.pypi.org/), then upload only the files for the new
|
|
227
|
+
version:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
python -m twine upload --repository testpypi dist/sem2surface-0.2.0*
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
When prompted, use `__token__` as the username and the complete TestPyPI token,
|
|
234
|
+
including its `pypi-` prefix, as the password. Test the uploaded wheel in a new
|
|
235
|
+
environment without resolving dependencies from TestPyPI:
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
python -m pip install --index-url https://test.pypi.org/simple/ --no-deps sem2surface==0.2.0
|
|
239
|
+
sem2surface --version
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
For the real release, create a PyPI account and API token at
|
|
243
|
+
[pypi.org](https://pypi.org/), then run:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
python -m twine upload dist/sem2surface-0.2.0*
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
PyPI and TestPyPI use separate accounts and tokens. Never commit a token or put
|
|
250
|
+
one directly in a command. For later automated releases, prefer
|
|
251
|
+
[PyPI Trusted Publishing](https://docs.pypi.org/trusted-publishers/).
|
|
252
|
+
|
|
253
|
+
## Method references
|
|
254
|
+
|
|
255
|
+
1. Neggers, J. et al. (2021). Principal image decomposition for multi-detector
|
|
256
|
+
backscatter electron topography reconstruction. *Ultramicroscopy*, 227,
|
|
257
|
+
113200. [DOI](https://doi.org/10.1016/j.ultramic.2020.113200)
|
|
258
|
+
2. Frankot, R. T. and Chellappa, R. (1988). A method for enforcing integrability
|
|
259
|
+
in shape from shading algorithms. *IEEE Transactions on Pattern Analysis and
|
|
260
|
+
Machine Intelligence*, 10(4), 439-451.
|
|
261
|
+
[DOI](https://doi.org/10.1109/34.3909)
|
|
262
|
+
|
|
263
|
+
## Author and license
|
|
264
|
+
|
|
265
|
+
Developed by Vladislav A. Yastrebov, CNRS, Mines Paris – PSL, Centre des
|
|
266
|
+
matériaux. Distributed under the
|
|
267
|
+
[BSD 3-Clause License](https://github.com/vyastreb/sem2surface/blob/master/LICENSE).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sem2surface"
|
|
7
|
+
version = "0.2.0"
|
|
8
|
+
description = "3D surface reconstruction from multi-detector SEM/BSE images"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "BSD-3-Clause"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Vladislav A. Yastrebov" },
|
|
14
|
+
]
|
|
15
|
+
keywords = ["SEM", "BSE", "surface reconstruction", "metrology", "microscopy"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 4 - Beta",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Environment :: X11 Applications",
|
|
20
|
+
"Intended Audience :: Science/Research",
|
|
21
|
+
"Operating System :: MacOS",
|
|
22
|
+
"Operating System :: Microsoft :: Windows",
|
|
23
|
+
"Operating System :: POSIX :: Linux",
|
|
24
|
+
"Programming Language :: Python :: 3",
|
|
25
|
+
"Programming Language :: Python :: 3.10",
|
|
26
|
+
"Programming Language :: Python :: 3.11",
|
|
27
|
+
"Programming Language :: Python :: 3.12",
|
|
28
|
+
"Programming Language :: Python :: 3.13",
|
|
29
|
+
"Topic :: Scientific/Engineering :: Image Processing",
|
|
30
|
+
]
|
|
31
|
+
dependencies = [
|
|
32
|
+
"numpy>=1.23",
|
|
33
|
+
"matplotlib>=3.7",
|
|
34
|
+
"scipy>=1.10",
|
|
35
|
+
"scikit-image>=0.21",
|
|
36
|
+
"pillow>=9.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
vtk = ["vtk>=9.2"]
|
|
41
|
+
test = ["build>=1.2", "pytest>=8", "twine>=5"]
|
|
42
|
+
|
|
43
|
+
[project.urls]
|
|
44
|
+
Homepage = "https://github.com/vyastreb/sem2surface"
|
|
45
|
+
Repository = "https://github.com/vyastreb/sem2surface"
|
|
46
|
+
Issues = "https://github.com/vyastreb/sem2surface/issues"
|
|
47
|
+
|
|
48
|
+
[project.scripts]
|
|
49
|
+
sem2surface = "sem2surface_cli:main"
|
|
50
|
+
|
|
51
|
+
[project.gui-scripts]
|
|
52
|
+
sem2surface-gui = "sem2surface_gui:main"
|
|
53
|
+
|
|
54
|
+
[tool.setuptools]
|
|
55
|
+
package-dir = { "" = "src" }
|
|
56
|
+
py-modules = ["sem2surface", "sem2surface_cli", "sem2surface_gui"]
|
|
57
|
+
|
|
58
|
+
[tool.pytest.ini_options]
|
|
59
|
+
addopts = "-ra"
|
|
60
|
+
testpaths = ["tests"]
|