Code covered by the BSD License  

Highlights from
Toolbox image

from Toolbox image by Gabriel Peyre
A toolbox that contains image processing functions

select_region(M)
function M1 = select_region(M)

% select_region - extract some sub image
%
%   M1 = select_region(M);
%
%   Copyright (c) 2005 Gabriel Peyr

M1 = M;
[n,p] = size(M);

b = 1;

while b==1
    clf;
    imagesc(M1);
    colormap gray(256);
    axis image; axis off;
    [x,y,b] = ginput(1);
    x = round(x); x = max(min(x,n),1);
    y = round(y); y = max(min(y,p),1);
    M1(y,x) = Inf;
end

Contact us at files@mathworks.com