网站最新上线:http://www.hslogic.com/

HOG梯度特征提取

上一篇 / 下一篇  2018-09-16 21:11:47

function [gradx, grady] = HOGGradient(G)

% here we defing the mask as [-1, 0, 1], the edge of the image use [-1, 1]
[height, width] = size(G);

gradx = zeros(height, width);
grady = zeros(height, width);

% Process the Image edge
gradx(:,1) = sum(G(:,1:2).*repmat([-1, 1], height, 1), 2);
gradx(:,width) = sum(G(:, width-1:width).*repmat([-1, 1], height, 1), 2);

grady(1,:) = sum(G(1:2, :).*repmat([-1; 1], 1, width), 1);
grady(height,:) = sum(G(height-1:height, :).*repmat([-1; 1], 1, width), 1);

for j=2:height-1
    for i=2:width-1
        tmpx = G(j, i-1:i+1);
        tmpy = G(j-1:j+1, i);
        gradx(j,i) = sum(tmpx.*[-1, 0, 1], 2);
        grady(j,i) = sum(tmpy.*[-1; 0; 1], 1);
    end
end

TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar