Regional_growth
来源:互联网 发布:校园网络 布局 编辑:程序博客网 时间:2024/04/26 21:00
int Move_detect::Regional_growth(IplImage* src,CvPoint start,int region_color,int change_color)//函数功能:对于二值图像src求连通阈
{
uchar* srcdata=(uchar*)src->imageData;
//8领域
int Region8_x[]={-1,0,1,1,1,0,-1,-1};
int Region8_y[]={-1,-1,-1,0,1,1,1,0};
//4邻域
//int Region8_x[]={0,1,0,-1};
//int Region8_y[]={-1,0,1,0};
long int temp1=0,temp2=0;
int x,y;
if (srcdata[start.y*src->widthStep+start.x]!=region_color)
{
return 0;
}
else
{
Region_x[temp2]=start.x;
Region_y[temp2]=start.y;
temp2++;
}
while(temp1<=(temp2-1)&&temp1<5600000&&temp2<=5600000)
{
//printf("temp1:%d\n",temp1);
//printf("temp2:%d\n",temp2);
for (int i=0;i<8;i++)
{
//Region_x和Region_y里存放连通域占集的坐标
x=Region8_x[i]+Region_x[temp1];
y=Region8_y[i]+Region_y[temp1];
if (x>=0&&x<src->width&&y>=0&&y<src->height)
{
if (srcdata[y*src->widthStep+x]==region_color)
{
srcdata[y*src->widthStep+x]=change_color;
Region_x[temp2]=x;
Region_y[temp2]=y;
temp2++;
}
}
}
temp1++;
}
return temp1;
}
{
uchar* srcdata=(uchar*)src->imageData;
//8领域
int Region8_x[]={-1,0,1,1,1,0,-1,-1};
int Region8_y[]={-1,-1,-1,0,1,1,1,0};
//4邻域
//int Region8_x[]={0,1,0,-1};
//int Region8_y[]={-1,0,1,0};
long int temp1=0,temp2=0;
int x,y;
if (srcdata[start.y*src->widthStep+start.x]!=region_color)
{
return 0;
}
else
{
Region_x[temp2]=start.x;
Region_y[temp2]=start.y;
temp2++;
}
while(temp1<=(temp2-1)&&temp1<5600000&&temp2<=5600000)
{
//printf("temp1:%d\n",temp1);
//printf("temp2:%d\n",temp2);
for (int i=0;i<8;i++)
{
//Region_x和Region_y里存放连通域占集的坐标
x=Region8_x[i]+Region_x[temp1];
y=Region8_y[i]+Region_y[temp1];
if (x>=0&&x<src->width&&y>=0&&y<src->height)
{
if (srcdata[y*src->widthStep+x]==region_color)
{
srcdata[y*src->widthStep+x]=change_color;
Region_x[temp2]=x;
Region_y[temp2]=y;
temp2++;
}
}
}
temp1++;
}
return temp1;
}
- Regional_growth
- android设置中常用的PreferenceActivity用法介绍
- 开源软件分类列表
- Some characters cannot be mapped using 'ISO-8859-1' character encoding
- 用运放做自动OR操作的电源选择器
- iphone开发之多线程NSThread和NSInvocationOperation
- Regional_growth
- [JAVA]Java导出Excel数据的一种方法(完美实现,包含表格线)
- 感冒
- SOA之路:基于Microsoft.net 平台的SOA 架构设计与开发
- The main() method
- 正则表达式,数据库验证
- 中文分词
- OpenCV 专业词汇
- 一些iOS技术面试题