filter_edge_sobelprewitt.m

来自「这是采用Matlab编写的车牌识别程序,好不好下了就知」· M 代码 · 共 57 行

M
57
字号
function varargout = filter_edge_sobelprewitt(varargin)

if nargin == 0
	p1 = struct( ...
		'Name',					'Method', ...
		'Style',				'popup', ...
		'DefaultValue',			1, ...
		'Items',				{ {'Sobel', 'Prewitt'} } );
	p2 = struct( ...
		'Name',					'Threshold', ...
		'Style',				'single', ...
		'DefaultValue',			0.5, ...
		'Max',					1, ...
		'Min',					0, ...
		'LargeStep',			1 / 10, ...
		'SmallStep',			1 / 100);
	p3 = struct( ...
		'Name',					'Automatic threshold', ...
		'Style',				'check', ...
		'DefaultValue',			0);
	p4 = struct( ...
		'Name',					'Direction', ...
		'Style',				'popup', ...
		'DefaultValue',			1, ...
		'Items',				{ {'Both', 'Horizontal', 'Vertical'} } );
	P = struct( ...
		'FilterName',			'Sobel/Prewitt edge detection', ...
		'AvailableImageType',	[0 0 0 1 0], ...
		'Class',				'edge', ...
		'ParameterNumber',		4, ...
		'Parameters', 			{ { p1, p2, p3, p4} });
	varargout{1} = P;
else
	CX = varargin{1};
	FUNPARA = varargin{2};
	switch FUNPARA{1}
	case 1
		method = 'sobel';
	case 2
		method = 'prewitt';
	end
	if ~FUNPARA{3}
		threshold = FUNPARA{2};
	else
		threshold = [];
	end
	switch FUNPARA{4}
	case 1
		direction = 'both';
	case 2
		direction = 'horizontal';
	case 3
		direction  = 'vertical';
	end
	BW = edge(CX, method, threshold, direction);
	varargout{1} = BW;
end

⌨️ 快捷键说明

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