//STEP 2:进行空间矩运算计算亚像素级边缘
int count = 0;
//这里先定义一个数组来存放边缘点
double *Edge_x = new double[1000];
double *Edge_y = new double[1000];
//边缘点的数目
long Account = 0;
//定义三个数组,分别用来保存每个模板中心点的H,K,L
double *h = new double[nWidth*nHeight];
double *l = new double[nWidth*nHeight];
double *k = new double[nWidth*nHeight];
//定义六个用来存储6个矩的变量
double M00 = 0.0, M01 = 0.0, M10 = 0.0, M11 = 0.0, M20 = 0.0, M02 = 0.0;
//定义三个用来存储旋转后的矩的值
double M_00 = 0.0, M_10 = 0.0, M_20 = 0.0;
double cos_theta = 0.0;
double sin_theta = 0.0;
// CString RR1;
// RR1.Format("ARRAY LENGTH IS:%d",ptArray.GetSize());
// MessageBox(RR1);
//取出每个点之后进行与模版相与处理
//判断在使用SOBEL检测出来的边缘点,然后使用原来图片的另一个拷贝对象pTemBmp作为空间矩处理对象。
for(x = 2; x <= nWidth-2; x++)
{
for(y = 2; y <= nHeight-2; y++)
{
//判断如果当前为像素级边缘的时候才开始计算他的DELTA L
if(pTempBmp->m_pBits[(nHeight - y - 1)*nSaveWidth+x] == 0)
{
//重置为0
//M00 = 0;
//判断边缘点个数加1
Account =Account +1;
CString str1,str2;
str1.Format("x=%d,",x);
str2.Format("y=%d ", y);
str1=str1+str2;
M00 = 0;
M01 = 0;
M10 = 0;
M11 = 0;
M20 = 0;
M02 = 0;
M_00 = 0;
M_10 = 0;
M_20 = 0;
//计算
//第一行
M00 = pTemBmp->m_pBits[(x-2)+((nHeight - y - 1)-2)*nSaveWidth]*0.0219 + pTemBmp->m_pBits[(x-1)+((nHeight - y - 1)-2)*nSaveWidth]*0.1231
+pTemBmp->m_pBits[x+((nHeight - y - 1)-2)*nSaveWidth]*0.1573 +pTemBmp->m_pBits[(x+1)+((nHeight - y - 1)-2)*nSaveWidth]*0.1231
+pTemBmp->m_pBits[(x+2)+((nHeight - y - 1)-2)*nSaveWidth]*0.0219
//第二行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)-1)]*0.1231 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)-1)]*0.1600
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)-1)]*0.1600 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)-1)]*0.1600
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)-1)]*0.1231
//第三行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*(nHeight - y - 1)]*0.1573 +pTemBmp->m_pBits[(x-1)+nSaveWidth*(nHeight - y - 1)]*0.1600
+pTemBmp->m_pBits[x+nSaveWidth*(nHeight - y - 1)]*0.1600 +pTemBmp->m_pBits[(x+1)+nSaveWidth*(nHeight - y - 1)]*0.1600
+pTemBmp->m_pBits[(x+2)+nSaveWidth*(nHeight - y - 1)]*0.1573
//第四行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+1)]*0.1231 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+1)]*0.1600
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+1)]*0.1600 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+1)]*0.1600
+pTemBmp->m_pBits[x+2+nSaveWidth*((nHeight - y - 1)+1)]*0.1231
//第五行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+2)]*0.0219 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+2)]*0.1231
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+2)]*0.1573 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+2)]*0.1231
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)+2)]*0.0219;
//第一行
M11 = pTemBmp->m_pBits[(x-2)+((nHeight - y - 1)-2)*nSaveWidth]*(-0.0098) + pTemBmp->m_pBits[(x-1)+((nHeight - y - 1)-2)*nSaveWidth]*(-0.0352)
+pTemBmp->m_pBits[x+((nHeight - y - 1)-2)*nSaveWidth]*0.000 +pTemBmp->m_pBits[(x+1)+((nHeight - y - 1)-2)*nSaveWidth]*0.0352
+pTemBmp->m_pBits[(x+2)+((nHeight - y - 1)-2)*nSaveWidth]*0.0098
//第二行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)-1)]*(-0.0352) +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)-1)]*(-0.0256)
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)-1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)-1)]*0.0256
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)-1)]*0.0352
//第三行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*(nHeight - y - 1)]*0.000 +pTemBmp->m_pBits[(x-1)+nSaveWidth*(nHeight - y - 1)]*0.000
+pTemBmp->m_pBits[x+nSaveWidth*(nHeight - y - 1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*(nHeight - y - 1)]*0.000
+pTemBmp->m_pBits[(x+2)+nSaveWidth*(nHeight - y - 1)]*0.000
//第四行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+1)]*0.0352 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+1)]*0.0256
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+1)]*(-0.0256)
+pTemBmp->m_pBits[x+2+nSaveWidth*((nHeight - y - 1)+1)]*(-0.0352)
//第五行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+2)]*0.0098 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+2)]*0.0352
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+2)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+2)]*(-0.0352)
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)+2)]*(-0.0098);
//第一行
M10 = pTemBmp->m_pBits[(x-2)+((nHeight - y - 1)-2)*nSaveWidth]*(-0.0147) + pTemBmp->m_pBits[(x-1)+((nHeight - y - 1)-2)*nSaveWidth]*(-0.0469)
+pTemBmp->m_pBits[x+((nHeight - y - 1)-2)*nSaveWidth]*0.000 +pTemBmp->m_pBits[(x+1)+((nHeight - y - 1)-2)*nSaveWidth]*0.0469
+pTemBmp->m_pBits[(x+2)+((nHeight - y - 1)-2)*nSaveWidth]*0.0147
//第二行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)-1)]*(-0.0933) +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)-1)]*(-0.0640)
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)-1)]*0.000 +pTemBmp->m_pBits[(x+1)+nHeight*((nHeight - y - 1)-1)]*0.0640
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)-1)]*0.0933
//第三行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*(nHeight - y - 1)]*(-0.1253) +pTemBmp->m_pBits[(x-1)+nSaveWidth*(nHeight - y - 1)]*(-0.0640)
+pTemBmp->m_pBits[x+nSaveWidth*(nHeight - y - 1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*(nHeight - y - 1)]*0.0640
+pTemBmp->m_pBits[(x+2)+nSaveWidth*(nHeight - y - 1)]*0.1253
//第四行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+1)]*(-0.0933) +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+1)]*(-0.0640)
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+1)]*0.0640
+pTemBmp->m_pBits[x+2+nSaveWidth*((nHeight - y - 1)+1)]*0.0933
//第五行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)+2)]*(-0.0147) +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)+2)]*(-0.0469)
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)+2)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)+2)]*0.0469
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)+2)]*0.0147;
M01 = pTemBmp->m_pBits[(x-2)+((nHeight - y - 1)-2)*nSaveWidth]*(0.0147) + pTemBmp->m_pBits[(x-1)+((nHeight - y - 1)-2)*nSaveWidth]*0.0933
+pTemBmp->m_pBits[x+((nHeight - y - 1)-2)*nSaveWidth]*0.1253 +pTemBmp->m_pBits[(x+1)+((nHeight - y - 1)-2)*nSaveWidth]*0.0933
+pTemBmp->m_pBits[(x+2)+((nHeight - y - 1)-2)*nSaveWidth]*0.0147
//第二行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y - 1)-1)]*0.0469 +pTemBmp->m_pBits[(x-1)+nSaveWidth*((nHeight - y - 1)-1)]*(0.0640)
+pTemBmp->m_pBits[x+nSaveWidth*((nHeight - y - 1)-1)]*0.0640 +pTemBmp->m_pBits[(x+1)+nSaveWidth*((nHeight - y - 1)-1)]*0.0640
+pTemBmp->m_pBits[(x+2)+nSaveWidth*((nHeight - y - 1)-1)]*0.0469
//第三行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*(nHeight - y - 1)]*0.000 +pTemBmp->m_pBits[(x-1)+nSaveWidth*(nHeight - y - 1)]*0.000
+pTemBmp->m_pBits[x+nSaveWidth*(nHeight - y - 1)]*0.000 +pTemBmp->m_pBits[(x+1)+nSaveWidth*(nHeight - y - 1)]*0.000
+pTemBmp->m_pBits[(x+2)+nSaveWidth*(nHeight - y - 1)]*0.000
//第四行
+pTemBmp->m_pBits[(x-2)+nSaveWidth*((nHeight - y
daksfjaawdawawd.rar_daksfjaawdawawd_sub-pixel edge_亚像素边缘_亚像素边缘c+
版权申诉
21 浏览量
2022-07-15
15:37:44
上传
评论
收藏 2KB RAR 举报
钱亚锋
- 粉丝: 86
- 资源: 1万+
最新资源
- 学生成绩管理系统-C++版本
- 吉林大学离散数学2笔记.pdf
- 通道处理过程的模拟通常涉及对通道处理机制的理解与实现.txt
- Flume进阶-自定义拦截器jar包
- Dubins曲线算法讲解和在运动规划中的使用.pdf
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.dta
- 上市公司-股票性质数据-工具变量(民企、国企、央企)2003-2022年.xlsx
- Reeds+Shepp曲线算法讲解和实现.pdf
- 毕业设计基于SpringBoot+MyBatisPlus+MySQL+Vue的外卖配送信息系统源代码+数据库
- 词向量(Word Embeddings)是自然语言处理(NLP)领域的一种重要技术.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0