setimage.m
来自「matlab处理图像的一些基本方法。其中有一部分mex程序需要安装编译」· M 代码 · 共 89 行
M
89 行
function setimage(newimg, pos, clip)%SETIMAGE Set and display the global variable I.%% SETIMAGE(NEWIMAGE, XYPOS, CLIP)%% SETIMAGE copies the image NEWIMAGE to the global variable I% and redisplays the image. XYPOS specifies the X and Y position% to which the NEWIMAGE will be copied (Default pos=[1 1]).% The NEWIMAGE can be smaller than the current image. In this case, only% part of the image will be changed. If pos is outside the% image border, the NEWIMAGE will be cropped to fit inside the% borders.% If CLIP is 1 (Default), the Clipboard and the Undofun are set;% if it is 0, the Cliboard is not set.% ALWAYS USE THIS FUNCTION TO MODIFY I.%% See also SHOWIMAGE, IMAGE, UNDO.%% Copyright (c) 1995 by Claudio Rivetti and Mark Young% claudio@alice.uoregon.edu, mark@alice.uoregon.edu%global I Undofun isModifyif nargin < 1 error('Too few input arguments.');endif nargin==2 clip=1;endif nargin==1 pos=[1 1]; clip=1;endf=watchon;if clip setclipboard(I); Undofun='setimage(getclipboard,inf,0);setclipboard([]);';endif pos~=inf pos=round(pos); imgr=size(I,1); imgc=size(I,2); newimgr=size(newimg,1); newimgc=size(newimg,2); if pos(2)>imgr | pos(1)>imgc | (pos(2)+newimgr)<1 | (pos(1)+newimgc)<1 return; end if pos(1)<1 newimg=newimg(:,abs(pos(1))+1:newimgc); pos(1)=1; newimgc=size(newimg,2); end if pos(1)+newimgc > imgc newimg=newimg(:,1:imgc-pos(1)+1); newimgc=size(newimg,2); end if pos(2)+newimgr > imgr newimg=newimg(1:imgr-pos(2)+1, :); newimgr=size(newimg,1); end if pos(2)<1 newimg=newimg(abs(pos(2))+1:newimgr, :); pos(2)=1; newimgr=size(newimg,2); end I(pos(2):pos(2)+newimgr-1, pos(1):pos(1)+newimgc-1)=newimg;else I=newimg;endshowimage;isModify=isModify+1;watchoff(f);return
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?