31

16

I'm trying to extrude a nice 3D form from the 2D binary image below using the code posted, but I haven't had any luck in figuring out the error that's keeping `GraphicsComplex`

from running. The end result should be the 3D points and a plot. Any help would certainly be appreciated!

```
pts= ImageData[testimage];
twoD = Rescale[Table[Thread[{pts[[i]], pts[[i]]}], {i, 1, Length[pts]}]];
extrude[pts_, h_] := Module[{vb, vt, len = Length[pts], nh, shape},
If[! NumericQ[h], nh = 0., nh = N@h];
vb = Table[{pts[[i, 1]], pts[[i, 2]], 0}, {i, len}];
vt = Table[{pts[[i, 1]], pts[[i, 2]], nh}, {i, len}];
shape =
GraphicsComplex[
Join[vb, vt], {Polygon[Range[len]],
Polygon[Append[
Table[{i, i + 1, len + i + 1, len + i}, {i, len - 1}], {len, 1,
len + 1, 2 len}]], Polygon[Range[len + 1, 2 len]]}]
]
```

1

You;ll find some solutions to exactly this problem among the answers to this question: Character edge finding.

– Szabolcs – 2012-05-30T07:16:45.867Thanks @Szabolcs Interesting approaches! – R Hall – 2012-05-30T11:02:49.293