• 轮廓提取


    图像的轮廓提取在数字图像处理第三版(中文版 冈萨雷斯)第九章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;
    }

    版权声明:

  • 相关阅读:
    Android 禁用以及捕捉home键
    android中正确导入第三方jar包
    使用SharedPreferences进行数据存储
    tomcat不安全因素
    spring边边角角
    宏定义
    C++变量对比java变量所占内存
    结构指针的分析
    对结构使用指针
    什么是程序文件?
  • 原文地址:https://www.cnblogs.com/walccott/p/4957133.html
Copyright © 2020-2023  润新知