MATLAB代做  | MATLAB代写  | MATLAB有偿编程
首 页
当前位置:MATLAB代做|MATLAB代写|MATLAB有偿编程matlab源码图像分析
matlab图像代写编程路面裂缝检测识别系统设计        [↓跳到下载地址]
官方主页:源码共享网站:www.buycode.cn

联系方式:客服QQ:1747812398 买代码源码软件站,欢迎咨询

运行环境:Win9X/2000/XP/2003/

源码语言:简体中文

源码类型:源码程序 - 图像分析

推荐星级:

更新时间:2015-09-19 20:44:07

源码简介

function varargout = Gui_Main(varargin)
% GUI_MAIN M-file for Gui_Main.fig
%      GUI_MAIN, by itself, creates a new GUI_MAIN or raises the existing
%      singleton*.
%
%      H = GUI_MAIN returns the handle to a new GUI_MAIN or the handle to
%      the existing singleton*.
%
%      GUI_MAIN('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI_MAIN.M with the given input arguments.
%
%      GUI_MAIN('Property','Value',...) creates a new GUI_MAIN or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Gui_Main_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Gui_Main_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 Gui_Main

% Last Modified by GUIDE v2.5 29-Mar-2011 22:28:58

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
    'gui_Singleton',  gui_Singleton, ...
    'gui_OpeningFcn', @Gui_Main_OpeningFcn, ...
    'gui_OutputFcn',  @Gui_Main_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 Gui_Main is made visible.
function Gui_Main_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 Gui_Main (see VARARGIN)

% Choose default command line output for Gui_Main
handles.output = hObject;
handles.Result = [];
handles.File = [];
% Update handles structure
guidata(hObject, handles);
clc; warning off all;
InitAxes(handles);

% UIWAIT makes Gui_Main wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = Gui_Main_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 pushbuttonOpenFile.
function pushbuttonOpenFile_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonOpenFile (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({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
    '*.*','All Files' },'载入图像',...
    fullfile(pwd, 'images'));
I = imread(fullfile(pathname, filename));
Result = Process_Main(I);
handles.File = fullfile(pathname, filename);
handles.Result = Result;
guidata(hObject, handles);
InitAxes(handles)
axes(handles.axes1); imshow(handles.Result.Image); title('原图像');


% --- Executes on button press in pushbuttonHisteq.
function pushbuttonHisteq_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonHisteq (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.hist); title('直方图均衡化图像');
end

% --- Executes on button press in pushbuttonMedfilt.
function pushbuttonMedfilt_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonMedfilt (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.Medfilt); title('中值滤波图像');
end


% --- Executes on button press in pushbuttonBw.
function pushbuttonBw_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonBw (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
end

% --- Executes on button press in pushbuttonEnance.
function pushbuttonEnance_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonEnance (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.Enance); title('增强图像');
end

% --- Executes on button press in pushbuttonBwfilter.
function pushbuttonBwfilter_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonBwfilter (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
end

% --- Executes on button press in pushbuttonCrackRec.
function pushbuttonCrackRec_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonCrackRec (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.Bw); title('二值图像');
    axes(handles.axes3); imshow(handles.Result.BwFilter); title('二值图像滤波');
    axes(handles.axes4); imshow(handles.Result.CrackRec); title('裂缝识别');
end


% --- Executes on button press in pushbuttonCrackJudge.
function pushbuttonCrackJudge_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonCrackJudge (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
    axes(handles.axes3); imshow(handles.Result.CrackRec); title('裂缝识别');
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝判断');
end

% --- Executes on button press in pushbuttonCrackLoc.
function pushbuttonCrackLoc_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonCrackLoc (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title(handles.Result.str);
    axes(handles.axes4); imshow(handles.Result.CrackJudge); title('裂缝标记图像');
    hold on;
    rectangle('Position', handles.Result.rect, 'EdgeColor', 'g', 'LineWidth', 2);
    hold off;
end

% --- Executes on button press in pushbuttonProject.
function pushbuttonProject_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonProject (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.CrackJudge); title('裂缝图像');
    axes(handles.axes3); plot(1:size(handles.Result.Image, 1), handles.Result.Projectr);
    title('行投影');
    axes(handles.axes4); plot(1:size(handles.Result.Image, 2), handles.Result.Projectc);
    title('列投影');
end


% --- Executes on button press in pushbuttonClose.
function pushbuttonClose_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonClose (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
choice = questdlg('确定退出?', ...
    '退出', ...
    '是','否','否');
switch choice
    case '是'
        close;
    otherwise
        return;
end

% --- Executes on button press in pushbuttonSaveResult.
function pushbuttonSaveResult_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonSaveResult (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
try
    if ~isempty(handles.File)
        raw = [];
        xlsfile = fullfile(pwd, 'Result/result.xls');
        if exist(xlsfile, 'file')
            [num, txt, raw] = xlsread(xlsfile);
        end
       
        F = [];
        F{1, 1} = '文件名';
        F{1, 2} = '阈值信息';
        F{1, 3} = '面积信息';
        F{1, 4} = '长度信息';
        F{1, 5} = '最大宽度信息';
        F{1, 6} = '最小宽度信息';
        F{1, 7} = '形状信息';
       
        F{2, 1} = handles.File;
        F{2, 2} = handles.Result.BwTh;
        F{2, 3} = handles.Result.BwArea;
        F{2, 4} = handles.Result.BwLength;
        F{2, 5} = handles.Result.BwWidthMax;
        F{2, 6} = max(handles.Result.BwWidthMin,0.01);
        F{2, 7} = handles.Result.str;
       
        F = [raw; F];
        xlswrite(xlsfile, F);
       
        msgbox('保存结果成功!', '信息提示框');
    end
catch
    msgbox('保存结果失败,请检查程序!', '信息提示框');
end


% --- Executes on button press in pushbuttonBridge.
function pushbuttonBridge_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonBridge (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.Result)
    axes(handles.axes1); imshow(handles.Result.Image); title('原图像');
    axes(handles.axes2); imshow(handles.Result.BwFilter); title('二值图像滤波');
    axes(handles.axes3); imshow(handles.Result.CrackJudge); title('裂缝判断');
    axes(handles.axes4); imshow(handles.Result.CrackBridge); title('裂缝拼接');
end


% --- Executes on button press in pushbuttonSaveImage.
function pushbuttonSaveImage_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonSaveImage (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
[filename, pathname] = uiputfile({'*.jpg;*.tif;*.png;*.gif','All Image Files';...
    '*.*','All Files' },'Save Image',...
    fullfile(pwd, 'Result/result.png'));
if ~isequal(filename, 0)
    imwrite(handles.Result.BwEnd, fullfile(pathname, filename));
    msgbox('保存图像成功!', '信息提示框');
end


% --- Executes on button press in pushbuttonDiplay.
function pushbuttonDiplay_Callback(hObject, eventdata, handles)
% hObject    handle to pushbuttonDiplay (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
if ~isempty(handles.File)
    F = [];
    F{1} = sprintf('文件名:%s', handles.File);
    F{2} = sprintf('阈值信息%.2f', handles.Result.BwTh);
    F{3} = sprintf('面积信息%.2f', handles.Result.BwArea);
    F{4} = sprintf('长度信息%.2f', handles.Result.BwLength);
    F{5} = sprintf('最大宽度信息%.2f', handles.Result.BwWidthMax);
    F{6} = sprintf('最小宽度信息%.2f', max(handles.Result.BwWidthMin,0.01));
    F{7} = sprintf('形状信息%s', handles.Result.str);
    listdlg('PromptString', '参数显示:',...
        'Name', '参数信息', ...
        'ListSize', [300, 150], ...
        'SelectionMode','single',...
        'ListString', F);
end
 

function newim = adjgamma(im, g)
if nargin < 2
    g = 1;
end

if g <= 0
    error('Gamma参数必须大于0');
end
if ndims(im) == 3
    I = rgb2gray(im);
else
    I = im;
end
if isa(I,'uint8');
    newim = double(I);
else
    newim = I;
end
newim = newim-min(min(newim));
newim = newim./max(max(newim));
newim =  newim.^(1/g); 
 

function bwn = Bridge_Crack(bw)
[row, col] = size(bw);
[L, num] = bwlabel(bw);
bwn = bw;
if num < 2
    return;
end
stats = regionprops(L, 'BoundingBox');
for i = 1 : num
    l(i) = round(stats(i).BoundingBox(1) + 0.5);
    b(i) = round(stats(i).BoundingBox(2) - 0.5);
    r(i) = round(stats(i).BoundingBox(1) + stats(i).BoundingBox(3) - 1.5);
    rb(i) = round(stats(i).BoundingBox(2) + stats(i).BoundingBox(4));
end
l(l<=0) = 1;
b(b<=0) = 1;
r(r>=col) = col;
rb(rb>=row) = row;
try
    for i = 1 : num-1
        for j = b(i) : rb(i)
            if bw(j, r(i)) ~= 0
                break;
            end
        end
        for k = b(i+1) : rb(i+1)
            if bw(k, l(i+1)) ~= 0
                break;
            end
        end
        Yi = l(i+1); Ya = r(i);
        Xi=  k; Xa = j;
        d = Yi - Ya;
        e = Xa - Xi;
        if e>0
            if (d>e) || (d==e);
                for p = 1 : e
                    bw(j-p, r(i)+p) = 1;
                    bw(j-p-1, r(i)+p) = 1;
                    bw(j-p+1, r(i)+p) = 1;
                end
                for q = e+1 : d-1
                    bw(j-e, r(i)+q) = 1;
                    bw(j-e-1, r(i)+q) = 1;
                    bw(j-e+1, r(i)+q) = 1;
                end
            end
            if d<e
                for p = 1:d
                    bw(j-p, r(i)+d) = 1;
                    bw(j-p-1, r(i)+d) = 1;
                    bw(j-p+1, r(i)+d) = 1;
                end
                for q = d+1 : e-1
                    bw(j-q, r(i)+d) = 1;
                    bw(j-q, r(i)+d-1) = 1;
                    bw(j-q, r(i)+d+1) = 1;
                end
            end
            if d == 0;
                for p = 1 : e
                    bw(j-p, r(i)) = 1;
                    bw(j-p, r(i)-1) = 1;
                    bw(j-p, r(i)+1) = 1;
                end
            end
        end
        if e < 0
            e = abs(e);
            if (d>e) || (d==e)
                for p = 1:e;
                    bw(j+p, r(i)+p) = 1;
                    bw(j+p-1, r(i)+p) = 1;
                    bw(j+p+1, r(i)+p) = 1;
                end
                for q = e+1 : d-1
                    bw(j+e, r(i)+q) = 1;
                    bw(j+e-1, r(i)+q) = 1;
                    bw(j+e+1, r(i)+q) = 1;
                end
            end
            if d < e
                for p = 1 : d
                    bw(j+p, r(i)+p) = 1;
                    bw(j+p-1, r(i)+p) = 1;
                    bw(j+p+1, r(i)+p) = 1;
                end
                for q = d+1 : e-1
                    bw(j+q, r(i)+d) = 1;
                    bw(j+q, r(i)+d-1) = 1;
                    bw(j+q, r(i)+d+1) = 1;
                end
            end
            if d == 0
                for p = 1:e
                    bw(j+p, r(i)) = 1;
                    bw(j+p, r(i)-1) = 1;
                    bw(j+p, r(i)+1) = 1;
                end
            end
        end
        if e == 0
            for p = 1 : d
                bw(j, r(i)+p) = 1;
                bw(j-1, r(i)+p) = 1;
                bw(j+1, r(i)+p) = 1;
            end
        end
        if d<0
            for p = min(Xa, Xi) : max(Xa, Xi)
                for q = min(Ya, Yi) : max(Ya, Yi)
                    bw(p, q) = 1;
                end
            end
        end
    end
catch
    bwn = bw;
    return;
end
bwn = bw;
function bwn = bw_filter(bw, keepnum)
if nargin < 2
    keepnum = 15;
end
[L, num] = bwlabel(bw, 8);
Ln = zeros(1, num);
stats = regionprops(L, 'Area');
Ln = cat(1, stats.Area);
[Ln, ind] = sort(Ln);
if num>keepnum || num==keepnum
    for i = 1 : num-keepnum
        bw(L == ind(i)) = 0;
    end
end
bwn = bw;
function InitAxes(handles)
clc;
axes(handles.axes1); cla reset;
set(handles.axes1, 'XTick', [], 'YTick', [], ...
    'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000], 'Box', 'On');
axes(handles.axes2); cla reset;
set(handles.axes2, 'XTick', [], 'YTick', [], ...
    'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000], 'Box', 'On');
axes(handles.axes3); cla reset;
set(handles.axes3, 'XTick', [], 'YTick', [], ...
    'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000], 'Box', 'On');
axes(handles.axes4); cla reset;
set(handles.axes4, 'XTick', [], 'YTick', [], ...
    'XTickLabel', '', 'YTickLabel', '', 'Color', [0.7020 0.7804 1.0000], 'Box', 'On');

function [bw, th] = IterProcess(Img)
if ndims(Img) == 3
    I = rgb2gray(Img);
else
    I = Img;
end

T0 = (double(max(I(:))) + double(min(I(:))))/2;
flag = 1;

while flag
    ind1 = I > T0;
    ind2 = ~ind1;
    T1 = (mean(double(I(ind1))) + mean(double(I(ind2))))/2;
    flag = abs(T1-T0) > 0.5;
    T0 = T1;
end
bw = ind1;
th = T1;

function bwn = Judge_Crack(bw, Ig, th)
if nargin < 3
    th = 20;
end
[L, num] = bwlabel(bw);
Ig = im2uint8(mat2gray(Ig));
Ig = double(Ig);
stats = regionprops(L, 'Area', 'BoundingBox');
for i = 1 : num
    Ymin = round(stats(i).BoundingBox(1));
    Ymax = round(stats(i).BoundingBox(1) + stats(i).BoundingBox(3));
    Xmin = round(stats(i).BoundingBox(2));
    Xmax = round(stats(i).BoundingBox(2) + stats(i).BoundingBox(4));
    sum1(i) = 0;
    for k1 = Xmin : Xmax-1
        for k2 = Ymin : Ymax-1
            sum1(i) = sum1(i) + Ig(k1, k2);
        end
    end
    RectArea(i) = stats(i).BoundingBox(3)*stats(i).BoundingBox(4);
    Average1(i) = sum1(i)/RectArea(i);
    [r, c] = find(L == i);
    Ln(i) = length(find(L==i));
    for j = 1 : Ln(i)
        gv(i, j) = Ig(r(j), c(j));
    end
    sum2(i) = sum(gv(i, :));
    Average2(i) = sum2(i)/Ln(i);
    Sub(i) = abs(Average1(i) - Average2(i));
    if Sub(i) < th
        bw(find(L==i)) = 0;
    end
end
bwn = bw;


提 示:本站所有源码只提供浏览,需要定制的朋友可以联系在线客服!
注意:价格根据项目的难易程度来定价格业务咨询

matlab图像代写编程路面裂缝检测识别系统设计 --下载地址

注意:为避免不必要的误会,本站项目里的源码只公开部分需要的联系在线客服

本站长期招聘程序代写高手,欢迎加入华南地区matlab团队

想创业却没有经验的人

无论你是否有过网上开店的经验,都可以随时联系在线客服,建立自己独立的网站
想开网店却不知道如何入手

淘宝创业成本低而且风险小,如果想开淘宝店的朋友可以联系在线客服。
想兼职创业,却不擅长交际与服务的人

在家创业月入5000元。网站程序+百套群发工具+网赚资料+域名+空间+本站终身代理资格,这样你网赚的条件全具备了。每天3小时管理、推广、收钱。
缺乏能快速赢利型产品的人

导入多种最新流行营销软件+网赚教程,让入驻者轻松加盟、复制有效成交技巧、快速赚钱。

源码评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

浏览说明

* 本站所有源码全部公开,随时随地浏览!
* MATLAB软件如用于商业用途,请购买正版!
* 如果您发现下载链接错误,请点击报告错误谢谢!
* 站内提供的所有软件包含破解及注册码均是由网上搜集,若侵犯了你的版权利益,敬请来信通知我们!
Copyright © 2008-2014 www.buycode.cn. All Rights Reserved.
页面执行时间:234.37500 毫秒