Extracts cuboids of given size from the array I at specified locations. extractflag determines how cuboids are extracted near the border of the image. Regardless of extractflag, if a certain cuboid contains no array data then it is discarded. If extractflag==0, then extracted cuboids near the borders are cropped to contain only image data, under this option cuboids may have irregular sizes. If extractflag==1, then extracted cuboids near the border are zero padded. This also means the cuboid_starts and cuboid_ends may have values outside of the range of I. If extractflag==2, then cuboid centers near the border are shifted until they fall fully within the image. When this option is selected the altered subscript locations are returned in the output subs. Data is returned in a cell array due to possibly irregular sizes of the cuboids (if extractflag==0 cuboids may be cropped). See cell2array.m for converting cell to array (by zero padding smaller entries in the cell array). INPUTS I - d dimension array cuboids_rs - the dimensions of the cuboids to find (1 x d) subs - subscricts of max locations (n x d) extractflag - [optional] by default==0, see above for usage OUTPUTS cuboids - cuboid{i} contains the ith extracted cuboid (n x 1) cuboid_starts - start locations of cuboids (n x d) [may have vals out of range] cuboid_ends - end locations of cuboids (n x d) [may have vals out of range] subs - subscricts of (possibly altered) max locations (n x d) See also CUBOID_DISPLAY