咩咩咩 骨架算法 代码代码
93°2009/07/31软件综合 IP:广东
等下才上原理,买大M去了~~~~

public: void __gc* ThiningPic(Int32 __gc* dgGrayValue)
{
    Int32 __gc* lWidth = this->bmpobj->Width;
    Int32 __gc* lHeight = this->bmpobj->Height;
    Int32 __gc* neighbour __gc [,] = __gc new Int32 __gc*[5, 5];
    Boolean __gc* bModified = true;
    while (bModified)
    {
        bModified = false;
        for (Int32 __gc* j = 2; (j < (lHeight - 2)); j++)
        {
            for (Int32 __gc* i = 2; (i < (lWidth - 2)); i++)
            {
                Boolean __gc* bCondition1 = false;
                Boolean __gc* bCondition2 = false;
                Boolean __gc* bCondition3 = false;
                Boolean __gc* bCondition4 = false;
                if (this->bmpobj->GetPixel(i, j)->R > dgGrayValue)
                {
                    if (this->bmpobj->GetPixel(i, j)->R < 0xff)
                    {
                        this->bmpobj->SetPixel(i, j, Color::White);
                    }
                }
                else
                {
                    for (Int32 __gc* m = 0; (m < 5); m++)
                    {
                        for (Int32 __gc* n = 0; (n < 5); n++)
                        {
                            neighbour[m, n] = ((this->bmpobj->GetPixel(((i + m) - 2), ((j + n) - 2))->R < dgGrayValue) ? 1 : 0);
                        }
                    }
                    Int32 __gc* nCount = (((((((neighbour[1, 1] + neighbour[1, 2]) + neighbour[1, 3]) + neighbour[2, 1]) + neighbour[2, 3]) + neighbour[3, 1]) + neighbour[3, 2]) + neighbour[3, 3]);
                    if ((nCount >= 2) && (nCount <= 6))
                    {
                        bCondition1 = true;
                    }
                    nCount = 0;
                    if ((neighbour[1, 2] == 0) && (neighbour[1, 1] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[1, 1] == 0) && (neighbour[2, 1] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[2, 1] == 0) && (neighbour[3, 1] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[3, 1] == 0) && (neighbour[3, 2] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[3, 2] == 0) && (neighbour[3, 3] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[3, 3] == 0) && (neighbour[2, 3] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[2, 3] == 0) && (neighbour[1, 3] == 1))
                    {
                        nCount++;
                    }
                    if ((neighbour[1, 3] == 0) && (neighbour[1, 2] == 1))
                    {
                        nCount++;
                    }
                    if (nCount == 1)
                    {
                        bCondition2 = true;
                    }
                    if (((neighbour[1, 2] * neighbour[2, 1]) * neighbour[2, 3]) == 0)
                    {
                        bCondition3 = true;
                    }
                    else
                    {
                        nCount = 0;
                        if ((neighbour[0, 2] == 0) && (neighbour[0, 1] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[0, 1] == 0) && (neighbour[1, 1] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[1, 1] == 0) && (neighbour[2, 1] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[2, 1] == 0) && (neighbour[2, 2] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[2, 2] == 0) && (neighbour[2, 3] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[2, 3] == 0) && (neighbour[1, 3] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[1, 3] == 0) && (neighbour[0, 3] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[0, 3] == 0) && (neighbour[0, 2] == 1))
                        {
                            nCount++;
                        }
                        if (nCount != 1)
                        {
                            bCondition3 = true;
                        }
                    }
                    if (((neighbour[1, 2] * neighbour[2, 1]) * neighbour[3, 2]) == 0)
                    {
                        bCondition4 = true;
                    }
                    else
                    {
                        nCount = 0;
                        if ((neighbour[1, 1] == 0) && (neighbour[1, 0] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[1, 0] == 0) && (neighbour[2, 0] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[2, 0] == 0) && (neighbour[3, 0] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[3, 0] == 0) && (neighbour[3, 1] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[3, 1] == 0) && (neighbour[3, 2] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[3, 2] == 0) && (neighbour[2, 2] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[2, 2] == 0) && (neighbour[1, 2] == 1))
                        {
                            nCount++;
                        }
                        if ((neighbour[1, 2] == 0) && (neighbour[1, 1] == 1))
                        {
                            nCount++;
                        }
                        if (nCount != 1)
                        {
                            bCondition4 = true;
                        }
                    }
                    if (((bCondition1 && bCondition2) && bCondition3) && bCondition4)
                    {
                        this->bmpobj->SetPixel(i, j, Color::White);
                        bModified = true;
                    }
                    else
                    {
                        this->bmpobj->SetPixel(i, j, Color::Black);
                    }
                }
            }
        }
    }
}



+500  科创币    我说要有光    2009/07/31 有爱
来自:计算机科学 / 软件综合
3
已屏蔽 原因:{{ notice.reason }}已屏蔽
{{notice.noticeContent}}
~~空空如也
rc5
15年6个月前 IP:未同步
134520
那一堆"if ((neighbour[1, 1] == 0) && (neighbour[2, 1] == 1))"应该想法精简
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论
93°作者
15年6个月前 IP:未同步
134524
概念验证而已,不过懒得弄了 = = 看电影去……偶也
引用
评论
加载评论中,请稍候...
200字以内,仅用于支线交流,主线讨论请采用回复功能。
折叠评论

想参与大家的讨论?现在就 登录 或者 注册

所属专业
上级专业
同级专业
93°
学者 笔友
文章
651
回复
6032
学术分
30
2007/04/10注册,6年11个月前活动
暂无简介
主体类型:个人
所属领域:无
认证方式:邮箱
IP归属地:未同步
文件下载
加载中...
{{errorInfo}}
{{downloadWarning}}
你在 {{downloadTime}} 下载过当前文件。
文件名称:{{resource.defaultFile.name}}
下载次数:{{resource.hits}}
上传用户:{{uploader.username}}
所需积分:{{costScores}},{{holdScores}}下载当前附件免费{{description}}
积分不足,去充值
文件已丢失

当前账号的附件下载数量限制如下:
时段 个数
{{f.startingTime}}点 - {{f.endTime}}点 {{f.fileCount}}
视频暂不能访问,请登录试试
仅供内部学术交流或培训使用,请先保存到本地。本内容不代表科创观点,未经原作者同意,请勿转载。
音频暂不能访问,请登录试试
支持的图片格式:jpg, jpeg, png
插入公式
评论控制
加载中...
文号:{{pid}}
投诉或举报
加载中...
{{tip}}
请选择违规类型:
{{reason.type}}

空空如也

加载中...
详情
详情
推送到专栏从专栏移除
设为匿名取消匿名
查看作者
回复
只看作者
加入收藏取消收藏
收藏
取消收藏
折叠回复
置顶取消置顶
评学术分
鼓励
设为精选取消精选
管理提醒
编辑
通过审核
评论控制
退修或删除
历史版本
违规记录
投诉或举报
加入黑名单移除黑名单
查看IP
{{format('YYYY/MM/DD HH:mm:ss', toc)}}