I would like to create a visualization of a volume with the help of equally-spaced grid lines. The effect I want to get is easily obtainable for 2D images, the image is simply divided into quadratic patches and the boundary is replaced by some constant value:
patchSize = 10;
insidePad2D[x_, padding_, val_] :=
With[{offset = padding + 1},
ArrayPad[x[[offset ;; -offset, offset ;; -offset]], padding, val]]
dataSpikey = ColorConvert[Import["ExampleData/spikey.tiff"], "Grayscale"] // ImageData;
imgSpikey = ArrayFlatten[BlockMap[insidePad2D[#, 1, 0] &, dataSpikey, {patchSize, patchSize}],
2] // Image
However, this seems to be more challenging for Image3D
:
patchSize = 10;
insidePad3D[x_, padding_, val_] :=
With[{offset = padding + 1},
ArrayPad[x[[offset ;; -offset, offset ;; -offset,
offset ;; -offset]], padding, val]]
dataEngine = Import["ExampleData/CTengine.tiff", "Image3D"] // ImageData;
dataEngine =
ArrayFlatten[
BlockMap[insidePad3D[#, 1, 0] &,
dataEngine, {patchSize, patchSize, patchSize}], 3];
imgEngine = Image3D[dataEngine]
The grid lines are visualized as zero-opacity voxels ("gaps") and not in black as desired. How can I fix this problem?