首页 新闻 赞助 找找看

RGB 提取绿色分量画曲线图

0
悬赏园豆:10 [已关闭问题]

我从一张图片的每个像素那获取RGB 的绿色分量 把单位宽为1 的所有绿色分量的平均值 通过坐标曲线表现出来 横坐标为宽 纵坐标为绿色分量 我写了一部分代码但是那平均值那总是不对 大家帮忙看看 谢谢大家

 //24位
 else if(bm.bmBitsPixel == 24)
 {
  if(pGreenDate!=NULL)
  {
   delete [] pGreenDate;
   pGreenDate= NULL;
  }
  pGreenDate= new BYTE[bm.bmHeight*bm.bmWidth];
  BYTE *pData = (BYTE*)buf;
  
  int nWidth = bm.bmWidth*3;
  while(nWidth %4 != 0)
  {
   nWidth++;
  }
  nWith= bm.bmWidth;
  nHeight= bm.bmHeight;
  pointCount= nWith;//*nHeight
  int totleGreen= 0;
  int min=255;

  int j=0;
  for(int i=bm.bmHeight-1; i>=0; i--)
  {
  
   for( j=0; j<=bm.bmWidth; j++)
   {
    pGreenDate[i*bm.bmWidth+j]=pData[i*nWidth+j*3+1];
    
    if(min>pData[i*nWidth+j*3+1])
    {
     min=pData[i*nWidth+j*3+1];
    }
    
   }

}

以上是每个像素的绿色分量

怎么求单位为1的绿色分量的平均值?

以下代码出的平均值不对 大家帮忙了 谢谢

 LineGreen= new BYTE[bm.bmWidth];
  BYTE TO;
  for (int t=1;t<=bm.bmWidth;t++)
  {
    for(int p=bm.bmHeight;p>=1;p--)
    {
     TO+=pGreenDate[p]; 
     
    }
    LineGreen[t]=TO/bm.bmHeight;
     CString sMsg1;
     sMsg1.Format("LineGreen is: %d", LineGreen[t]);
     AfxMessageBox(sMsg1);
  }

小芊的主页 小芊 | 初学一级 | 园豆:180
提问于:2010-05-10 17:14
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册