robert算子检测边界

#检测mask图像边界
def roberts_detect(img):
    image = cv2.copyMakeBorder(img, 1, 0, 1, 0, cv2.BORDER_DEFAULT)
    for i in range(1, image.shape[0]):
        for j in range(1, image.shape[1]):
            image[i, j] = RobertsOperator(image[i - 1:i + 2, j - 1:j + 2])
    return image[1:image.shape[0], 1:image.shape[1]]


# 将三维图像抽壳
def border_mask_3d(mask):
    thickness, width, length = mask.shape
    border_3d = np.zeros((thickness, width, length))
    for i in range(thickness):
        temp_border = filters.roberts(mask[i])
        border_3d[i] = temp_border
    return border_3d

你可能感兴趣的:(计算机视觉,python)