一、图像分割简介

理论知识参考:【基础教程】基于matlab图像处理图像分割【含Matlab源码 191期】

二、部分源代码

function varargout = GARoadCut(varargin)
% GAROADCUT MATLAB code for GARoadCut.fig
%      GAROADCUT, by itself, creates a new GAROADCUT or raises the existing
%      singleton*.
%
%      H = GAROADCUT returns the handle to a new GAROADCUT or the handle to
%      the existing singleton*.
%
%      GAROADCUT('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GAROADCUT.M with the given input arguments.
%
%      GAROADCUT('Property','Value',...) creates a new GAROADCUT or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before GARoadCut_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to GARoadCut_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 GARoadCut% Last Modified by GUIDE v2.5 02-Jan-2019 16:07:32% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @GARoadCut_OpeningFcn, ...'gui_OutputFcn',  @GARoadCut_OutputFcn, ...'gui_LayoutFcn',  [] , ...'gui_Callback',   []);
if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1});
endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
elsegui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT% --- Executes just before GARoadCut is made visible.
function GARoadCut_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 GARoadCut (see VARARGIN)% Choose default command line output for GARoadCut
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes GARoadCut wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = GARoadCut_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 SelectPhoto_button.
function SelectPhoto_button_Callback(hObject, eventdata, handles)
% hObject    handle to SelectPhoto_button (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global chrom oldpop fitness lchrom  popsize cross_rate mutation_rate yuzhisum
global maxgen  m n fit gen yuzhi A B C oldpop1 popsize1 b b1 fitness1 yuzhi1
axis off  %%关闭坐标轴显示
[filename,pathname] =uigetfile({'*.jpeg';'*.bmp';'*.jpg';'*.png';'*.*'},'选择图片');
str=[pathname filename];
%打开图像
A=imread(str);  %读入道路图像
%打开axes1的句柄 进行axes1的操作
axes(handles.OriginPhoto);
%%在axes1中显示 图像
imshow(A);  % --- Executes on button press in RUN_button.
function RUN_button_Callback(hObject, eventdata, handles)
% hObject    handle to RUN_button (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global chrom oldpop fitness lchrom  popsize cross_rate mutation_rate yuzhisum
global maxgen  m n fit gen yuzhi A B C oldpop1 popsize1 b b1 fitness1 yuzhi1 result bestyuzhibbox=msgbox('正在使用改进算法进行图像分割,请稍后......');%图像处理部分
B=rgb2gray(A);      %将RGB图像转化成灰度图像
C=imresize(B,0.1);    %将读入的图像缩小
data_1_str = get(handles.lchromNum, 'string');
lchrom = str2num(data_1_str);%染色体长度
data_2_str = get(handles.popsizeNum, 'string');
popsize=str2num(data_2_str);    %种群大小
data_3_str = get(handles.crossNum, 'string');
cross_rate=str2double(data_3_str);      %杂交概率
data_4_str = get(handles.mutationNum, 'string');
mutation_rate=str2double(data_4_str);    %变异概率
%最大代数
data_5_str = get(handles.maxgenNum, 'string');
maxgen=str2num(data_5_str);
[m,n]=size(C);%初始种群
initpop;
%遗传操作
tic;
for gen=1:maxgenfitness_order; %计算适应度值及排序select; %选择操作crossover;  %交叉mutation;  %变异
end
set(handles.edit9, 'string', toc);%耗时
findresult; %图像分割结果
axes(handles.CuttedPhoto);
imshow(C);
%%%%%%输出进化各曲线%%%%%%
set(handles.edit8, 'string', result);%最终阈值axes(handles.Best);
gen=1:maxgen;
plot(gen,fit(1,gen)); axes(handles.BestYuzhi);
plot(gen,yuzhi(1,gen));
axes(handles.photoyuzhi);
plot(gen,bestyuzhi(1,gen));close(bbox);function popsizeNum_Callback(hObject, eventdata, handles)
% hObject    handle to popsizeNum (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 popsizeNum as text
%        str2double(get(hObject,'String')) returns contents of popsizeNum as a double% --- Executes during object creation, after setting all properties.
function popsizeNum_CreateFcn(hObject, eventdata, handles)
% hObject    handle to popsizeNum (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');
endfunction lchromNum_Callback(hObject, eventdata, handles)
% hObject    handle to lchromNum (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 lchromNum as text
%        str2double(get(hObject,'String')) returns contents of lchromNum as a double% --- Executes during object creation, after setting all properties.
function lchromNum_CreateFcn(hObject, eventdata, handles)
% hObject    handle to lchromNum (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

三、运行结果


四、matlab版本及参考文献

1 matlab版本
2014a

2 参考文献
[1] 蔡利梅.MATLAB图像处理——理论、算法与实例分析[M].清华大学出版社,2020.
[2]杨丹,赵海滨,龙哲.MATLAB图像处理实例详解[M].清华大学出版社,2013.
[3]周品.MATLAB图像处理与图形用户界面设计[M].清华大学出版社,2013.
[4]刘成龙.精通MATLAB图像处理[M].清华大学出版社,2015.
[5]赵勇,方宗德,庞辉,王侃伟.基于量子粒子群优化算法的最小交叉熵多阈值图像分割[J].计算机应用研究. 2008,(04)

【图像分割】基于matlab GUI遗传算法Otsu图像分割【含Matlab源码 734期】相关推荐

  1. 【光学】基于matlab GUI杨氏双缝干涉【含Matlab源码 001期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI杨氏双缝干涉[含Matlab源码 001期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2: 付费 ...

  2. 【人脸识别】基于matlab GUI人数统计【含Matlab源码 2121期】

    ⛄一.人数统计简介(附课程作业报告) 1 课题背景 本课题为基于matlab的人数统计系统.近年来,很多行业对人流信息有极大的需求,如汽车公交站,地铁站台,商场出入口等.通过人数统计系统可以方便.可靠 ...

  3. Matlab实现遗传算法(附上完整仿真源码)

    遗传算法(Genetic Algorithm,GA)是一种基于生物进化理论的优化算法,通过模拟自然界中的遗传过程,来寻找最优解. 在遗传算法中,每个解被称为个体,每个个体由一组基因表示,每个基因是解空 ...

  4. 基于SSM的仓库管理系统(含完整源码+论文)

    后端框架:SSM 数据库:MySQL 开发工具:IDEA/Eclipse 系统介绍:本系统是基于SSM框架进行设计,MySQL作为底层数据库,前端采用bootstrap 模块大致介绍:包括库存管理.出 ...

  5. 【条形码识别】基于matlab GUI二维条形码识别【含Matlab源码 607期】

    ⛄一.二维条形码识别简介 采用数字图像处理技术对二维条码进行识别, 是二维条形码识别中较常用的方法, 它在处理污损的条形码方面有光电识别方法无法比拟的优势.另外图像式识别方法对识别角度的要求没有光电识 ...

  6. 【心电信号】基于matlab GUI心电信号预处理【含Matlab源码 938期】

    ⛄一.心电信号预处理方法简介 理论知识参考文献:心电信号预处理方法研究 ⛄二.部分源代码 function varargout = kaishi(varargin) gui_Singleton = 1 ...

  7. matlab svm 语音识别,【情感识别】基于matlab支持向量机(SVM)的语音情感识别【含Matlab源码 543期】...

    一.简介 支持向量机(Support Vector Machine)是Cortes和Vapnik于1995年首先提出的,它在解决小样本.非线性及高维模式识别中表现出许多特有的优势,并能够推广应用到函数 ...

  8. 【Matlab验证码识别】遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别【含GUI源码 1694期】

    一.代码运行视频(哔哩哔哩) [Matlab验证码识别]遗传算法和最大熵优化+大津法(OTSU)+自定义阈值数字验证码识别[含GUI源码 1694期] 二.matlab版本及参考文献 1 matlab ...

  9. 【图像分割】FCMKFCM MRI图像分割【含GUI Matlab源码 582期】

    ⛄一.图像分割简介 理论知识参考:[基础教程]基于matlab图像处理图像分割[含Matlab源码 191期] ⛄二.部分源代码 function varargout = MainGUI(vararg ...

  10. 【图像分割】基于matlab HSV彩色空间图像分割【含Matlab源码 1474期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[图像分割]基于matlab HSV彩色空间图像分割[含Matlab源码 1474期] (https://download.csdn.ne ...

最新文章

  1. c++ clr编译dll在c#调用时出现“试图加载不正确的格式”“找不到dll”错误的解决...
  2. python怎么打印列表长度_关于python:生成器输出的长度
  3. 秘钥对使用_使用gitactions持续集成项目实例
  4. 持久层是什么意思_软件项目实训及课程设计指导—如何在数据持久层中应用DAO模式...
  5. Python如何使用不同分隔符切分字符串
  6. Happy 牛 Year!牛年dotnet云原生技术趋势
  7. android 剪切板广播发送者,Android使用剪切板传递数据
  8. Linux多线程开发-线程同步-互斥锁pthread_mutex_t
  9. 2014.7.8模拟赛【笨笨当粉刷匠】|bzoj1296 [SCOI]粉刷匠
  10. java8 求list最大值
  11. Windows Server 2008 RemoteApp(五)---远程桌面Web访问
  12. D7000、60D、K5、E5的详细对比评价(转)
  13. 游戏开发入门终极指南(技术资源大合集)
  14. A. Is your horseshoe on the other hoof?
  15. webp的js插件_Vuejs webp图片支持,插件开发过程~ - 简书
  16. RobotStudio 创建第一个工作站
  17. Win10系统重装过程(一键装机)
  18. Django的多表查询操做
  19. c语言患者住院管理系统,住院系统-中小医院医疗套装软件管理系统_九明珠信息科技...
  20. 嵌入式新闻早班车-第5期

热门文章

  1. 【刷题】BZOJ 1003 [ZJOI2006]物流运输
  2. ActionContext介绍(在Struts2中)
  3. 错误因为数据库正在使用,所以无法获得对数据库的独占访问权的解决方案(转)...
  4. 深入浅出SharePoint Designer 2010
  5. AutoCAD2020线型比例修改
  6. AutoCAD2020布局和模型窗口背景色都修改为黑色
  7. 20200704每日一句
  8. python深拷贝和浅拷贝学习
  9. 190428每日一句
  10. 每天1万步就叫健康吗?