Advertisement

Smooth the histogram

阅读量:
复制代码
      一个好的阈值应该对应着直方图中两个峰之间的最小值。但是,由于灰度直方图中的随机波动,两个峰尖的最大值和他们之间谷底的最小值都不能被很好的确定。所以需对直方图进行平滑处理。这里用高斯平滑。
    
复制代码
 void Thresholding::ComputeHist()

    
 {
    
 	if (m_nBitCount!=8)
    
 	{
    
 		return;
    
 	}
    
  
    
 	for (int i=0; i<256; i++)
    
 	{
    
 		m_histArray[i]=0;
    
 	}
    
  
    
 	int lineByte=(m_imgWidth*m_nBitCount/8+3)/4*4;
    
  
    
 	for (int i=0; i<m_imgHeight; i++)
    
 	{
    
 		for(int j=0; j<m_imgWidth; j++)
    
 		{
    
 			int temp=*(m_pImgData+i*lineByte+j);
    
 			m_histArray[temp]++;
    
 		}
    
 	}
    
 }
    
    
    

全部评论 (0)

还没有任何评论哟~