在计算用于HOG描述符提取的梯度方向时,我们可以选择使用0-180或0-360之间的梯度方向,我们如何使用Matlab生成这样的角度?我有以下代码:
Im=imread('cameraman.tif'); // reading the image
Im=double(Im); // converting it to double
hx = [-1,0,1]; // the gradient kernel for x direction
hy = -hx; // the gradient kernel for y direction
grad_x = imfilter(Im,hx); //gradient image in x direction
grad_y = imfilter(Im,hy); // gradient image in y direction
% angles in 0-180:
...
%angles in 0-360:
...