⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 suzy_080505_1.m

📁 一个基于GUI的界面系统设计的程序
💻 M
📖 第 1 页 / 共 2 页
字号:
function varargout = suzy_080505_1(varargin)

 %定义全局变量
global tthh


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

% Last Modified by GUIDE v2.5 26-May-2008 11:42:57

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

% Choose default command line output for suzy_080505_1
handles.output = hObject;
cla reset

% Update handles structure
guidata(hObject, handles);

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

% --- Outputs from this function are returned to the command line.
function varargout = suzy_080505_1_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;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%以下BACK原始图片按钮★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes during object creation, after setting all properties.
function BACK_YSTP_CreateFcn(hObject, eventdata, handles)
% hObject    handle to BACK_YSTP (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
%以上BACK原始图片按钮★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下导入原始图像★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_DRTU.
function BTN_DRTU_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_DRTU (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';'*.gif';;'*.bmp';'*.*'},'Query Image Selector');  %选择图片路径
str=[pathname filename];                  %合成路径 文件名
imm=imread(str);                          %读取图片
axes(handles.axes1_ZBZ);                      %使用一个axes

h=waitbar(0,'正在处理图片,请稍等...');  %★★★进度条
for i=1:0.05:200
waitbar(i/50,h)
end
close(h)                               %★★★进度条

imshow(imm);                              %显示图片
title('原始图像')
setappdata(gcf,'A',imm);
%以上导入图像★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下清除原始图片★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_QCTX.
function BTN_QCTX_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_QCTX (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

%回调函数
%plot(1,1);或者
imm=getappdata(gcf,'A');
cla reset
axes(handles.axes1_ZBZ);
imagesc(imm);
%以上清除原始图片结束★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%以下BACK图片处理★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes during object creation, after setting all properties.
function BACK_TXCL_CreateFcn(hObject, eventdata, handles)
% hObject    handle to BACK_TXCL (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
%以上BACK系统退出★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下灰度直方图★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_HDZFT.
function BTN_HDZFT_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_HDZFT (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of BTN_HDZFT

%以下灰度直方图回调函数
imm=getappdata(gcf,'A');
im=rgb2gray(imm);

h=waitbar(0,'正在处理图片,请稍等...');  %进度条
for i=1:0.05:200
waitbar(i/50,h)
end
close(h)                                %进度条

axes(handles.axes3_);
imhist(im);
axis([0 255 0 1000]);
title('灰度直方图')

imwrite(im,'huidu.bmp','bmp');
setappdata(gcf,'B',im);


% guidata(hObject, handles);
%以上灰度直方图★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下叶面图像分割★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_TXFG.
function BTN_TXFG_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_TXFG (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of BTN_TXFG

%图像分割回调函数
imm=getappdata(gcf,'A');
im=getappdata(gcf,'B');

[m,n]=size(im);
str=double(im);


h=waitbar(0,'正在处理图片,请稍等...');  %进度条
for i=1:0.05:200
waitbar(i/50,h)
end
close(h)                                %进度条

k=0;
for th=10:120
    u1=0;
    u2=0;
    n1=0;
    n2=0;
    pix1=0;
    pix2=0;
    for i=1:m
        for j=1:n
            if str(i,j)<th
                pix1=pix1+str(i,j);
                n1=n1+1;
            else
                pix2=pix2+str(i,j);
                n2=n2+1;
            end
        end
    end
    u1=pix1/n1;
    u2=pix2/n2;
    k=k+1;
    s(k)=((u2-th+eps)*(th-u1+eps))/((u2-u1+eps)^2);
end
ss=max(s);
for i=1:k
    if s(i)==ss
        tthh=i;
    end
end
tthh
for i=1:m
    for j=1:n
        if str(i,j)<tthh
            str(i,j)=255;
        end
    end
end
str=uint8(str);


imwrite(str,'fenge.bmp','bmp');
fg=imread('erzhihua2.bmp');
axes(handles.axes2_ZBZ);
imshow(fg);
setappdata(gcf,'C',str);

%clc

%guidata(hObject, handles);
%以上叶面图像分割★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下叶片去噪声★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_YPQZ.
function BTN_YPQZ_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_YPQZ (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of BTN_YPQZ
%回调函数
imm=getappdata(gcf,'A');
im=getappdata(gcf,'B');
str=getappdata(gcf,'C');

[m,n]=size(str);
for i=1:m
    for j=1:n
        if str(i,j)>200
            str(i,j)=255;
        end
    end
    
end
axes(handles.axes2_ZBZ);
imagesc(str);

guidata(hObject, handles);

clc
%以上叶片去噪声★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下病害部位分割提取★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_BHFG.
function BTN_BHFG_Callback(hObject, eventdata, handles)
% hObject    handle to BTN_BHFG (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hint: get(hObject,'Value') returns toggle state of BTN_BHFG

%回调函数
imm=getappdata(gcf,'A');
im=getappdata(gcf,'B');
str=getappdata(gcf,'C');
im=imm
str=rgb2gray(im);
[m,n]=size(str);
str=double(str);
for i=1:m
    for j=1:n
        if str(i,j)>200
            str(i,j)=255;
        end
    end
end
for i=1:m
    for j=1:n
        if str(i,j)<230&str(i,j)>5
            str(i,j)=0;
        end
    end
end
str=uint8(str);

axes(handles.axes4_);

h=waitbar(0,'正在处理图片,请稍等...');  %进度条
for i=1:0.05:200
waitbar(i/50,h)
end
close(h)                                %进度条

imagesc(str);

%以上病害部位分割提取★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★

%以下病害去噪★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★
% --- Executes on button press in BTN_BHQZ.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -