【问题标题】:MATLAB: Crop an image using Row Projection HistogramMATLAB:使用行投影直方图裁剪图像
【发布时间】:2016-06-12 10:51:21
【问题描述】:

我是Matlab 的初学者,我正在尝试实现ANPR Parking System 的研究论文,它使用行投影直方图来识别车牌的水平区域。我编写了以下代码来计算垂直梯度:

Matlab 代码:

[rows,cols] = size(img);
img2 = zeros(rows,cols);

%Calculated the gradients
for i =1:1:rows
    for j =1:1:cols-1
        img2(i,j) = abs(img(i,j+1) - img(i,j));
    end
end

% calculated the mean of gradients to determine which pixels hold the value
% that is above the average difference as the paper says `Then the average
% gradient variance is calculated and compared with each other. The bigger
% intensity variations provide the rough estimation of license plate region.`

M = mean2(img2);
for i =1:1:rows
    for j =1:1:cols-1
        if(abs(img(i,j+1) - img(i,j))<M)
            img2(i,j)=0;
        else
            img2(i,j)=100;
        end
    end
end

% Applied average filter to reduce the noise
img2 = filter2(fspecial('average',2),img2)/255;

% Output is shown
figure,imshow(img2);title('Gradient');

在梯度计算之后,我计算了以下直方图:

现在我需要根据论文中给出的标准裁剪车牌:

但我不知道如何根据水平投影直方图裁剪图像?

我在mathworksstackoverflow 上阅读了一些答案,但找不到关于我的问题的任何指导。有人请指导我如何裁剪水平区域,如图所示。提前致谢。

【问题讨论】:

    标签: matlab image-processing histogram crop projection


    【解决方案1】:

    说明是“垂直梯度的水平投影”。你在计算投影之前计算了垂直梯度吗?

    从图像的外观来看,我认为您可能从另一个类似的问题here 中错过了这一步。

    【讨论】:

    • 很抱歉,我不明白这个答案是否有助于使用直方图裁剪图像。我想我没有错过那一步。请查看更新后的问题,我已将前面的步骤添加到我的问题中。
    • 首先我不确定您所说的直方图是什么意思。直方图为您提供有关图像的信息,并且与像素的位置无关。只是他们的价值观。现在当你说水平投影时,基本上意味着每列中所有像素的总和。 (我也为此使用了方差,有时效果会更好一些)。因此,一旦您执行水平投影,您将得到一个 vector 。该向量将帮助您识别车牌的裁剪点。
    猜你喜欢
    • 1970-01-01
    • 2013-04-20
    • 2016-12-05
    • 2012-02-12
    • 2013-03-08
    • 2014-10-20
    • 1970-01-01
    • 2011-09-03
    相关资源
    最近更新 更多