max2d.m

来自「这是一个基于MATLAB的机器视觉工具箱,里面用很多非常有价值的的程序」· M 代码 · 共 42 行

M
42
字号
%MAX2d	Maximum of image%%	[r,c] = max2d(image)%%	Return the interpolated coordinates (r,c) of the greatest peak in image.%% SEE ALSO:	ihough xyhough%%	Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab% 1996 Peter Corkefunction [r,c] = max2d(im)	ncols = numcols(im);	nrows = numrows(im);	[mx,where] = max(im);	[mx2,where2] = max(mx);	c = where2;	r = where(where2);	% now try to interpolate the peak over a 3x3 window	dx = [		c-1 c c+1		c-1 c c+1		c-1 c c+1];	dy = [		r-1 r-1 r-1		r   r  r		r+1   r+1  r+1];	% can't interpolate if against an edge	if (c>1) & (c<ncols) & (r>1) & (r<nrows),		p = im(r-1:r+1,c-1:c+1);		c = sum(sum(dx.*p)) / sum(sum(p));		r = sum(sum(dy.*p)) / sum(sum(p));	end

⌨️ 快捷键说明

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