金牌会员
- 积分
- 1868
- 威望
- 994
- 贡献
- 478
- 兑换币
- 399
- 注册时间
- 2011-8-5
- 在线时间
- 198 小时
|
mxj1005071012 发表于 2013-3-31 09:25
考虑的很全面
我再发最新的,已经没有什么问题了,边沿提取精确
if(!right_end_flag)
{
if(!scan_right)
{
for(right_count_location=right_pix_temp;right_count_location<l;right_count_location++)
{
//边沿点获取
// printf("h=%d ",hang_pic);
// printf("r=%d ",right_count_location);
if(*(picpoint[hang_pic]+l/2)<color_div_value) //开始扫描的点不是白色的则关闭扫描
{
scan_right=1;
// printf("h=%d no color=%d\n",hang_pic,*(picpoint[hang_pic]+right_count_location));
break;
}
if((*(picpoint[hang_pic]+right_count_location)>=color_div_value)&& //找到边沿点
(*(picpoint[hang_pic]+right_count_location+1)>=color_div_value)&&
(*(picpoint[hang_pic]+right_count_location+2)<color_div_value)&&
(*(picpoint[hang_pic]+right_count_location+3)<color_div_value))
{
if(hang_pic==h-1) //记录最近一行的位置
{
temp_edge[hang_pic].right_edge=right_count_location;
// printf("h=%d rLOne=%d color=%d\n",hang_pic,right_count_location,*(picpoint[hang_pic]+right_count_location));
break;
}
if((hang_pic<h-1) && (temp_edge[hang_pic+1].right_edge>=right_count_location)) //第二行开始记录位置并且和上一行比较
{
temp_edge[hang_pic].right_edge=right_count_location;
right_add_count++;
// printf("h=%d rL=%d color=%d\n",hang_pic,right_count_location,*(picpoint[hang_pic]+right_count_location));
break;
}
else //找到连续方向不一样的时候屏蔽该边,并且停止扫描
{
right_use=1;
scan_right=1;
right_end=hang_pic;
//printf("h=%d end=%d\n",hang_pic,right_end);
break;
}
}
else if(right_count_location>l-5) //位置在图像边界的4个点内找不到边缘时位置标记为256
{
if(hang_pic<l-3 && temp_edge[hang_pic+1].right_edge==256 && temp_edge[hang_pic+2].right_edge<256)
{
right_end_flag=1;
break;
}
temp_edge[hang_pic+1].right_edge=256;
// printf("h=%d end1=%d\n",hang_pic,temp_edge[hang_pic+1].right_edge);
if(hang_pic>=20)
cross_right++;
break;
}
}
}
else
{
temp_edge[hang_pic].right_edge=257; //标记为结束
// printf("final=%d loc=%d\n",hang_pic+1,temp_edge[hang_pic].right_edge);
right_end_flag=1;
}
}
|
|