You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+83-10
Original file line number
Diff line number
Diff line change
@@ -97,25 +97,98 @@ dt = edt.edt(
97
97
98
98
*Note on Memory Usage: Make sure the input array to edt is contiguous memory or it will make a copy. You can determine if this is the case with `print(data.flags)`.*
99
99
100
-
###C++ Usage
100
+
## C++ Instructions for MLAEDT-3D
101
101
102
-
Include the edt.hpp header which includes the implementation in namespace `edt`. You'll need to also include `threadpool.h` and add the `-pthread` compiler flag. The code is written to the C++11 standard.
102
+
Compute the Euclidean Distance Transform of a 1d, 2d, or 3d labeled image containing multiple labels in a single pass with support for anisotropic dimensions. C++ function expect the input array to be in Fortran (column-major) order. If your array is in C (row-major) order, it will also work but you must
103
+
reverse the order of the dimension and anisotropy arguments (sx,sy,sz -> sz,sy,sx and wx,wy,wz -> wz,wy,wx).
104
+
105
+
### Compiling
106
+
107
+
You only need `edt.hpp`, `test.cpp` is only there for testing.
108
+
109
+
```bash
110
+
make shared # compile edt.so
111
+
make test# compile ./test with debugging information
112
+
```
113
+
114
+
If you statically integrate `edt.hpp` into your own C++ program, I recommend compiler flags `-O3` and `-ffast-math` for optimal performance.
115
+
116
+
### C++ Examples
103
117
104
118
```cpp
105
119
#include"edt.hpp"
106
120
107
-
intmain () {
121
+
int* labels1d = newint[512]();
122
+
int* labels2d = newint[512*512]();
123
+
int* labels3d = newint[512*512*512]();
124
+
125
+
// ... populate labels ...
126
+
127
+
// 1d, 2d, and 3d anisotropic transforms, wx = anisotropy on x-axis
Binary images are treated specially in 2D and 3D to avoid executing the extra multi-label logic (1D is very fast even with it). This results in a substantial savings of perhaps 20-50% depending on the compiler. For a 512x512x512 cube filled with ones, on a 4.0 GHz linux machine with g++, I witnessed reductions from 9 sec. to 7 sec. (1.29x). On 2.8 GHz Mac OS with clang-902.0.39.2 I saw a reduction from 12.4 sec to 7.9 sec (1.56x).
108
158
109
-
int* labels = new int[3*3*3]();
159
+
The code will easily handle all integer types, and the image only needs to be binary in the sense that there is a single non-zero label, it doesn't have to be ones.
110
160
111
-
int sx = 3, sy = 3, sz = 3;
112
-
float wx = 6, wy = 6, wz = 30; // anisotropy
161
+
Boolean typed images are handled specially by a specialization of the edt function, so nothing different from above needs to be done. If you have an integer typed image, you'll need to use `binary_edt` or `binary_edtsq` instead to take advantage of this.
0 commit comments