bestblk.m
来自「有关matlab的电子书籍有一定的帮助希望有用」· M 代码 · 共 42 行
M
42 行
function [mb,nb] = bestblk(siz,k)
%BESTBLK Choose block size for block processing.
% SIZ = BESTBLK([M N],K) returns, for an M-by-N image, the
% optimal block size for block processing. K is a scalar
% specifying the maximum row and column dimensions for the
% block; if the argument is omitted, it defaults to 100. SIZ is
% a 1-by-2 vector containing row and column dimensions for the
% block.
%
% [MB,NB] = BESTBLK([M N],K) returns the row and column
% dimensions in MB and NB, respectively.
%
% Example
% -------
% siz = bestblk([640 800], 72)
%
% See also BLKPROC.
% Clay M. Thompson
% Copyright 1993-1998 The MathWorks, Inc. All Rights Reserved.
% $Revision: 5.7 $ $Date: 1997/11/24 15:33:57 $
if nargin==1, k = 100; end % Default block size
%
% Find possible factors of siz that make good blocks
%
% Define acceptable block sizes
m = floor(k):-1:floor(min(ceil(siz(1)/10),ceil(k/2)));
n = floor(k):-1:floor(min(ceil(siz(2)/10),ceil(k/2)));
% Choose that largest acceptable block that has the minimum padding.
[dum,ndx] = min(ceil(siz(1)./m).*m-siz(1)); blk(1) = m(ndx);
[dum,ndx] = min(ceil(siz(2)./n).*n-siz(2)); blk(2) = n(ndx);
if nargout==2,
mb = blk(1); nb = blk(2);
else
mb = blk;
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?