I'm trying to convert a 2d image to a 3d object that can be digested by 3d slicing software, specifically the algorithm contained here http://archive.bridgesmathart.org/2013/bridges2013-311.pdf

I had to convert the input/output of the routine to the below, however my cloud file just contains the wolfram comment 'created by wolfram' and no actual STL file.

img=ColorConvert[Import["bone.png"],"Grayscale"]      (* import the image as values in range 0..1 *)
height = 2.0;   (* height of cylinder.  Units are set in the 3D printer *)
alpha = 0.1;   (* max relief depth, as fraction of height, typically around 0.1, or -0.1 for inverting *)
{n,m} = ImageDimensions[img];
rMid=n * height/(2 Pi m) ;     (* scale so pixels are square at mid-depth*)
r=Map[rMid-alpha height (#-0.5)&,ImageData[img],{2}];   (* convert to table of radii *)
xyz=Table[{r[[j,i]]Sin[2 Pi i/n],r[[j,i]]Cos[2 Pi i/n],(1-j/m) height},{i,1,n},{j,1,m}];   (* convert to Cartesian *)
(* the cylinder consists of three parts: the curved surface with the image and two circular caps: *)
g=Graphics3D[{EdgeForm[],Map[Polygon,Join[surface,top,bottom]]}] ;
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – Michael E2 Feb 9 at 15:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.