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

📄 imuiconv.m

📁 这是采用Matlab编写的车牌识别程序,好不好下了就知
💻 M
字号:
function CY = imuiconv(varargin)
%IMUICONV Image Convoluation
%    Member of IMUI
%    Kotaimen.C, 2002/05 - 2002/07, All Rights Reserved

error(nargchk(1, 1, nargin))

if ~ischar(varargin{1})
	Action = '::::BuildGUI';
	CX = varargin{1};
	CPREV = thumb(CX);
	if isgray(CPREV)
		CPREV = cat(3, CPREV, CPREV, CPREV);
	end
else
	Action = varargin{1};
	ud = get(gcf, 'UserData');
end

switch Action
case '::::BuildGUI'
	ud.fig = figure( ...
		'Position',			[0 0 495 435], ...
		'Name',				'Convoluation', ...
		'BackingStore',		'on', ...
		'Menubar',			'none', ...
		'NumberTitle',		'off', ...
		'Resize',			'off', ...
		'HandleVisibility', 'on', ...
		'WindowStyle',		'modal', ...
		'Interruptible', 	'off', ...
		'Visible',			'off');

	ud.cmnu = uicontextmenu( 'Parent', ud.fig );
	ud.colormap = uimenu( ud.cmnu, 'Label', '&Colormap');
	ud.alpha = uimenu( ud.cmnu, 'Label', '&Transparency');
	colormaps = { ...
		'hsv','hot','gray','bone','copper','pink','white','flag', ...
		'lines','colorcube','vga','jet','prism','cool','autumn', ...
		'spring','winter','summer'};
	for i = 1 : length(colormaps)
		uimenu( ud.colormap, ...
			'Label',			['&', char(i + 64 ), ' - ',colormaps{i}], ...
			'UserData',			colormaps{i}, ...
			'Callback',			'colormap(get(gcbo, ''UserData''))')
	end
	for i = 0 : 10
		switch i
		case 0
			uimenu( ud.alpha, ...
				'Label',			'&Clear ', ...
				'Callback',			'alpha(''clear'')')
		case 10
			uimenu( ud.alpha, ...
				'Label',			'&Opaque ', ...
				'UserData',			i/10, ...
				'Callback',			'alpha(''opaque'')')
		otherwise
			uimenu( ud.alpha, ...
				'Label',			['&', num2str(i), ' - Alpha ',num2str(i/10)], ...
				'UserData',			i/10, ...
				'Callback',			'alpha(get(gcbo, ''UserData''))')
		end
	end

	ud.txt1  = uicontrol( ...
		'Style',			'text', ...
		'Units',			'pixel', ...
		'Position',			[15 393 465 30], ...
		'HorizontalAlignment', 'left', ...
		'String',			sprintf([ ...
							'Enter convolution kenel below,\n', ...
							'Both workspace variables and expression can be used :'...
							]));
	ud.edt  = uicontrol( ...
		'Style',			'edit', ...
		'Units',			'pixel', ...
		'Position',			[15 370 465 22], ...
		'BackgroundColor',	'w', ...
		'HorizontalAlignment', 'left', ...
		'FontName',			'Courier New', ...
		'FontSize',			9, ...
		'String',			'[0 -1 0; -1 5 -1; 0 -1 0]', ...
		'Callback',			'imuiconv(''::::cb_UpdatePreview'')');

	ud.update  = uicontrol( ...
		'Style',			'pushbutton', ...
		'Units',			'pixel', ...
		'Position',			[15 340 110 24 ], ...
		'String',			'Update preview', ...
		'Callback',			'imuiconv(''::::cb_UpdatePreview'')');
	ud.chk  = uicontrol( ...
		'Style',			'checkbox', ...
		'Units',			'pixel', ...
		'Position',			[150 340 150 24 ], ...
		'String',			'Normalized', ...
		'Value',			1, ...
		'Callback',			'imuiconv(''::::cb_UpdatePreview'')');
	ud.fr = axes( ...
		'Units',			'pixel', ...
		'Position',			[40 40 256 256], ...
		'Color',			'k', ...
		'DrawMode',			'fast', ...
		'XGrid',			'on', ...
		'YGrid',			'on', ...
		'FontSize',			8);
	[H, fx, fy] = freqz2([0 -1 0; -1 5 -1; 0 -1 0], [48 48]);
	ud.hsurf= surf(linspace(-1, 1, size(H,1)),linspace(-1, 1, size(H,2)),  H);
	title('\bf\fontsize{9}Frequency Response  ')
	xlabel('\bfFrequency_X')
	ylabel('\bfFrequency_Y')
	zlabel('\bfMagnitude')
	set(ud.hsurf, ...
		'EdgeAlpha',		0.2, ...
		'FaceAlpha',		0.6, ...
		'EraseMode',		'normal', ...
		'FaceColor',		'interp', ...
		'EdgeLighting',		'phong', ...
		'FaceLighting',		'phong', ...
		'CDataMapping',		'scaled', ...
		'UIContextMenu',	ud.cmnu)
	set(ud.fr, ...
		'XLim',				[-1 1], ...
		'YLim',				[-1 1], ...
		'XTick', 			[-1 -0.5 0 0.5 1], ...
		'YTick', 			[-1 -0.5 0 0.5 1])
	axis square
	ud.preview = axes( ...
		'Units',			'pixel', ...
		'Position',			[350 185 128 128]);
	ud.img = imshow(imfilter(CPREV, [0 -1 0; -1 5 -1; 0 -1 0], 'replicate'), 'notruesize');
	set(ud.preview, ...
		'Visible',			'off', ...
		'DrawMode',			'fast')
	set(ud.img, ...
		'UserData', 		CPREV, ...
		'EraseMode',		'xor')

	ud.apply  = uicontrol( ...
		'Style',			'pushbutton', ...
		'Units',			'pixel', ...
		'Position',			[377 125 75 24 ], ...
		'FontWeight',		'bold', ...
		'String',			'Apply', ...
		'Callback',			'imuiconv(''::::cb_apply'')');
	ud.cancel  = uicontrol( ...
		'Style',			'pushbutton', ...
		'Units',			'pixel', ...
		'Position',			[377 85 75 24 ], ...
		'FontWeight',		'bold', ...
		'String',			'Cancel', ...
		'Callback',			'imuiconv(''::::cb_cancel'')');

	movegui(ud.fig, 'center')
	set(ud.fig, ...
		'Visible', 			'on', ...
		'UserData',			ud, ...
		'Color',			get(0, 'DefaultUIControlBackgroundColor'), ...
		'CloseRequestFcn',	'imuiconv(''::::cb_cancel'')' );

	waitfor(ud.fig, 'Visible', 'off')

	if strcmp('apply', get(ud.apply, 'UserData'))

		h = waitfig('Applying Convoluation');
		convkernel = deblank(get(ud.edt, 'String'));
		convkernel = evalin('base', convkernel);

		if get(ud.chk, 'Value')
			temp = abs(sum(sum(convkernel)));
			if temp ~= 0
				convkernel = convkernel ./ temp;
			end
		end

		CY = imfilter(CX, convkernel, 'replicate');

		delete(h)
	else
		CY = -1;
	end
	delete(ud.fig)

