Fast implementation of the K-Means clustering algorithm adapted to work on 3D image arrays in MATLAB.