1 简介

Hough变换是图像处理中从图像中识别几何形状的基本方法之一.Hough变换的基本原理在于利用点与线的对偶性,将原始图像空间给定的曲线通过曲线表达形式变为参数空间的一个点.这样就把原始图像中给定曲线的检测问题转化为寻找参数空间中的峰值问题.也即把检测整体特性转化为检测局部特性.本文试图以matlab为工具,通过matlab编程仿真,利用hough变换和曲线拟合算法,在图像空间中识别出三角形,矩形和圆.

经典 Hough 变换检测是通过将图像域中的图形映射到 Hough 参数域内,根据某一解析式将图形上的每个点投影到参数域中,并进行简单的累加统计,然后寻找累加峰值的方法检测图形。而广义 Hough 变换是先按照一定规则抽取图形中的多个像素点,采用某一解析公式将这些像元映射到参数空间对应点,再对这些对应点进行投票表决的参数估计技术。在参数空间不超过二维的情况下,这种检测方法有着理想的效果。

2 部分代码

function varargout = HoughObject(varargin)
% HOUGHOBJECT M-file for HoughObject.fig
%     HOUGHOBJECT, by itself, creates a new HOUGHOBJECT or raises the existing
%     singleton*.
%
%     H = HOUGHOBJECT returns the handle to a new HOUGHOBJECT or the handle to
%     the existing singleton*.
%
%     HOUGHOBJECT('CALLBACK',hObject,eventData,handles,...) calls the local
%     function named CALLBACK in HOUGHOBJECT.M with the given input arguments.
%
%     HOUGHOBJECT('Property','Value',...) creates a new HOUGHOBJECT or raises the
%     existing singleton*. Starting from the left, property value pairs are
%     applied to the GUI before HoughObject_OpeningFunction gets called. An
%     unrecognized property name or invalid value makes property application
%     stop. All inputs are passed to HoughObject_OpeningFcn via varargin.
%
%     *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
%     instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help HoughObject
% Last Modified by GUIDE v2.5 07-Dec-2005 20:15:07
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
'gui_Singleton',  gui_Singleton, ...
'gui_OpeningFcn', @HoughObject_OpeningFcn, ...
'gui_OutputFcn',  @HoughObject_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback',   []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before HoughObject is made visible.
function HoughObject_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
% varargin   command line arguments to HoughObject (see VARARGIN)
% Choose default command line output for HoughObject
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes HoughObject wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = HoughObject_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject   handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles   structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;

3 仿真结果

【图像检测】基于Hough变换实现形状检测matlab代码_对应点

【图像检测】基于Hough变换实现形状检测matlab代码_图像空间_02

【图像检测】基于Hough变换实现形状检测matlab代码_对应点_03

4 参考文献

[1]邱伟江. "基于HOUGH变换简单形状识别的研究." 高职论丛 4(2009):3.

部分理论引用网络文献,若有侵权联系博主删除。

【图像检测】基于Hough变换实现形状检测matlab代码_对应点_04