# computation of gradient vector field in 3D using GradientOrientationFilter

I want to compute a 3D gradient vector field of an Image3D object using the built-in GradientOrientationFilter function in Mathematica. From the documentation I extracted the example for computing the gradient vector field for the 2D case and put it into a module:

computeGradientField2D[image_Image] := Module[
{dims, dirs, magnitudes},

dims = ImageDimensions[image];
dirs = ImageData[GradientOrientationFilter[image, 5]];
magnitudes = ImageData[GradientFilter[image, 5]];
MapThread[#1 {-Sin[#2], Cos[#2]} &, {magnitudes, dirs}, 2]
];


For drawing the vectors I also use the method from the documenation:

Show[ImageAdjust@img,
ListVectorPlot[
MapIndexed[{{#2[], dims[] - #2[]}, #1} &, or, {2}],
VectorColorFunction -> (Yellow &), VectorPoints -> Fine],
ImageSize -> 256]


This gives me the following output for a grayscale image of cell nuclei (left: raw image, right: raw image with overlayed vector field):  So far so good. Now I am struggeling with the computation of the gradient vector field for Image3D objects. My current function looks like the following:

computeGradientField3D[image_Image3D] := Module[
{img, dims, dirs, magnitudes},
dims = ImageDimensions[image];
dirs = ImageData[GradientOrientationFilter[image, 5]];
magnitudes = ImageData[GradientFilter[image, 5]];
MapThread[#1 {Cos[#2[]], Sin[#2[]] Cos[#2[]],
Sin[#2[]] Sin[#2[]]} &, {magnitudes, dirs}, 3]
];


I am particularly not sure about the last line with the MapThread where the orientations of the vectors are created and multiplied with the magnitudes. The documentation of GradientOrientationFilter contains the following information about how to interprete the orientation angles: Questions:

1. Am I misinterpreting the documentation?

2. How do I visualize the gradient vector field in the end (e.g. using ListVectorPlot3D)?