19,468
社区成员
发帖
与我相关
我的任务
分享
unsigned char* lpSrc1;
unsigned char* lpSrc2;
double result=0;
for (int i = 0; i < m_height; i++)
{
lpSrc1 = (unsigned char *)m_pDibBits + m_width *3* i;
for(int j = 0; j < m_width; j++)
{
lpSrc2 = lpSrc1+j*3;
result=0.114*(*(lpSrc2+0))+0.587*(*(lpSrc2+1))+0.3*(*(lpSrc2+2));
*(lpSrc2+0)=(BYTE)result;
*(lpSrc2+1)=(BYTE)result;
*(lpSrc2+2)=(BYTE)result;
}
}
unsigned char* lpSrc;
for(int i = 0; i <m_height*m_width*lBitCount/8; i++)
{
if(m_pDibBits[i]>thresholdValue)
m_pDibBits[i]=255;
else
m_pDibBits[i]=0;
}
for(int x=0; x<m_height;x++)
{
for(int y=0; y<m_width*lbitCount/8;y++)
{
if(m_pDbiBits[x*m_width*lbitCount/8+y]==255)
// 输出亮点坐标
printf("xPos = %d,yPos = %d",x,y/lbitCount*8);
}
}
[/quote]
这段代码注释写的很清楚了,就是遍历整个图像,输出图像中像素值为255的亮点的坐标。不是找图像的中心。图像的中心也不用找啊,图像的中心不就是图像的中心点吗?[/quote]
通过遍历整个图像的亮点,记住起亮点的始点和终点,然后运算后得出中心位置,是这样的吧。for(int x=0; x<m_height;x++)
{
for(int y=0; y<m_width*lbitCount/8;y++)
{
if(m_pDbiBits[x*m_width*lbitCount/8+y]==255)
// 输出亮点坐标
printf("xPos = %d,yPos = %d",x,y/lbitCount*8);
}
}
[/quote]
这段代码注释写的很清楚了,就是遍历整个图像,输出图像中像素值为255的亮点的坐标。不是找图像的中心。图像的中心也不用找啊,图像的中心不就是图像的中心点吗?for(int x=0; x<m_height;x++)
{
for(int y=0; y<m_width*lbitCount/8;y++)
{
if(m_pDbiBits[x*m_width*lbitCount/8+y]==255)
// 输出亮点坐标
printf("xPos = %d,yPos = %d",x,y/lbitCount*8);
}
}
for(int x=0; x<m_height;x++)
{
for(int y=0; y<m_width*lbitCount/8;y++)
{
if(m_pDbiBits[x*m_width*lbitCount/8+y]==255)
// 输出亮点坐标
printf("xPos = %d,yPos = %d",x,y/lbitCount*8);
}
}