iroi.m

来自「来自澳大利亚Qeensland大学的计算机视觉Matlab工具箱。 This 」· M 代码 · 共 67 行

M
67
字号
%IROI	Extract region of interest from current image figure%%	si = IROI(image)%	[si,region] = IROI(image)%%	si = IROI(image,region)%%	The first two forms display the image and a rubber band box to%	allow selection of the region of interest.%	The selected subimage s output and optionally the coordinates of %	the region selected which is of the form [top bottom; left right].%%	The last form uses a previously created region matrix and outputs the%	corresponding subimage.  Useful for chopping the same region out of%	a different image.%%% SEE ALSO:	image, idisp%%	Copyright (c) Peter Corke, 1999  Machine Vision Toolbox for Matlab% 1995 Peter Corkefunction [im, region] = iroi(image, reg)	if nargin == 2,		im = image(reg(1,1):reg(2,1),reg(1,2):reg(2,2));	else		% save old event handlers, otherwise may interfere with		% other tools operating on the figure, eg. idisp()		upfunc = get(gcf, 'WindowButtonUpFcn');		downfunc = get(gcf, 'WindowButtonDownFcn');		set(gcf, 'WindowButtonUpFcn', '');		set(gcf, 'WindowButtonDownFcn', '');		% get the rubber band box		waitforbuttonpress		f = gcf;		cp0 = get(gcf, 'CurrentPoint');		c0 = floor( get(gca, 'CurrentPoint') );		% top left		rect = [cp0 16 16];		rbbox(rect, cp0);			% return on up click		%disp('rbbox done, restore handlers');		% restore event handlers		set(gcf, 'WindowButtonUpFcn', upfunc);		set(gcf, 'WindowButtonDownFcn', downfunc);		c1 = floor( get(gca, 'CurrentPoint') );		% bottom right		ax = get(gca, 'Children');		img = get(ax, 'CData');			% get the current image		top = c0(1,2);		left = c0(1,1);		bot = c1(1,2);		right = c1(1,1);		im = img(top:bot,left:right);		if nargout == 2,			region = [top left; bot right];		end	end

⌨️ 快捷键说明

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