1 简介
纹理分析是图像处理中一种十分重要的方法.通过纹理分析,利用灰度共生矩阵惯性矩特征值能够反映图像灰度空间复杂度的特性,成功获取了LOG边缘检测算子最佳空间系数,抑制了图像中的大部分噪声.并通过基于TMS320C6000专用信号处理器的图像处理系统实现了图像边缘检测的自动提取.实验结果表明,采用这种方法可以取得很好的噪声抑制效果,并且检测出的边缘精度高,实时性强,便于实现.
2 部分代码
function varargout = td(varargin)
% TD M-file for td.fig
% TD, by itself, creates a new TD or raises the existing
% singleton*.
%
% H = TD returns the handle to a new TD or the handle to
% the existing singleton*.
%
% TD('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in TD.M with the given input arguments.
%
% TD('Property','Value',...) creates a new TD or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before td_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to td_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
% Copyright 2002-2003 The MathWorks, Inc.
% Edit the above text to modify the response to help td
% Last Modified by GUIDE v2.5 12-May-2015 11:29:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @td_OpeningFcn, ...
'gui_OutputFcn', @td_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 td is made visible.
function td_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 td (see VARARGIN)
% Choose default command line output for td
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes td wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = td_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;
% --- Executes on button press in open1.
function open1_Callback(hObject, eventdata, handles)
% hObject handle to open1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im1
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.png'},'select picture'); %••••••••••••••••••§••••••••••§••••••
%••••••••••••••§••••••••••§•••••••••••••
str=[pathname filename];
%••••••••••••••••
im1=imread(str);
%•••••••••••axes••••
axes(handles.axes1);
imshow(im1);
% --- Executes on button press in open2.
function open2_Callback(hObject, eventdata, handles)
% hObject handle to open2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im2
[filename,pathname]=uigetfile({'*.jpg';'*.bmp';'*.tif';'*.png'},'select picture'); %••••••••••••••••••§••••••••••§••••••
%••••••••••••••§••••••••••§•••••••••••••
str=[pathname filename];
%••••••••••••••••
im2=imread(str);
%•••••••••••axes••••
%im1= uint8(255 * im1* 0.5 + 0.5);
%th=graythresh(im1);
%im1=im2bw(im1,th);
axes(handles.axes1);
imshow(im1);
im2=rgb2gray(im2);
%th=graythresh(im2);
%im2=im2bw(im2,th);
axes(handles.axes2);
imshow(im2);
% --- Executes during object creation, after setting all properties.
function text1_CreateFcn(hObject, eventdata, handles)
% hObject handle to text1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on button press in quzao.
function quzao_Callback(hObject, eventdata, handles)
% hObject handle to quzao (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global im1
global im2
%im1=double(im1);
im1=medfilt2(im1);
axes(handles.axes1);
imshow(im1);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
end
function dui1_Callback(hObject, eventdata, handles)
% hObject handle to dui1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of dui1 as text
% str2double(get(hObject,'String')) returns contents of dui1 as a double
% --- Executes during object creation, after setting all properties.
function dui1_CreateFcn(hObject, eventdata, handles)
% hObject handle to dui1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function xiang1_Callback(hObject, eventdata, handles)
% hObject handle to xiang1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of xiang1 as text
% str2double(get(hObject,'String')) returns contents of xiang1 as a double
% --- Executes during object creation, after setting all properties.
function xiang1_CreateFcn(hObject, eventdata, handles)
% hObject handle to xiang1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function shang2_Callback(hObject, eventdata, handles)
% hObject handle to shang2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of shang2 as text
% str2double(get(hObject,'String')) returns contents of shang2 as a double
% --- Executes during object creation, after setting all properties.
function shang2_CreateFcn(hObject, eventdata, handles)
% hObject handle to shang2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function jieguo_CreateFcn(hObject, eventdata, handles)
% hObject handle to jieguo (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on button press in tuichu.
function tuichu_Callback(hObject, eventdata, handles)
% hObject handle to tuichu (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close;
% --- Executes on button press in suanfa.
function suanfa_Callback(hObject, eventdata, handles)
% hObject handle to suanfa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%global jiao1 jiao2 xiang1 xiang2 dui1 dui2 shang1 shang2
%G=sqrt(0.25*((jiao1-jiao2)*(jiao1-jiao2)+(dui1-dui2)*(dui1-dui2)+(xiang1-xiang2)*(xiang1-xiang2)+(shang1-shang2)*(shang1-shang2)));
%set(handles.jieguo,'string',num2str(G));
global G
str1=['两组特征匹配成功,判定为同一工具'];
str2=['两组特征匹配失败,判定为不同工具'];
if G<0.06
set(handles.jieguo,'string',str1);
end
if G>=0.06
se(handles.jieguo,'string',str2);
end
3 仿真结果
4 参考文献
[1]赵海涛, 董介春, and 张屹. "基于灰度共生矩阵的自适应图像边缘检测." 微计算机信息 06Z(2006):3.