def detect_optic_disk(image_rgb, disk_center, out_name):
scale = 100
w_sum = cv2.addWeighted(image_rgb, 4, cv2.GaussianBlur(image_rgb, (0, 0), scale / 30), -4, 128)# * circular_mask + 128 * (1 - circular_mask)
# Image.fromarray(np.mean(w_sum, axis=2).astype(np.uint8)).save(out_name)
edges = canny(np.mean(w_sum, axis=2).astype(np.uint8), sigma=1.,
low_threshold=50.)#, high_threshold=100.)
result = hough_ellipse(edges, threshold=10, min_size=45, max_size=55)
result.sort(order='accumulator')
best = list(result[-1])
yc, xc, a, b = [int(round(x)) for x in best[1:5]]
orientation = best[5]
cy, cx = ellipse_perimeter(yc, xc, a, b, orientation)
image_rgb[cy, cx] = (0, 0, 255)
Image.fromarray(image_rgb).save(out_name)
评论列表
文章目录