editimag.m

来自「线性代数实验及MATLAB入门,电子工业出版社出版 陈怀琛 龚杰民合著」· M 代码 · 共 39 行

M
39
字号
function A=editimag(B,imag,back)

% EDITIMAG   Edit an image created with MAKEIMAG.
%            The command (B,imag,back) edits the image
%            represented by the matrix B that was originally
%            created using the M-file makeimag. The input
%            arguments imag and back specify the image and
%            background colors based on the current colormap.
%            Click on a square to toggle between the background
%            color and the image color. Type q to quit.
%
%            Default colors are used if imag and back are not 
%            specified as input arguments.
%
%    Larry Riddle, ATLAST Workshop, San Diego, June 1994
%    Modified by S.J. Leon, May 1996

subplot(1,1,1)
[n,m]=size(B);
if nargin==1,imag=27;back=1;end
if nargin==2,back=1;end
A=B;
image(A); axis('square')
while 1
   [x y z]=ginput(1);
   if abs(z)=='q'
      break
   elseif (x>=1) & (x<n+1) & (y>=1) & (y<n+1)
      x=fix(x); y=fix(y);
      if A(y,x)~=imag
         A(y,x)=imag;
      else
         A(y,x)=back;
      end
      image(A); axis('square')
   end
end
close

⌨️ 快捷键说明

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