Matlab 图像分割 (阈值处理)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
![](/assets/blank.gif)
function g = movingthresh(f, n, K)
%MOVINGTHRESH Image segmentation using a moving average threshold.
% G = MOVINGTHRESH(F, n, K) segments image F by thresholding its
% intensities based on the moving average of the intensities along
% individual rows of the image. The average at pixel k is formed
% by averaging the intensities of that pixel and its n − 1
% preceding neighbors. To reduce shading bias, the scanning is
% done in a zig-zag manner, treating the pixels as if they were a
% 1-D, continuous stream. If the value of the image at a point
% exceeds K percent of the value of the running average at that
% point, a 1 is output in that location in G. Otherwise a 0 is
% output. At the end of the procedure, G is thus the thresholded
% (segmented) image. K must be a scalar in the range [0, 1]. % Preliminaries.
% || means or operator;rem(n,1) means the residual of n/1
f = tofloat(f);
[M, N] = size(f);
if (n < 1) || (rem(n, 1) ~= 0) error('n must be an integer >= 1.')
end
if K < 0 || K > 1 error('K must be a fraction in the range [0, 1].')
end % Flip every other row of f to produce the equivalent of a zig-zag scanning pattern. Convert image to a vector.
f(2:2:end, :) = fliplr(f(2:2:end, :)); %fliplr realize the overturn of the vector
f = f'; % Still a matrix.
f = f(:)'; % Convert to row vector for use in function filter. % Compute the moving average.
maf = ones(1, n)/n; % The 1-D moving average filter.
ma = filter(maf, 1, f); % Computation of moving average. % Perform thresholding.
g = (f > K * ma); % Go back to image format (indexed subscripts).
g = reshape(g, N, M)';
% Flip alternate(交替的) rows back.
g(2:2:end, :) = fliplr(g(2:2:end, :));
如果有人看懂,麻烦讲解一下,有利于大家讨论学习。
Matlab 图像分割 (阈值处理)相关推荐
- 迭代阈值图像分割matlab,Matlab 图像分割 (阈值处理)
使用移动平均的可变阈值处理,对很多对比度差的图像处理效果可以很好,但相应的程序代码的编写却很羞涩,难懂. function g = movingthresh(f, n, K) %MOVINGTHRES ...
- matlab 图像分割
matlab图像分割 什么是图像分割 固定阈值分割 自适应阈值分割 分割效果增强 平滑处理 什么是图像分割 将数字图像划分成不相交,不重合的区域的过程就叫图像分割. 这很像PhotoShop里面的快速 ...
- MATLAB图像分割和形态学处理
MATLAB图像分割和形态学处理 一.实验目的 掌握图像分割的基本方法. 掌握形态学处理的基本方法. 学会使用MATLAB编程实现上述方法. 二.实验任务 (1)编程实现基于阈值的图像分割方法和边缘检 ...
- matlab人工选择阈值进行分割,基于MATLAB的图像阈值分割算法的研究
[摘要]:图像分割是一种重要的数字图像处理技术.本文首先介绍了图像分割技术,其次总结了目前图像分割技术中所用到的阈值.边缘检测.区域提取等方法以及分水岭算法.针对各种阈值分割算法,本文在最后做了详细的 ...
- 灰度图像--图像分割 阈值处理之谷底阈值、峰顶平均
学习DIP第54天 转载请标明本文出处:***http://blog.csdn.net/tonyshengtan ***,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发:http ...
- 灰度图像--图像分割 阈值处理之补充说明
学习DIP第56天 转载请标明本文出处:***http://blog.csdn.net/tonyshengtan ***,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发:http ...
- 灰度图像--图像分割 阈值处理之OTSU阈值
学习DIP第55天 转载请标明本文出处:***http://blog.csdn.net/tonyshengtan ***,出于尊重文章作者的劳动,转载请标明出处!文章代码已托管,欢迎共同开发:http ...
- 【MATLAB教程案例23】基于MATLAB图像分割算法仿真——阈值分割法、Otsu阈值分割法、K均值聚类分割法等
FPGA教程目录 MATLAB教程目录 目录 1.软件版本 2.通过二值图实现图像分割 3.通过Otsu阈值分割实现图像分割
- 数字图像处理实验(六)|图像分割{阈值分割、直方图法、OTUS最大类间方差法(edge、im2dw、imfilter、imresize)、迭代阈值法、点检测}(附matlab实验代码和截图)
文章目录 一.实验目的 二.实验原理 (一) 阈值分割 1. 直方图法 2.OTSU法(最大类间方差法)确定阈值 3. 迭代阈值法 4. 点检测 (二)边缘检测 三.实验内容 (一)阈值分割 1. 直 ...
最新文章
- QIIME 2教程. 16纵向和成对样本比较q2-longitudinal(2021.2)
- java bean销毁,销毁Spring Bean的三种方法
- 数据库中char与varchar类型的区别
- 【Python】Python的类和对象(长文系列第⑤篇)
- 全国计算机等级考试暨南大学,9月暨南大学计算机等级考试报名时间通知
- python函数案例名片管理器_python案例:实现一个函数版的名片管理系统
- 游戏会记录某个api的调用_专家坐诊丨老出BUG怎么办?游戏服务器常见问题的解决方法分享...
- 【渝粤教育】国家开放大学2018年春季 0234-22T公务员制度讲座 参考试题
- Linux中vi的退出命令
- 微信游戏推荐系统大揭秘
- 用户体验设计5大目标
- Matlab实现分离变量法求解一维热传导方程的初边值问题
- [51Nod 1035 最长的循环节] 循环小数的性质
- 图书管理系统项目导入
- android传感器摇一摇功能
- 平稳/非平稳信号举例
- 量化投资学习-10:追涨杀跌的本质是“高买低卖”,这是散户亏钱的背后的操作逻辑
- html5网页综合案例制作,网页开发与制作 HTML5页面元素及属性 2-21综合案例(6页)-原创力文档...
- 一些方法:JQ: append() 、appendTo() || JS:appendChild():
- T-SQL程序练习03