function val = minInNeighborhood(M, row, col)
% Return min in neighborhood of (row, col) in matrix M

% Written by Paul Chew for CS100M, Feb 2006

% Place a border around M so no worries about edges
[nr nc] = size(M);
bigM = realmax * ones(nr+2, nc+2);
bigM(2:nr+1, 2:nc+1) = M;

r = row+1; c = col+1;   % Adjust center for bigM
val = minInMatrix(bigM(r-1:r+1, c-1:c+1));
