def mask_to_box(mask: np.ndarray) -> Tuple[np.ndarray, Tuple[int, int, int, int]]:
    """
    Get the largest connected component and return its bounding box.

    Args:
        mask (np.ndarray): The input binary mask.

    Returns:
        Tuple[np.ndarray, Tuple[int, int, int, int]]:
            - Largest connected component binary mask.
            - Bounding box coordinates (x, y, x + width, y + height).
    """
    if len(mask.shape) == 3:
        mask = mask[:, :, 0]

    # Find connected components
    num_labels, labels, stats, _ = cv2.connectedComponentsWithStats(mask)

    # Find the largest connected component
    # Ignore the background label
    largest_label = np.argmax(stats[1:, cv2.CC_STAT_AREA]) + 1

    # Create a new mask with only the largest connected component
    largest_connected_component_mask = np.zeros_like(mask)
    largest_connected_component_mask[labels == largest_label] = 255

    # Find the bounding box for the largest connected component
    x, y, width, height = cv2.boundingRect(largest_connected_component_mask)

    # Set all regions outside of the bounding box to black
    largest_connected_component_mask[:y, :] = 0
    largest_connected_component_mask[y + height :, :] = 0
    largest_connected_component_mask[:, :x] = 0
    largest_connected_component_mask[:, x + width :] = 0

    return largest_connected_component_mask, (x, y, x + width, y + height)

    Get the largest connected component and return its bounding box.

    Args:
        mask (np.ndarray): The input binary mask.

    Returns:
        Tuple[np.ndarray, Tuple[int, int, int, int]]:
            - Largest connected component binary mask.
            - Bounding box coordinates (x, y, x + width, y + height).
    
scripts/easyphoto_utils/tryon_utils.py