Untitled

 avatar
unknown
python
2 years ago
791 B
4
Indexable
def enclosing_circle(enclose_mask):
    contours, _ = cv2.findContours(enclose_mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    largest_contour = max(contours, key=cv2.contourArea)
    (center_x, center_y), radius = cv2.minEnclosingCircle(largest_contour)
    center = (int(center_x), int(center_y))
    radius = int(radius)
    return center, radius
        
def circle_mask(enclose_mask):
    center, radius = enclosing_circle(enclose_mask)
    c_mask = np.zeros_like(self.mask, dtype=np.uint8)
    c_mask = cv2.circle(c_mask, center, radius, (1, 1, 1), -1)
    return c_mask
    
def polar_image(inpainted_circle_image, c_mask):
    center, radius = enclosing_circle(c_mask)

    return cv2.linearPolar(inpainted_circle_image, center, radius, cv2.WARP_FILL_OUTLIERS)
Editor is loading...