像素标记法统计图像中连通域的个数
来源:互联网 发布:问卷调查自动填写软件 编辑:程序博客网 时间:2024/04/29 04:31
clear;clc;I=imread('rice.png');s=strel('disk',2);I=imerode(I,s);I=im2bw(I);I=I*255;[m,n]=size(I);%利用队列结构front=1;rear=1;%指明下一个像素入队的位置Queue=zeros(m*n,2);flag=0;for i=1:m for j=1:n if I(i,j)==255 Queue(rear,1)=i; Queue(rear,2)=j; flag=flag+1; I(i,j)=flag; rear=rear+1; end while rear~=front temp_i=Queue(front,1); temp_j=Queue(front,2); front=front+1; cond1=(temp_i-1)*(temp_j-1); if (cond1&I(temp_i-1,temp_j-1)==255) %1 Queue(rear,1)=temp_i-1; Queue(rear,2)=temp_j-1; I(temp_i-1,temp_j-1)=flag; rear=rear+1; end cond2=(temp_i-1)*(temp_j); if (cond2&I(temp_i-1,temp_j)==255) %2 Queue(rear,1)=temp_i-1; Queue(rear,2)=temp_j; I(temp_i-1,temp_j)=flag; rear=rear+1; end cond3=(temp_i-1)*(temp_j-n); if (cond3&I(temp_i-1,temp_j+1)==255) %3 Queue(rear,1)=temp_i-1; Queue(rear,2)=temp_j+1; I(temp_i-1,temp_j+1)=flag; rear=rear+1; end cond4=(temp_i)*(temp_j-n); if (cond4&I(temp_i,temp_j+1)==255) %4 Queue(rear,1)=temp_i; Queue(rear,2)=temp_j+1; I(temp_i,temp_j+1)=flag; rear=rear+1; end cond5=(temp_i-m)*(temp_j-n); if (cond5&I(temp_i+1,temp_j+1)==255) %5 Queue(rear,1)=temp_i+1; Queue(rear,2)=temp_j+1; I(temp_i+1,temp_j+1)=flag; rear=rear+1; end cond6=(temp_i-m)*(temp_j); if (cond6&I(temp_i+1,temp_j)==255) %6 Queue(rear,1)=temp_i+1; Queue(rear,2)=temp_j; I(temp_i+1,temp_j)=flag; rear=rear+1; end cond7=(temp_i-m)*(temp_j-1); if (cond7&I(temp_i+1,temp_j-1)==255) %7 Queue(rear,1)=temp_i+1; Queue(rear,2)=temp_j-1; I(temp_i+1,temp_j-1)=flag; rear=rear+1; end cond8=(temp_i)*(temp_j-1); if (cond8&I(temp_i,temp_j-1)==255) %8 Queue(rear,1)=temp_i; Queue(rear,2)=temp_j-1; I(temp_i,temp_j-1)=flag; rear=rear+1; end end endendflag
初到CBIB,导师就布置了几个练习,下面是我编写的利用像素标记法实现的图像中连通域个数的统计(8邻域法)
0 0
- 像素标记法统计图像中连通域的个数
- 线性筛选法统计素数个数
- 图像处理 连通域标记
- 基于区域生长的二值化图像连通域标记
- 图像分析:二值图像连通域标记-基于行程的标记方法
- 图像分析:二值图像连通域标记2-基于轮廓的标记
- 图像分析:二值图像连通域标记-基于行程的标记方法
- 二值图像连通域标记算法与代码加载栅格影响,提取像素转点存储shp文件
- 二值图像连通域标记算法
- 二值图像连通域标记
- 二值图像连通域标记
- 二值图像连通域标记
- 二值图像连通域标记
- 【图像处理】二值图像连通区域标记中等价对的合并
- 数字图像处理—图像分割—并行区域—连通区域标记(像素标记)(4-连通情况)
- bwlabel(BW,n) matlab中标记二值图像中白色(1)的连通区域
- 图像分析:二值图像连通域标记
- 图像分析:二值图像连通域标记
- eclipse里面INSTALL_FAILED_SHARED_USER_INCOMPATIBLE错误需要签名
- 贪吃蛇(链表指针)
- event handling in Java
- uva 639 Don't Get Rooked ( 回溯 )
- LeetCode 之 Search for a Range(查找)
- 像素标记法统计图像中连通域的个数
- 《程序员面试宝典3》大量错误(50+)纠正表
- 【ZOJ】3886 Nico Number【线段树】
- zoj 3888 Twelves Monkeys(zoj 2015年7月月赛)
- php5安装时可能会遇到的问题
- 重学java23种设计模式(7)桥接模式
- 快快快!27个提升效率的iOS开源库推荐
- ZOJ 3888 Twelves Monkeys
- C++ 类的静态成员详细讲解