As the equation above illustrates, DICOM only specifies image plane I and J axis directions. Applications often define a third (K) axis. For a single plane, you can always choose this K axis direction so that IJK axes form an orthogonal basis. However, you do not have the freedom of choosing arbitrary K axis direction if you want to describe geometry of a gantry-tilt multi-slice volume with a single 4x4 matrix. See for example this FAQ and computation of the shear matrix.
@lassoan provides a nice answer. While DICOM describes 2D orientations, when we stack 2D slices into a 3D matrix we need to consider the shear when developing our matrix. Likewise, when there is gantry tilt you have to be cautious regarding whether the vendor computes slice thickness based on distance between corresponding voxels (blue arrow in figure) or nearest voxel in next slice (red arrow in figure). Indeed, vendors have not been consistent on their definition of slice thickness.
As Kernighan and Plauger note Floating point numbers are like piles of sand; every time you move one you lose a little sand and pick up a little dirt. Therefore, as previously noted due to rounding errors some images may appear to have small amounts of shear. One solution would be to compare the image matrix to the same image matrix that has been converted to a quaternion and back again (e.g. nifti_mat44_to_quatern nifti_quatern_to_mat44). Since the quaternion can not store the shear, a difference between these two matrices will reveal the magnitude of the shear. If the difference is below a tolerance, the orthogonal one can be used, else the shear is meaningful.
As an aside, the other challenge with converting 2D DICOM CT scans to volumes in most tools (and converting them to most formats) is that brain CT scans often have variable slice thicknesses, with many thin slices near the life-threatening portions of the brain stem and fewer thick slices of the superior cortex. NIfTI and (I believe NRRD) require that all slices in a volume are equally spaced.
A public example of both gantry tilt and variable slice thickness is dcm_qa_ct
As @hjmjohnson and @blowekamp pointed out, most ITK filters assume an orthonormal direction matrix and uniform spacing. This provides a good tradeoff with algorithm complexity and performance.
As Hans suggested, we can treat image data that does not meeting these criteria specially during serialization and deserialization, with multiple optional approaches.
@dzenanz has already added some support for handling this with DICOM series:
This type of support could be added for NIFTI, too.