im_fill_norm.m

来自「The pattern recognition matlab toolbox」· M 代码 · 共 33 行

M
33
字号
%IM_FILL_NORM Fill and normalize image for display puproses
%
%   B = IM_FILL_NORM(A,N)
%
%Low level routine for the DATAFILE/SHOW command to display non-square
%images of the datafile A, inside square of NxN pixels. Empty areas are
%filled with gray.

function b = im_fill_norm(a,n)

if isa(a,'dataset')
	isobjim(a);
  b = filtim(a,'im_fill_norm',{n});
else
	a = double(a);
	[x,y] = size(a);
	mx = max(a(:));
	mn = min(a(:));
	a = (a - mn)/(mx-mn+eps);
	b = 0.5*ones(n,n);
	z = floor(n/2);
	if x > y
		a = imresize(a,round(n*[x,y]/x));
		k = size(a,2);
		s = floor((n-k)/2)+1;
		b(:,s:s+k-1) = a;
	else
		a = imresize(a,round(n*[x,y]/y));
		k = size(a,1);
		s = floor((n-k)/2)+1;
		b(s:s+k-1,:) = a;
	end
end

⌨️ 快捷键说明

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