一、图像分割简介

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

二、部分源代码

function varargout = yuzhifenge(varargin)
% YUZHIFENGE MATLAB code for yuzhifenge.fig
%      YUZHIFENGE, by itself, creates a new YUZHIFENGE or raises the existing
%      singleton*.
%
%      H = YUZHIFENGE returns the handle to a new YUZHIFENGE or the handle to
%      the existing singleton*.
%
%      YUZHIFENGE('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in YUZHIFENGE.M with the given input arguments.
%
%      YUZHIFENGE('Property','Value',...) creates a new YUZHIFENGE or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before yuzhifenge_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to yuzhifenge_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 yuzhifenge% Last Modified by GUIDE v2.5 05-Nov-2017 11:53:20% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...'gui_Singleton',  gui_Singleton, ...'gui_OpeningFcn', @yuzhifenge_OpeningFcn, ...'gui_OutputFcn',  @yuzhifenge_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 yuzhifenge is made visible.
function yuzhifenge_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 yuzhifenge (see VARARGIN)% Choose default command line output for yuzhifenge
handles.output = hObject;% Update handles structure
guidata(hObject, handles);% UIWAIT makes yuzhifenge wait for user response (see UIRESUME)
% uiwait(handles.figure1);% --- Outputs from this function are returned to the command line.
function varargout = yuzhifenge_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 pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global im;
[filename,pathname]=...uigetfile({'*.jpg';'*.bnp';'*.png'},'选择图片');
str=[pathname filename];
im=imread(str);
axes(handles.axes1);
imshow(im);
title('原始图像')
axes(handles.axes3);
if isrgb( im )im=rgb2gray(im);
end
hist_im=imhist(im); %计算直方图
bar(hist_im);%画直方图
title('原始图像灰度直方图')% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
close(gcf)% --- Executes on button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton1 (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 radiobutton1
set(handles.radiobutton1,'value',1);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',0);
set(handles.popupmenu1,'value',1);
set(handles.popupmenu2,'value',1);
global im;B=im;T=0.5*(double(min(B(:)))+double(max(B(:))));d=false;%通过迭代求最佳阈值while~dg=B>=T;%g=0或1Tn=0.5*(mean(B(g))+mean(B(~g)));%mean(A,2)是矩阵求各行的均值,%mean(A)表示求矩阵A的均值,默认的是求各列的均值if(abs(T-Tn)<0.1)d=1;endT=Tn;endaxes(handles.axes2);% 根据最佳阈值进行图像分割level=T/255;J=im2bw(B,level);imshow(J);title('使用基本全局阈值法');% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton2 (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 radiobutton2
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',1);
set(handles.radiobutton3,'value',0);
set(handles.popupmenu1,'value',1);
set(handles.popupmenu2,'value',1);
global im;I=im;I=im2double(I);%[width,height]=size(I);%otsuTh = graythresh(I);BW = im2bw(I,Th);axes(handles.axes2);imshow(BW);title('Otsu最佳阈值法');% --- Executes on button press in radiobutton3.
function radiobutton3_Callback(hObject, eventdata, handles)
% hObject    handle to radiobutton3 (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 radiobutton3
set(handles.radiobutton1,'value',0);
set(handles.radiobutton2,'value',0);
set(handles.radiobutton3,'value',1);
set(handles.popupmenu1,'value',1);
set(handles.popupmenu2,'value',1);
global im;zi=im;bw=adaptivethreshold(zi,11,0.03,0);%  ws=11-平均滤波时的窗口大小,可参考fspecial的用法%    C-0.03常量,需要根据经验选取合适的参数%  tm-开关变量,tm=1进行中值滤波,tm=0则进行均值滤波% bw-图像分割后输出的二值图像axes(handles.axes2);imshow(bw);title('自适应阈值');

三、运行结果



四、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多种阈值图像分割(带面板)【含Matlab源码 733期】相关推荐

  1. 【图像处理】基于matlab GUI多功能图像处理系统【含Matlab源码 1876期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[图像处理]基于matlab GUI多功能图像处理系统[含Matlab源码 1876期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...

  2. 【机械仿真】基于matlab GUI曲柄摇杆机构运动仿真【含Matlab源码 1608期】

    一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[机械仿真]基于matlab GUI曲柄摇杆机构运动仿真[含Matlab源码 1608期] 点击上面蓝色字体,直接付费下载,即可. 获取代码 ...

  3. 【光学】基于matlab GUI光栅条纹投影生成【含Matlab源码 2118期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[光学]基于matlab GUI光栅条纹投影生成[含Matlab源码 2118期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...

  4. 【机械仿真】基于matlab GUI直齿圆柱齿轮应力计算【含Matlab源码 2077期】

    ⛄一.获取代码方式 获取代码方式1: 完整代码已上传我的资源:[机械仿真]基于matlab GUI直齿圆柱齿轮应力计算[含Matlab源码 2077期] 点击上面蓝色字体,直接付费下载,即可. 获取代 ...

  5. 【天体学】基于matlab GUI太阳天顶角计算【含Matlab源码 2229期】

    一.⛄获取代码方式 获取代码方式1: 完整代码已上传我的资源:[天体学]基于matlab GUI太阳天顶角计算[含Matlab源码 2229期] 点击上面蓝色字体,直接付费下载,即可. 获取代码方式2 ...

  6. 【语音去噪】基于matlab GUI IIR滤波器语音去噪【含Matlab源码 1864期】

    一.语音处理简介 语言是人们获得各类有效信息的主要途径, 而语音是语言的表现形式.语音在一定程度上可影响人们的生活, 因此, 语音信号的研究对科学领域和人们日常生活具有一定的研究价值和意义.噪声广泛存 ...

  7. 【身份证识别】基于matlab GUI BP神经网络身份证识别【含Matlab源码 2239期】

    ⛄一.身份证号码识别简介 1 引言 当今是一个信息高度发达的时代,对于每个公民而言身份证那一连串的数字体现了个人信息的唯一性,出于保障公民合法权益和社会治安的考虑,越来越多的行业都开始建立自己的安全保 ...

  8. 【数学建模】基于matlab GUI平行停车模拟仿真【含Matlab源码 1877期】

    一.平行停车模拟仿真简介 近年来, 随着我国经济的快速发展, 机动车保有量也迅速增长.截至2012年底, 全国机动车保有量已达2.4亿辆, 城市"停车难"的问题日趋严重.统计结果表 ...

  9. 【病虫害识别】基于matlab GUI SVM病虫害识别系统【含Matlab源码 2429期】

    ⛄一.基于机器视觉的农作物病害识别技术 1 叶片图像采集 进行农作物病害自动检测与识别首先要对病害叶片的图像进行采集.自动识别的前提是获得数字图像, 数字图像质量的好坏决定着之后叶片病害的识别特征能否 ...

  10. 【限速标志识别】基于matlab GUI形态学限速标志识别【含Matlab源码 1142期】

    ⛄一.SVM路标检测识别简介 1 路标识别 完整的路标识别系统包括:图像的获取与预处理,图像分割(路标定位),特征提取,模式分类(路标识别)等部分.其中模式分类是系统的关键技术.较常用的模式分类方法是 ...

最新文章

  1. 1小时学会:最简单的iOS直播推流(十)librtmp使用介绍
  2. 马斯克称特斯拉AutoPilot方案宛如“超人”,首要任务是“不撞车”;网友:???...
  3. iis服务器配置php项目,Windows7下IIS+php配置教程
  4. 计算机控制课程设计体会,计算机控制技术课程设计报告
  5. 修改npm默认全局安装路径
  6. 程序员,你怎么这么忙?为什么天天熬夜加班?
  7. c语言switch自动贩卖机,JAVA程式-自动贩卖机SWITCHampCASE.doc
  8. (转)ETL利器Kettle实战应用解析系列一【Kettle使用介绍】
  9. mysql 键 索引_五、MySQL索引和键
  10. 编码之Base64编码
  11. maven scm 配置git
  12. Mbed记录 STM32F207ZG板子引脚图
  13. 泛微e9隐藏明细表_泛微Ecology权限整理大全相当全要点
  14. A1,A2,A3,A4,A5,A6,A7,A8纸张大小图解
  15. ubuntu如何安装本地deb文件
  16. 计算机教师的人生格言,教师人生格言大全
  17. Quartz集群配置报错 This scheduler instance (XXXX) is still active but was recovered by another instance...
  18. HTML+CSS大作业: 抗击疫情网页制作作业_疫情防控网页设计
  19. 知乎热榜的话题,为什么从阿里巴巴离职,大萌哥汇总了9大理由,看完我先柠檬酸了!
  20. 《C++标准库》学习笔记 — STL —流

热门文章

  1. mongodb的基本操作数据更新
  2. SQL转换时间的时分
  3. ERP仓库管理系统查询(十)
  4. iOS:面试八大陷阱
  5. 情绪管理--不要总做“好脾气”的人。
  6. php中的常用魔术方法总结
  7. how to write a good api
  8. 190513每日一句
  9. Eye Tracking Methodology Theory and Practice, Third Edition
  10. Wilcoxon Signed-Rank Test