社区
图形处理/算法
帖子详情
有没有关于图像处理中的细化的算法代码,或者书集
wanzi7
2003-06-21 11:12:48
代码或者书都可以,请发到wanzi7@etang.com
谢谢!!
...全文
100
9
打赏
收藏
有没有关于图像处理中的细化的算法代码,或者书集
代码或者书都可以,请发到wanzi7@etang.com 谢谢!!
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
9 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
duwenyong
2003-06-30
打赏
举报
回复
bool CManage::ThingDIB()
{
int erasetable[256]=
{
0,0,1,1,0,0,1,1,
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,1,1,
0,0,0,0,0,0,0,1,
0,0,1,1,0,0,1,1,
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,1,1,
0,0,0,0,0,0,0,1,
1,1,0,0,1,1,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
1,1,0,0,1,1,0,0,
1,1,0,1,1,1,0,1,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,1,1,0,0,1,1,
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,1,1,
0,0,0,0,0,0,0,1,
0,0,1,1,0,0,1,1,
1,1,0,1,1,1,0,1,
1,1,0,0,1,1,1,1,
0,0,0,0,0,0,0,0,
1,1,0,0,1,1,0,0,
0,0,0,0,0,0,0,0,
1,1,0,0,1,1,1,1,
0,0,0,0,0,0,0,0,
1,1,0,0,1,1,0,0,
1,1,0,1,1,1,0,0,
1,1,0,0,1,1,1,0,
1,1,0,0,1,0,0,0
};
unsigned char * upSrc;//指向图像数据的指针
LONG x,y;
BYTE num;
//当前点的八邻点
int nDownLeftPixel,nDownPixel,nDownRightPixel,nLeftPixel,nRightPixel,nUpLeftPixel,nUpPixel,nUpRightPixel;
BOOL Finished=FALSE;
while(!Finished)
{
Finished=TRUE;
for (y=1;y<m_lHeight-1;y++)
for(x=1;x<m_lWidth-1;x++)
{
upSrc=(unsigned char *)m_lpDIBBits+m_lLineBytes*y+x;
if(*upSrc==0)
{
nLeftPixel=*(upSrc-1);
nRightPixel=*(upSrc+1);
if( (nLeftPixel==255)|| (nRightPixel==255))
{
nDownLeftPixel=*(upSrc+m_lLineBytes-1);
nDownPixel=*(upSrc+m_lLineBytes);
nDownRightPixel=*(upSrc+m_lLineBytes+1);
nUpLeftPixel=*(upSrc-m_lLineBytes-1);
nUpPixel=*(upSrc-m_lLineBytes);
nUpRightPixel=*(upSrc-m_lLineBytes+1);
num=nDownLeftPixel/255+nDownPixel/255*2+nDownRightPixel/255*4+nLeftPixel/255*8+nRightPixel/255*16+nUpLeftPixel/255*32+nUpPixel/255*64+nUpRightPixel/255*128;
if(erasetable[num]==1)
{
*upSrc=255;
Finished=FALSE;
x++;
}
}
}
}
for (x=1;x<m_lWidth-1;x++)
for(y=1;y<m_lHeight;y++)
{
upSrc=(unsigned char *)m_lpDIBBits+m_lLineBytes*y+x;
if(*upSrc==0)
{
nDownPixel=*(upSrc+m_lLineBytes);
nUpPixel=*(upSrc-m_lLineBytes);
if( (nDownPixel==255)|| (nUpPixel==255))
{
nDownLeftPixel=*(upSrc+m_lLineBytes-1);
nDownRightPixel=*(upSrc+m_lLineBytes+1);
nLeftPixel=*(upSrc-1);
nRightPixel=*(upSrc+1);
nUpLeftPixel=*(upSrc-m_lLineBytes-1);
nUpRightPixel=*(upSrc-m_lLineBytes+1);
num=nDownLeftPixel/255+nDownPixel/255*2+nDownRightPixel/255*4+nLeftPixel/255*8+nRightPixel/255*16+nUpLeftPixel/255*32+nUpPixel/255*64+nUpRightPixel/255*128;
if(erasetable[num]==1)
{
*upSrc=255;
Finished=FALSE;
y++;
}
}
}
}
}
return TRUE;
}
duwenyong
2003-06-30
打赏
举报
回复
BOOL WINAPI ThiningDIB(LPSTR lpDIBBits, LONG lWidth, LONG lHeight)
{
// 指向源图像的指针
LPSTR lpSrc;
// 指向缓存图像的指针
LPSTR lpDst;
// 指向缓存DIB图像的指针
LPSTR lpNewDIBBits;
HLOCAL hNewDIBBits;
LONG lLineBytes=WIDTHBYTES(lWidth * 8);
//脏标记
BOOL bModified;
//循环变量
long i;
long j;
int n;
int m;
//四个条件
BOOL bCondition1;
BOOL bCondition2;
BOOL bCondition3;
BOOL bCondition4;
bool bNotCondition5;
//计数器
unsigned char nCount;
//像素值
unsigned char pixel;
//5×5相邻区域像素值
unsigned char neighbour[5][5];
// 暂时分配内存,以保存新图像
hNewDIBBits = LocalAlloc(LHND, lLineBytes * lHeight);
if (hNewDIBBits == NULL)
{
// 分配内存失败
return FALSE;
}
// 锁定内存
lpNewDIBBits = (char * )LocalLock(hNewDIBBits);
// 初始化新分配的内存,设定初始值为255
lpDst = (char *)lpNewDIBBits;
memset(lpDst, (BYTE)255,lLineBytes * lHeight);
bModified=TRUE;
while(bModified)
{
bModified = FALSE;
// 初始化新分配的内存,设定初始值为255
lpDst = (char *)lpNewDIBBits;
memset(lpDst, (BYTE)255, lLineBytes* lHeight);
for(j = 2; j <lHeight-2; j++)
{
for(i = 2;i <lWidth-2; i++)
{
bCondition1 = FALSE;
bCondition2 = FALSE;
bCondition3 = FALSE;
bCondition4 = FALSE;
bNotCondition5=true;
//由于使用5×5的结构元素,为防止越界,所以不处理外围的几行和几列像素
// 指向源图像倒数第j行,第i个象素的指针
lpSrc = (char *)lpDIBBits + lLineBytes * j + i;
// 指向目标图像倒数第j行,第i个象素的指针
lpDst = (char *)lpNewDIBBits + lLineBytes * j + i;
//取得当前指针处的像素值,注意要转换为unsigned char型
pixel = (unsigned char)*lpSrc;
//目标图像中含有0和255外的其它灰度值
if(pixel != 255 && *lpSrc != 0)
//return FALSE;
continue;
//如果源图像中当前点为白色,则跳过
else if(pixel == 255)
continue;
//获得当前点相邻的5×5区域内像素值,白色用0代表,黑色用1代表
for (m = 0;m < 5;m++ )
{
for (n = 0;n < 5;n++)
{
neighbour[m][n] =(255 - (unsigned char)*(lpSrc + ((4 - m) - 2)*lLineBytes + n - 2 )) / 255;
}
}
// neighbour[][]
//逐个判断条件。
//判断2<=NZ(P1)<=6
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;
//判断Z0(P1)=1
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[1][1]+neighbour[2][1]+
neighbour[3][1]+neighbour[3][2]+neighbour[3][3]+
neighbour[2][3]+neighbour[1][3]==1)
bNotCondition5=false;
//判断P2*P4*P8=0 or Z0(p2)!=1
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;
}
//判断P2*P4*P6=0 or Z0(p4)!=1
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&&bNotCondition5)
{
*lpDst = (unsigned char)255;
bModified = TRUE;
}
else
{
*lpDst = (unsigned char)0;
}
}
}
// 复制腐蚀后的图像
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes * lHeight);
}
// 复制腐蚀后的图像
memcpy(lpDIBBits, lpNewDIBBits, lLineBytes * lHeight);
// 释放内存
LocalUnlock(hNewDIBBits);
LocalFree(hNewDIBBits);
// 返回
return TRUE;
}
doze
2003-06-28
打赏
举报
回复
具体算法,看看我手头有没有。
Sportbeuty
2003-06-27
打赏
举报
回复
我发的楼主收到了没有?
autoegg
2003-06-27
打赏
举报
回复
《Visual C++ 数字图像处理》人民邮电出版社,里面有代码和详细说明,现在已经有第二版了。
如果需要的话,我有256色图像的细化代码可以发给你。
bobworld
2003-06-25
打赏
举报
回复
人民邮电出版社数字图像处理的书有。
wygsh
2003-06-25
打赏
举报
回复
吕凤军的《数字图象处理编程入门》中有细化的内容和代码,可以一看。
Sportbeuty
2003-06-25
打赏
举报
回复
发给你了,注意接了、
ljranby
2003-06-21
打赏
举报
回复
我编过一个,不过只能针对二值图像,发给你看看行不行吧
从业务角度拆解配置巡检平台
标题:从业务角度拆解配置巡检平台 内容概要:从服务拆分、状态流转、容量评估与灰度发布出发,介绍从业务角度拆解配置巡检平台的工程化落地方式。 24直播网:m.hgvsjk.com 24直播网:mxgvsnf.com 24直播网:m.spainvsverde.com 24直播网:m.usa1vsparaguay.com 24直播网:m.canadavsqatar.com
围绕提示词工作台设计现代前端工程
标题:围绕提示词工作台设计现代前端工程 内容概要:聚焦性能优化、权限隔离、数据一致性与监控告警,讲解围绕提示词工作台设计现代前端工程的设计思路。 24直播网:www.ncaima.net 24直播网:kxzzyzs.com 24直播网:www.huhu520.com 24直播网:www.cdxstd.com 24直播网:m.hyst9.com
【Python编程】Python异步编程与asyncio核心原理
内容概要:本文全面解析Python异步编程的协程机制,重点对比async/await语法与生成器协程的历史演进、事件循环的调度策略及任务并发模型。文章从协程状态机(CORO_CREATED/CORO_RUNNING/CORO_SUSPENDED/CORO_CLOSED)出发,深入分析Task对象的包装与回调机制、Future的回调注册与结果获取、以及asyncio.gather与asyncio.wait的批量等待差异。通过
代码
示例展示aiohttp异步HTTP客户端、aiomysql异步数据库驱动的实战用法,同时介绍异步上下文管理器(async with)、异步迭代器(async for)的协议实现、以及uvloop对事件循环的性能加速,最后给出在高并发网络服务、实时数据流处理、微服务编排等场景下的异步架构设计原则。 24直播网:miguvideo.hcxyey.hl.cn 24直播网:xiaohongshu.yczllq.org.cn 24直播网:wap.feizbzhibo.com 24直播网:wap.feizbzhibo.cn 24直播网:m.yishuntongda.com
从架构层面拆解提示词工作台
标题:从架构层面拆解提示词工作台 内容概要:从服务拆分、状态流转、容量评估与灰度发布出发,介绍从架构层面拆解提示词工作台的工程化落地方式。 24直播网:m.shqjfwgs.com 24直播网:m.longcai0427.com 24直播网:lnlcyl.com 24直播网:quantumedi.com 24直播网:m.getzscl.com
用Java重塑审计日志查询服务
标题:用Java重塑审计日志查询服务 内容概要:结合用户体验、稳定性治理、扩展机制和排障手段,分析用Java重塑审计日志查询服务的建设方案。 24直播网:m.gzqddcw.com 24直播网:www.jxbjylmr.net 24直播网:m.jsjzlzs.com 24直播网:www.shqinang.cn 24直播网:m.shquanxingm.com
图形处理/算法
19,465
社区成员
50,678
社区内容
发帖
与我相关
我的任务
图形处理/算法
VC/MFC 图形处理/算法
复制链接
扫一扫
分享
社区描述
VC/MFC 图形处理/算法
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章