一、简介
模型参考这里。
二、源代码
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
axes(handles.axes2);
imshow(im2);
% --- Executes on button press in .
%function _Callback(hObject, eventdata, handles)
% hObject handle to (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in junhenghua.
function junhenghua_Callback(hObject, eventdata, handles)
% hObject handle to junhenghua (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=~im1;
%im1=bwmorph(im1,'thin',Inf);
%th1=graythresh(im1);
%im1=im2bw(im1,th1);
im1=histeq(im1);
axes(handles.axes1);
imshow(im1);
%im2=double(im2);
%im2=histeq(im2);
%th2=graythresh(im2);
%im2=im2bw(im2,th2);
im2=histeq(im2);
axes(handles.axes2);
imshow(im2);
% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in huiduhua.
function huiduhua_Callback(hObject, eventdata, handles)
% hObject handle to huiduhua (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
%[d1,d2,d3] = size(im1);
%if(d3 > 1)
im1=rgb2gray(im1);
%end
%im1= double(im1) / 255;
%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);
%im2=double(im2);
im2=medfilt2(im2);
axes(handles.axes2);
imshow(im2);
三、运行结果
四、参考文献
[1]步红刚, 黄秀宝, 汪军. 基于多分形特征参数的织物瑕疵检测[J]. 计算机工程与应用, 2007, 43(036):233-237.
博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。
部分理论引用网络文献,若有侵权联系博主删除。