function Z = imageCrop(A,p) % Input image A gets cropped from the center to the size defined by p, % where p(1) is the height and p(2) is the width. Z is the output image. % % LAst edit by Colin Joye, 10/20/04 [Ay Ax Az] = size(A); h = p(1); w = p(2); H = 1:h; W = 1:w; mx1 = floor(Ax/2) - floor(w/2) + 1; mx2 = mx1 + w - 1; my1 = floor(Ay/2) - floor(h/2) + 1; my2 = my1 + h - 1; Z = A( my1:my2 , mx1:mx2, :); % -------- END imagecrop.m -------------