社区
图形处理/算法
帖子详情
有没有关于图像处理中的细化的算法代码,或者书集
wanzi7
2003-06-21 11:12:48
代码或者书都可以,请发到wanzi7@etang.com
谢谢!!
...全文
53
9
打赏
收藏
有没有关于图像处理中的细化的算法代码,或者书集
代码或者书都可以,请发到wanzi7@etang.com 谢谢!!
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用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
打赏
举报
回复
我编过一个,不过只能针对二值图像,发给你看看行不行吧
形态学
图像处理
之
细化
算法
基本概念 “骨架”是指一幅图像的骨骼部分,它描述物体的几何形状和拓扑结构,是重要的图像描绘子之一。计算骨架的过程一般称为“
细化
”或“骨架化”,在包括文字识别、工业零件形状识别以及印刷电路板自动检测在内的很多应用
中
,
细化
过程都发挥这关键作用。通常,对我们感兴趣的目标物体进行
细化
有助于突出目标的形状特点和拓...
图像处理
------图像
细化
图像处理
------图像
细化
算法
流程参考自:
图像处理
细化
算法
参考博文
中
没有
细化
算法
的
代码
实现,只有
算法
的具体流程,在本文
中
,使用python实现图像
细化
的
代码
实现,但其运行效率没有考虑,只为理解
算法
原理:
算法
原理步骤 对二值图像进行
细化
,就是骨架提取,删除不需要的轮廓点,保留其骨架点。假设一个像素点,该点为p1,八邻域为p2->p9,通过考虑P1邻域的实际情况,以便决定是否删除P1点。假设处理的图像为二值图形,背景为黑色0,
细化
的前景为1.
算法
流程,分为两步,每步判断四个条件,然后决定像素点
图像处理
之图像
细化
一、图像的
细化
基础概念
细化
技术:把一个平面区域简化成图的结构形状表示法 骨架:一种
细化
的结构,它是目标重要的拓扑描述,具有很广泛的应用,再图像识别或者数据压缩时候,经常要用到
细化
结构。减少数据的冗余量,去掉没用用的信息
细化
算法
:采取逐次去除边界的方法来进行的,不能破环图像的连通性 通常我们会定义一个规则,来判断哪个点可以删除,哪个点不能删除。 在
细化
图像的过程
中
,应该满足两个条件: 在
细化
...
图像处理
细化
算法
转自:OpenCV学习(13)
细化
算法
(1) 程序编码参考经典的
细化
或者骨架
算法
文章: T. Y. Zhang and C. Y. Suen, “A fast parallel algorithm for thinning digital patterns,” Comm. ACM, vol. 27, no. 3, pp. 236-239, 1984. 它的原理也很简单: 我们...
二值图像快速
细化
算法
二值图像的
细化
是讨论将一个图像
中
的黑色部分沿着它的
中
心轴线将其
细化
为一个像素宽的线条的处理过程,
细化
的结果能基本保留图形
中
黑色部分的拓扑结构。图像
细化
是图像模式识别的关键步骤。快速
细化
算法
的思想是优化了原
细化
算法
中
由边界逐层消除黑色像素点的过程,提高
细化
效率。
细化
前
图形处理/算法
19,473
社区成员
50,678
社区内容
发帖
与我相关
我的任务
图形处理/算法
VC/MFC 图形处理/算法
复制链接
扫一扫
分享
社区描述
VC/MFC 图形处理/算法
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章