def __filter_candidate(greyscale_image, coord, neighborhood_size):
window = greyscale_image[coord[0] - neighborhood_size:coord[0] + neighborhood_size + 1,
coord[1] - neighborhood_size:coord[1] + neighborhood_size + 1]
grad_x = cv2.Sobel(window, cv2.CV_32FC1, dx=1, dy=0, ksize=3)
grad_y = cv2.Sobel(window, cv2.CV_32FC1, dx=0, dy=1, ksize=3)
grad_mag = np.abs(grad_x) + np.abs(grad_y)
grad_mag_flat = grad_mag.flatten()
orientations_flat = (cv2.phase(grad_x, grad_y) % pi).flatten() # phase accuracy: about 0.3 degrees
hist = (np.histogram(orientations_flat, bins=64, range=(0, pi), weights=grad_mag_flat)[0] /
(neighborhood_size * neighborhood_size))
return hist, grad_mag
评论列表
文章目录