首页 > 行业资讯 > 【图像分割】基于区域生长算法和Kmean聚类算法实现图像分割附matlab代码

【图像分割】基于区域生长算法和Kmean聚类算法实现图像分割附matlab代码

时间:2022-06-21 来源: 浏览:

【图像分割】基于区域生长算法和Kmean聚类算法实现图像分割附matlab代码

天天Matlab 天天Matlab
天天Matlab

TT_Matlab

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,完整matlab代码或者程序定制加qq1575304183。

收录于合集 #图像处理matlab源码 686个

1 简介

区域生长算法的基本思想是将具有相似性质(例如,颜色,亮度,纹理)的像素集合起来构成区域。具体实现时先确定一组种子像素作为生长的起点, 再将种子像素周围邻域中与种子像素有相同或相似性质的像素 (根据某种事先确定的生长或相似准则来判定)合并到种子像素所在的区域中。并将这些新像素当作新的种子像素继续进行上面的过程, 直到再没有满足条件的像素可被包括进来为止。

2 部分代码

function [hp,hpind,minval,minind] = heap_pop(hp,hpind) %pop min value in heap if length (hp)== 0 disp( ’empty heap, no pop operation’ ) return ; end l = length (hp); minval = hp( 1 ); minind = hpind( 1 ); hp( 1 ) = hp(l); hpind( 1 ) = hpind(l); l = l- 1 ; hp = hp( 1 :l); hpind = hpind( 1 :l); curnode = 1 ; halfl = fix(l/ 2 ); while (curnode<=halfl) sonnode1 = curnode* 2 ; sonnode2 = sonnode1 + 1 ; val1 = hp(curnode); val2 = hp(sonnode1); if l>=sonnode2 val3 = hp(sonnode2); else val3 = inf; end if val1>val2 if val2>val3 %1> 2 > 3 ,move3 stat = 3 ; else %1> 2 , 3 > 2 , move 2 stat = 2 ; end else if val1>val3 %2> 1 > 3 move 3 stat = 3 ; else %2> 1 , 3 > 1 , stop stat = 0 ; end end if ( stat == 0 ) break ; elseif ( stat == 3 ) %swap value, 1 <-> 3 hp(sonnode2) = val1; hp(curnode) = val3; %swap heapind tmp = hpind(curnode); hpind(curnode) = hpind(sonnode2); hpind(sonnode2) = tmp; curnode = sonnode2; else % stat == 2 %swap value, 1 <-> 2 hp(sonnode1) = val1; hp(curnode) = val2; %swap heapind tmp = hpind(curnode); hpind(curnode) = hpind(sonnode1); hpind(sonnode1) = tmp; curnode = sonnode1; end end

3 仿真结果

4 参考文献

[1]谢理训, 杨宜民. 基于改进区域生长算法的彩色图像分割[J]. 微计算机信息, 2009(18):3.

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

版权:如无特殊注明,文章转载自网络,侵权请联系cnmhg168#163.com删除!文件均为网友上传,仅供研究和学习使用,务必24小时内删除。
相关推荐