%=====================================================================
case '::::cb_UpdatePreview'
	convkernel = deblank(get(ud.edt, 'String'));
	try
		convkernel = evalin('base', convkernel);

		if get(ud.chk, 'Value')
			temp = abs(sum(sum(convkernel)));
			if temp ~= 0
				convkernel = convkernel ./ temp;
			end
		end

		[H, fx, fy] = freqz2(convkernel, [48 48]);
		set(ud.hsurf, ...
			'ZData', 	H, ...
			'CData',	H)
		CX = get(ud.img, 'UserData');
		set(ud.img, 'CData', imfilter(CX, convkernel, 'replicate'));
	catch
		prompt = sprintf(['Error while evaluatng:\n\\bf', ...
					convkernel , '\\rm. \n\n', lasterr]);
		h = errordlg(prompt, 'Convoluation', ...
			struct('Interpreter', 'tex', 'WindowStyle', 'modal') );
	end
%=====================================================================
case '::::cb_apply'
	imuiconv('::::cb_UpdatePreview')
	set(ud.apply, 'Userdata', 'apply')
	set(ud.fig, 'Visible', 'off')
%=====================================================================
case '::::cb_cancel'
	set(ud.apply, 'Userdata', 'cancel')
	set(ud.fig, 'Visible', 'off')
end

⌨️ 快捷键说明

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