Fix bugs in histogram of orientations