天天看點

【角點檢測】 基于各向異性高斯方向導數濾波器實作圖像角點檢測附matlab代碼

1 内容介紹

為了改進噪聲魯棒性和定位準确性,利用各向異性高斯方向導數濾波器,提出多方向角點檢測算法.該算法利用一組各向異性高斯方向導數濾波器對輸入圖像進行卷積處理得到各個方向的濾波器響應.對于每個像素點,利用它與周圍鄰近像素點的濾波器響應的相關資訊構造局部自相關矩陣,然後根據自相關矩陣歸一化特征值及像素點處各方向濾波器響應,作門檻值處理和非極大值抑制處理判定像素點是否為角點.實驗結果表明,在無噪聲和噪聲的條件下,提出的檢測方法與各向同性高斯核函數的Harris算法相比,配準角點數均提高6.0%左右,具有更好的檢測性能.

2 部分代碼

function varargout = ch3(varargin)

% CH3 M-file for ch3.fig

%      CH3, by itself, creates a new CH3 or raises the existing

%      singleton*.

%

%      H = CH3 returns the handle to a new CH3 or the handle to

%      the existing singleton*.

%

%      CH3('CALLBACK',hObject,eventData,handles,...) calls the local

%      function named CALLBACK in CH3.M with the given input arguments.

%

%      CH3('Property','Value',...) creates a new CH3 or raises the

%      existing singleton*.  Starting from the left, property value pairs are

%      applied to the GUI before ch3_OpeningFunction gets called.  An

%      unrecognized property name or invalid value makes property application

%      stop.  All inputs are passed to ch3_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 ch3

% Last Modified by GUIDE v2.5 10-Oct-2021 08:46:09

% Begin initialization code - DO NOT EDIT

gui_Singleton = 1;

gui_State = struct('gui_Name',       mfilename, ...

                   'gui_Singleton',  gui_Singleton, ...

                   'gui_OpeningFcn', @ch3_OpeningFcn, ...

                   'gui_OutputFcn',  @ch3_OutputFcn, ...

                   'gui_LayoutFcn',  [] , ...

                   'gui_Callback',   []);

if nargin & isstr(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 ch3 is made visible.

function ch3_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 ch3 (see VARARGIN)

% Choose default command line output for ch3

handles.output = hObject;

% Update handles structure

guidata(hObject, handles);

% UIWAIT makes ch3 wait for user response (see UIRESUME)

% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.

function varargout = ch3_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;

% --------------------------------------------------------------------

function Files_Callback(hObject, eventdata, handles)

% hObject    handle to Files (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------

function Open_Callback(hObject, eventdata, handles)

% hObject    handle to Open (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

[filename,pathname]=uigetfile({'*.bmp'},'選擇圖檔');

global str;

if isequal(filename,0)

    disp('Users Selected Canceled');

else

str=[pathname filename];

handles.str=str;

guidata(hObject,handles);

im = imread(str);

axes(handles.OImageDisplay);

imshow(im);

end;

% --------------------------------------------------------------------

function det_Callback(hObject, eventdata, handles)

% hObject    handle to det (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

% --------------------------------------------------------------------

function Hardet_Callback(hObject, eventdata, handles)

% hObject    handle to Untitled_2 (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

% handles    structure with handles and user data (see GUIDATA)

%清屏,是以變量置零

%記錄檢測的角點數

count=0;

for i1=2:height-1;

  for j1=2:width-1

  % 在3*3視窗範圍内尋找局部最大值點作為檢測出的角點

  a=[R(i1-1,j1-1) R(i1-1,j1) R(i1-1,j1+1) R(i1,j1-1) R(i1,j1+1) R(i1+1,j1-1) R(i1+1,j1) R(i1+1,j1+1)];

  if R(i1,j1)>0.01*Rmax && R(i1,j1)>max(a)

  Result(i1,j1)=1;

  count=count+1;

  end

  end

end

% 紀錄角點位置

[posr,posc]=find(Result==1);

 % 輸出角點個數  

%fprintf('檢測到的角點數count=%d\n',count);

set(handles.text3,'String',num2str(count));

axes(handles.DetImage);

imshow(image);   

hold on;

%角點處畫+

plot(posc,posr,'r+');

3 運作結果

【角點檢測】 基于各向異性高斯方向導數濾波器實作圖像角點檢測附matlab代碼

4 參考文獻

[1]周文天 李軍民 唐慧娟 李科. 基于高斯差分濾波和形态學濾波的Harris角點檢測算法[J]. 西華大學學報:自然科學版, 2014, 33(6):4.

部落客簡介:擅長​​智能優化算法​​、​​神經網絡預測​​、​​信号處理​​、​​元胞自動機​​、​​圖像處理​​、​​路徑規劃​​、​​無人機​​、​​雷達通信​​、​​無線傳感器​​等多種領域的Matlab仿真,相關matlab代碼問題可私信交流。

部分理論引用網絡文獻,若有侵權聯系部落客删除。