I noticed a bug in the histogram computation. Gradient vectors whose angle is equal to pi are being omitted from the histogram because you check for angle < angle_lim instead of angle <= angle_lim.
I also re-wrote the histogram computation to optimize it in a way similar to what was suggested in an earlier comment.
% Compute the bin index for every angle.
binIndeces = ceil((v_angles + pi) / binSize);
% For each bin
for (bin = 1:B)
% Get the magnitudes for all the pixels that belong in 'bin'.
magnitudes = v_magnit(binIndeces == bin);
% Add all of the magnitudes to 'bin'.
H2(bin) = H2(bin) + sum(magnitudes);
Could you explain why it was adopted blockwise normalization? From the best of my knowledge, there is no mathematical foundation behind HOG descriptors, only good sense. This is my version, which was made available to be evaluated by the community. Go ahead, you should make the comparison with other algorithms in your case study (Science is not religion, feel free to doubt and inovate).