Gradients play an important role in 2D image processing. Many edge detection algorithms are gradient-based. We are interested in 3D boundary detection which can be considered as an extension of 2D edge detection in 3D space. In this paper, an algorithm to automatically and quantitatively measure the suitability of gradient magnitudes in detection of 3D boundary points of confocal image stacks is presented. A Measurement Function is defined to evaluate the suitability of each gradient magnitude chosen to be the threshold for 3D boundary detection. The application of Gauss's Divergence Theorem provides a solution to calculate the Measurement Function numerically. The gradient magnitude at which the maximum of the Measurement Function is achieved can be utilized as the most appropriate threshold for gradient-based boundary detection and other operations like volume visualization.