⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stencilcrop.m

📁 用matlab实现图像融合
💻 M
字号:
function [StencilC, CenterC] = stencilCrop(Stencil, Center)%------------------------------------------------------------------------------%% This function crops a stencil at its bounds, in case all values are% zero on the bounds and the center remains within the stencil.% For dimensions <=3 no (more) cropping is performed.%% Stencil  = input stencil%% Center   = center of Stencil%% StencilC = output stencil (cropped)%% CenterC  = center of StencilC%% See also: stencilR2Q%% Design and implementation by:% Dr. Paul M. de Zeeuw <Paul.de.Zeeuw@cwi.nl>  http://homepages.cwi.nl/~pauldz/% Last Revision: January 24, 2001.% Copyright 1999-2002 Stichting CWI, Amsterdam.%------------------------------------------------------------------------------o=[0 0];if ~all(size(o) == size(Center))  error(' stencilCrop - unexpected dimensions of Center ')else  clear o;endStencilC = Stencil;CenterC = Center;%[n, m] = size(Stencil);for j = n:-1:4   [nC, mC] = size(StencilC);   v = StencilC(nC,:);   if any(v) || CenterC(1)>=nC     break;   else     StencilC = StencilC(1:(nC-1),:);   endendfor j = m:-1:4   [nC, mC] = size(StencilC);   v = StencilC(:,mC)';   if any(v) || CenterC(2)>=mC     break;   else     StencilC = StencilC(:,1:(mC-1));   end   end%[n, m] = size(StencilC);for j = 1:(n-3)   [nC, mC] = size(StencilC);   v = StencilC(1,:);   if any(v) || CenterC(1)<=1     break;   else     StencilC = StencilC(2:nC,:);     CenterC = [(CenterC(1)-1) CenterC(2)];   endendfor j = 1:(m-3)   [nC, mC] = size(StencilC);   v = StencilC(:,1)';   if any(v) || CenterC(2)<=1     break;   else     StencilC = StencilC(:,2:mC);     CenterC = [CenterC(1) (CenterC(2)-1)];   end   end%

⌨️ 快捷键说明

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