# arrayToDims

## PURPOSE

Pads or crops I appropriately so that size(IC)==dims.

## SYNOPSIS

function IC = arrayToDims( I, dims, padEl )

## DESCRIPTION

     Pads or crops I appropriately so that size(IC)==dims.

     For each dimension d, if size(I,d) is larger then dims(d) then
     symmetrically crops along d (if cropping amount is odd crops one more
     unit from the start of the dimension).  If size(I,d) is smaller then
     dims(d) then symmetrically pads along d with padEl (if padding amount is
     even then pads one more unit along the start of the dimension).

     USAGE
      IC = arrayToDims( I, dims, [padEl] )

     INPUTS
      I         - n dim array to crop window from (for arrays can only crop)
      dims      - dimensions to make I
      padEl     - [0] element with which to pad

     OUTPUTS
      IC        - cropped array

     EXAMPLE
      I=randn(10); delta=1; IC=arrayToDims(I,size(I)-2*delta);

     See also ARRAYCROP, PADARRAY

     Piotr's Image&Video Toolbox      Version 2.0
     Copyright 2008 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Lesser GPL [see external/lgpl.txt]

## CROSS-REFERENCE INFORMATION

This function calls:

- arrayCrop Used to crop a rectangular region from an n dimensional array.
- checkNumArgs Helper utility for checking numeric vector arguments.

This function is called by:

- FbCrop Crop a 2D filterbank (adjusting filter norms).
- FbReconstruct2d Use to see how much image information is preserved in filter outputs.
- convnFast Fast convolution, replacement for both conv2 and convn.
- imtransform2 Applies a general/special homography on an image I
- optFlowCorr Calculate optical flow using cross-correlation.
- cell2array Flattens a cell array of regular arrays into a regular array.