Message Boards Message Boards


3D Images and Parallelization

Posted 2 years ago
1 Reply
1 Total Likes

I am interested in converting stl files and found this interesting discussion in StackExchange:

A very neat solution is provided:

voxelify[region_?RegionQ, res_?NumericQ] := 
 Module[{f, bounds, boxsize, voxsize, data, d2},
  f = RegionDistance[region];
  bounds = RegionBounds[region]; 
  boxsize = -Subtract @@ # & /@ bounds;
  voxsize = Max[boxsize]/res; 
  data = ParallelArray[f[{##}] &, Round[boxsize/voxsize], bounds]; 
  d2 = HeavisideTheta[data - voxsize]; 
  2 - ReplaceAll[WatershedComponents[Image3D[1 - d2]], {0 -> 2}]
spikey = Import["ExampleData/spikey.stl", "MeshRegion"];
Image3D[voxelify[spikey, 100]]

enter image description here

Unfortunately the code no longer works in MMA 11.3, due to a problem with ParallelArray:

ParallelArray::nopar1: Array[f[{##1}]&,{100,95,81},{{-1.54435,1.54435},{-1.46876,1.46876},{-1.2494,1.2494}},List] cannot be parallelized; proceeding with sequential evaluation.

The sequential evaluation is far too slow for practical purposes.

Does anyone have any idea why the parallelization fails? Or can they suggest a workaround?

If anyone is still using MMA v10, I would appreciate it they would test the code to see if parallelization works.

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract