基于直方图的图像全局二值化算法原理、实现--百分比阈值(P-Tile)

来源:互联网 发布:新华三java笔试题 编辑:程序博客网 时间:2024/05/16 11:31
 //HistGram灰度图像的直方图 //Tile背景在图像中所占的面积百分比    int GetPTileThreshold(int* HistGram, int Tile)    {        int Y, Amount = 0, Sum = 0;        for (Y = 0; Y < 256; Y++) Amount += HistGram[Y];        //  像素总数         for (Y = 0; Y < 256; Y++)        {            Sum = Sum + HistGram[Y];            if (Sum >= Amount * Tile / 100) return Y;        }        return -1;    }
0 0