轮廓提取

图像的轮廓提取在数字图像处理第三版(中文版 冈萨雷斯)第九章412页,讲得很清楚,在此就不赘述了。

将腐蚀和相减化作一步,上代码

BOOL CImageColorProcess::Contour(LPBYTE lpSrc, LPBYTE lpDst, LPBYTE lpDst_, int nSrcCount, int nW, int nH)
{
	this->OSTUThreshold(lpSrc, lpDst_, nSrcCount, nW, nH);//首先大律法二值化
	for (int i = 0; i < nH; i++)
	{
		for (int j = 0; j < nW; j++)
		{
			lpDst[i*nW + j] = 255;
		}
	}
	for (int i = 1; i < nH - 1; i++)
	{
		for (int j = 1; j < nW - 1; j++)
		{
			if (lpDst_[i*nW + j] == 0)
			{
				lpDst[i*nW + j] = 0;
				int nw = lpDst_[(i + 1)*nW + j - 1];
				int n = lpDst_[(i + 1)*nW + j];
				int ne = lpDst_[(i + 1)*nW + j + 1];
				int w = lpDst_[i*nW + j - 1];
				int e = lpDst_[i*nW + j + 1];
				int sw = lpDst_[(i - 1)*nW + j - 1];
				int s = lpDst_[(i - 1)*nW + j];
				int se = lpDst_[(i - 1)*nW + j + 1];
				if (nw + n + ne + e + sw + se + s + w == 0)
				{
					lpDst[i*nW + j] = 255;
				}
			}
		}
	}
	return true;
}

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值