| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1769 人关注过本帖
标题:再牛的人也永远看不懂这段程序!
取消只看楼主 加入收藏
yinkai1205
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-5-28
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
再牛的人也永远看不懂这段程序!
void computeF(IplImage* img,int* feature)
{
        uchar* imgdate;
        int height=train->height;
        int width=train->width;
        int indexadd=-1,index=0,begin=0;
        for (int h=0;h<height;h++)
        {
            imgdate=(uchar*)(img->imageData+h*train->widthStep);
            begin=0;
            for (int w=0;w<width;w++)
            {
                if (w!=width-1&&imgdate[3*w]==0&&imgdate[3*w+1]==0&&imgdate[3*w+2]==0&&imgdate[3*(w+1)]==255&&imgdate[3*(w+1)+1]==255&&imgdate[3*(w+1)+2]==255)    //黑白跳跃
                {
                    indexadd++;
                    if (w<width/3&&h<height/2)
                    {
                        if (indexadd>1)      //接触2次黑白跳跃
                        {
                            w=width/3-1;
                            begin=width/3;
                            indexadd=-1;
                            continue;
                        }
                        index=0+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }
                    else if (w<2*width/3&&h<height/2)
                    {
                        if (indexadd>1)      
                        {
                            w=2*width/3-1;
                            begin=2*width/3;
                            indexadd=-1;
                            continue;
                        }
                        index=2+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }
                    else if (w<width&&h<height/2)
                    {
                        if (indexadd>1)
                        {
                            indexadd=-1;
                            break;
                        }
                        index=4+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }
                    else if (w<width/3&&h<height)
                    {
                        if (indexadd>1)
                        {
                            w=width/3-1;
                            begin=width/3;
                            indexadd=-1;
                            continue;
                        }
                        index=6+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }
                    else if (w<2*width/3&&h<height)
                    {
                        if (indexadd>1)      
                        {
                            w=2*width/3-1;
                            begin=2*width/3;
                            indexadd=-1;
                            continue;
                        }
                        index=8+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }
                    else if (w<width&&h<height)
                    {
                        if (indexadd>1)
                        {
                            indexadd=-1;
                            break;
                        }
                        index=10+indexadd;
                        feature[index]+=w-begin+1;
                        begin=w+1;
                    }

                    if (w==width/3-1)
                    {
                        if (h<height/2)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=0+indexadd;
                            feature[index]+=w-begin+1;
                            begin=w+1;
                        }
                        else  if (h<height)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=6+indexadd;
                            feature[index]+=w-begin+1;
                            begin=w+1;
                        }
                    }

                    if (w==2*width/3-1)
                    {
                        if (h<height/2)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=2+indexadd;
                            feature[index]+=w-begin+1;
                            begin=w+1;
                        }
                        else  if (h<height)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=8+indexadd;
                            feature[index]+=w-begin+1;
                            begin=w+1;
                        }
                    }

                    if (w==width-1)
                    {
                        if (h<height/2)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=4+indexadd;
                            feature[index]+=w-begin+1;
                        }
                        else  if (h<height)
                        {
                            if (indexadd==0)
                            {
                                indexadd=1;
                            }
                            if (indexadd==-1)
                            {
                                indexadd=0;
                            }
                            index=10+indexadd;
                            feature[index]+=w-begin+1;
                        }
                    }
                }
            }
        }
}

搜索更多相关主题的帖子: train 
2010-05-28 21:41
快速回复:再牛的人也永远看不懂这段程序!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025161 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved