pasteimage.m

来自「matlab处理图像的一些基本方法。其中有一部分mex程序需要安装编译」· M 代码 · 共 84 行

M
84
字号
function pasteimage(command)%PASTEIMAGE Copy the CutPaste global variable to the specified position%		in the current image, using the mouse.%% 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 ax l w h x y oldz oldmf olddf oldpn ss px;if isempty(CutPaste)  message('|    Nothing to Paste.');  return;endif nargin>1  error('Too many input arguments.');endif nargin==0  command='START';endif strcmp(upper(command), 'START')  if ~isimage    setviewmode('TOPVIEW');    showimage;  end  oldpn=get(gcf, 'pointer');  oldmf=get(gcf, 'WindowButtonMotionFcn');  olddf=get(gcf, 'WindowButtonDownFcn');  oldz=getzoomstatus;  setzoomstatus(0);  ss=scansize(H);  px=size(I,1);  w=size(CutPaste,2);  h=size(CutPaste,1);  w=w*ss/px;  h=h*ss/px;  lx=[0 0 w w 0];  ly=[0 h h 0 0];  l=line(lx,ly,'erasemode','xor');  set(gcf, 'pointer', 'fleur');  set(gcf, 'WindowButtonMotionFcn', 'pasteimage(''MOVE'')');  set(gcf, 'WindowButtonDownFcn', 'pasteimage(''PASTE'')');endif strcmp(upper(command), 'MOVE')  p=pix2axes(get(gcf, 'currentpoint'));  lx=[p(1)-w/2 p(1)-w/2 p(1)+w/2 p(1)+w/2 p(1)-w/2];  ly=[p(2)-h/2 p(2)+h/2 p(2)+h/2 p(2)-h/2 p(2)-h/2];  set(l,'xdata',lx);set(l,'ydata',ly);end		 if strcmp(upper(command), 'PASTE')  set(gcf, 'WindowButtonMotionFcn', oldmf);  set(gcf, 'WindowButtonDownFcn', olddf);  set(gcf, 'pointer', oldpn);  x=get(l, 'xdata');  y=get(l, 'ydata');  x=ceil((x(1)-xoffset(H)) * px/ss);  y=ceil((y(1)-yoffset(H)) * px/ss);  delete(l);  setzoomstatus(oldz);  setimage(CutPaste, [x y]);end   return;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?