I have a capillary system and I want to convert this into a numeric matrix. My aim is to create a matrix with NxNxN dimensions of 1's and 0's where the 0's represent the capillary and the 1's represent the transparent region into the box (similar to 2d's case questioned and answered).
The capillary was built manually; it is consists of tubes with different diameters/radius
(*trunk*)
t0 = {{4, 4, 0}, {4, 4, 2}};
r0 = 0.7;
(*first branches*)
t11 = {{4, 4, 2}, {2, 4, 4}};
t12 = {{4, 4, 2}, {6, 4, 4}};
t13 = {{4, 4, 2}, {4, 2, 4}};
t14 = {{4, 4, 2}, {4, 6, 4}};
r1 = 0.4;
(*first branche's secondary branches*)
t21 = {{3, 4, 3}, {2, 5, 5}};
t22 = {{3, 4, 3}, {2, 3, 5}};
t23 = {{5, 4, 3}, {6, 5, 5}};
t24 = {{5, 4, 3}, {6, 3, 5}};
t25 = {{4, 3, 3}, {3, 2, 5}};
t26 = {{4, 3, 3}, {5, 2, 5}};
t27 = {{4, 5, 3}, {5, 6, 5}};
t28 = {{4, 5, 3}, {3, 6, 5}};
r2 = 0.2;
(*second branches*)
t31 = {{4, 2, 4}, {1, 0, 5}};
t32 = {{4, 2, 4}, {7, 0, 5}};
t33 = {{4, 6, 4}, {1, 8, 5}};
t34 = {{4, 6, 4}, {7, 8, 5}};
t35 = {{2, 4, 4}, {0, 7, 5}};
t36 = {{2, 4, 4}, {0, 1, 5}};
t37 = {{6, 4, 4}, {8, 7, 5}};
t38 = {{6, 4, 4}, {8, 1, 5}};
r3 = 0.3;
(* branches to center*)
t41 = {{4, 2, 4}, {4, 3, 6}};
t42 = {{4, 6, 4}, {4, 5, 6}};
t43 = {{2, 4, 4}, {3, 4, 6}};
t44 = {{6, 4, 4}, {5, 4, 6}};
r4 = 0.1;
(*branches to center (vertical)*)
t51 = {{4, 3, 6}, {4, 3, 8}};
t52 = {{4, 5, 6}, {4, 5, 8}};
t53 = {{3, 4, 6}, {3, 4, 8}};
t54 = {{5, 4, 6}, {5, 4, 8}};
r5 = 0.1;
(*secondary branches conection*)
t61 = {{3, 2, 5}, {1, 1, 8}};
t62 = {{5, 2, 5}, {7, 1, 8}};
t63 = {{5, 6, 5}, {7, 7, 8}};
t64 = {{3, 6, 5}, {1, 7, 8}};
t65 = {{2, 5, 5}, {1, 7, 8}};
t66 = {{6, 5, 5}, {7, 7, 8}};
t67 = {{6, 3, 5}, {7, 1, 8}};
r6 = 0.1;
To generate the tubes with different diameters, I joined the radius to the branches
(*trunk*)
J0 = {{{4, 4, 0}, {4, 4, 2}}, r0};(*start and end point*)
(*first branches*)
J11 = {{{4, 4, 2}, {2, 4, 4}}, r1};
J12 = {{{4, 4, 2}, {6, 4, 4}}, r1};
J13 = {{{4, 4, 2}, {4, 2, 4}}, r1};
J14 = {{{4, 4, 2}, {4, 6, 4}}, r1};
(*first branche's secondary branches*)
J21 = {{{3, 4, 3}, {2, 5, 5}}, r2};
J22 = {{{3, 4, 3}, {2, 3, 5}}, r2};
J23 = {{{5, 4, 3}, {6, 5, 5}}, r2};
J24 = {{{5, 4, 3}, {6, 3, 5}}, r2};
J25 = {{{4, 3, 3}, {3, 2, 5}}, r2};
J26 = {{{4, 3, 3}, {5, 2, 5}}, r2};
J27 = {{{4, 5, 3}, {5, 6, 5}}, r2};
J28 = {{{4, 5, 3}, {3, 6, 5}}, r2};
(*second branches*)
J31 = {{{4, 2, 4}, {1, 0, 5}}, r3};
J32 = {{{4, 2, 4}, {7, 0, 5}}, r3};
J33 = {{{4, 6, 4}, {1, 8, 5}}, r3};
J34 = {{{4, 6, 4}, {7, 8, 5}}, r3};
J35 = {{{2, 4, 4}, {0, 7, 5}}, r3};
J36 = {{{2, 4, 4}, {0, 1, 5}}, r3};
J37 = {{{6, 4, 4}, {8, 7, 5}}, r3};
J38 = {{{6, 4, 4}, {8, 1, 5}}, r3};
(* branches to center*)
J41 = {{{4, 2, 4}, {4, 3, 6}}, r4};
J42 = {{{4, 6, 4}, {4, 5, 6}}, r4};
J43 = {{{2, 4, 4}, {3, 4, 6}}, r4};
J44 = {{{6, 4, 4}, {5, 4, 6}}, r4};
(*branches to center (vertical)*)
J51 = {{{4, 3, 6}, {4, 3, 8}}, r5};
J52 = {{{4, 5, 6}, {4, 5, 8}}, r5};
J53 = {{{3, 4, 6}, {3, 4, 8}}, r5};
J54 = {{{5, 4, 6}, {5, 4, 8}}, r5};
(*secondary branches conection*)
J61 = {{{3, 2, 5}, {1, 1, 8}}, r6};
J62 = {{{5, 2, 5}, {7, 1, 8}}, r6};
J63 = {{{5, 6, 5}, {7, 7, 8}}, r6};
J64 = {{{3, 6, 5}, {1, 7, 8}}, r6};
J65 = {{{2, 5, 5}, {1, 7, 8}}, r6};
J66 = {{{6, 5, 5}, {7, 7, 8}}, r6};
J67 = {{{6, 3, 5}, {7, 1, 8}}, r6};
J = {J0,J11,J12,J13,J14,J21,J22,J23,J24,J25,J26,J27,J28,J31,J32,J33,J34,J35,J36,J37,J38,J41,J42, J43,J44,J51,J52,J53,J54,J61,J62,J63,J64,J65,J66,J67};
Graphics3D[Tube[#[[1]], #[[2]]] & /@ J]
The figure generated by this branching process is
How to obtain a 3d matrix (with dimension 128x128x128)?
Is it possible to save this image in 3D (pixel)? If yes, so could import it a list of images as a 3D volume:
n = 128;
image = Import["image", "Image3D"]
image = ImageResize[image, {n,n,n}];
data = ImageData[MorphologicalBinarize[image]];
MatrixPlot[data]
MatrixPlot[1 - data]
Or alternatively, would it be possible some alternative way to get this 3D matrix?
n = 128; (*dimension of matrix*)
f[i_, j_, k_] := (*rule to generated the tube*)
s = SparseArray[{{i_, j_, k_} -> f[i, j]}, {n, n, n}]; (*matrix*)
MatrixForm[s];
Can anybody help me?
Thank you in advance.





"*.tiff". Have you tried explicitly exporting yourGraphics3Din said format, specifying the desired image size/resolution? – CA Trevillian Dec 22 '21 at 21:37Image3D, not aGraphics3D. See this question for ways to do that. – Rohit Namjoshi Dec 22 '21 at 23:37