算法实现:
/*************均值方差法对图像进行阈值分割*********************
***函数来源:本算法实现了论文“基于车载摄像头的前方运动
***车辆检测与跟踪方法研究”提出的阈值分割算法
***函数名称:cvMeanVarThreshold
***函数参数:IplImage* image
***函数说明:对输入图像进行两次自适应阈值分割提取彻底阴影
*****************************************************/
float cvMeanVarThreshold(IplImage* image)
{
int height = image->height;
int width = image->width;
int size = height * width;
int row, col, i;
float pixelSum[256];
for (i = 0; i < 256; i++)
{
pixelSum[i] = 0;
}
for (row = 0; row < height; row++)
{
for (col = 0; col < width; col++)
{
uchar* ptr = (uchar*)(image->imageData + image->widthStep * row + col);
pixelSum[*ptr]++;//统计图像中某一灰度值的像素总数
}
}
float pixelsum = 0;
float pixelavg1, pixelavg2;
float pixelavr1 = 0.0, pixe
采用均值、方差法实现求取图像的阈值
最新推荐文章于 2022-11-16 15:14:53 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)