在影像分析之中常見的分析手法是透過投影(projection)後找到最適合的分割點,進而成功取得感興趣的區域。

其方法是透過統計垂直/水平 上所有的像素點。

分析成果如下圖所示。

 

也可以用在文字切割處理透過投影方是,找到文字的分割點,進而將文字分割出來進行後續辨識。


垂直投影程式碼:

private void verticalProcess()
{
    Max_vertical = 0;
    int width = _srcImage.Width;
    int height = _srcImage.Height;

    int count = 0;
    for (int y = 0; y < height; y++)
    {
        count = 0;
        for (int x = 0; x < width; x++)
        {
            if (!_IsInverse)
            {
                if (_imageMap[x, y] > _Threshold)
                    count++;
            }
            else
            {
                if (_imageMap[x, y] < _Threshold)
                    count++;
            }

        }
        _vertical[y] = count;

        if (count > Max_vertical)
            Max_vertical = count;
    }
}

 

水平投影程式碼:

private void horizontalProcess()
{
    Max_horizontal = 0;
    int width = _srcImage.Width;
    int height = _srcImage.Height;

    int count = 0;
    for (int x = 0; x < width; x++)
    {
        count = 0;
        for (int y = 0; y < height; y++)
        {
            if (!_IsInverse)
            {
                if (_imageMap[x, y] > _Threshold)
                    count++;
            }
            else
            {
                if (_imageMap[x, y] < _Threshold)
                    count++;
            }
        }
        _horizontal[x] = count;

        if (count > Max_horizontal)
            Max_horizontal = count;
    }
}

 

 

arrow
arrow
    文章標籤
    Image Process
    全站熱搜

    Lung-Yu,Tsai 發表在 痞客邦 留言(0) 人氣()