function cimg=cutimage %CUTIMAGE Copy from a specified position in the current image an area, % defined with the mouse, to the global variable CutPaste and % set the same area to a value equal to the mean of the values % of the image. % % Claudio 28 Sept. 1995 % % % Copyright (c) 1995 by Claudio Rivetti and Mark Young % claudio@alice.uoregon.edu, mark@alice.uoregon.edu % global H I CutPaste; if nargin>0 error('Too many input arguments.'); end if ~isimage setviewmode('TOPVIEW'); showimage; end % rect = [left, bottom, width, height] [cimg, rect]=imcrop; ss=scansize(H); px=size(I,1); rect(1)=rect(1)-xoffset(H); rect(2)=rect(2)-yoffset(H); rect=rect*px/ss; rect=round(rect); value=min(min(I)); CutPaste=I(rect(2):rect(2)+rect(4), rect(1):rect(1)+rect(3)); setimage(CutPaste*0+value, [rect(1) rect(2)]); set(findobj('tag', 'PASTEITEM'), 'Enable', onoff(~isempty(CutPaste))); if nargout == 1 cimg=CutPaste; end return;