def apply_mask_to_image(
    img_foreground: np.ndarray,
    img_background: np.ndarray,
    mask: np.ndarray,
    mask_blur: int = 5,
    expand_kernal=5,
) -> np.ndarray:
    """
    Apply a mask to an image to keep pixels where the mask is 255 and set other areas to white.

    Args:
        img_foreground (np.ndarray): The foreground image.
        img_background (np.ndarray): The background image.
        mask (np.ndarray): mask wthite use foreground, the other use background
        mask_blur (int): kernal size of mask_blur

    Returns:
        np.ndarray: The processed image with the specified pixels retained and other areas set to white.
    """
    mask = cv2.dilate(np.array(mask), np.ones((expand_kernal, expand_kernal), np.uint8), iterations=1)
    mask_blur = cv2.GaussianBlur(np.array(np.uint8(mask)), (mask_blur, mask_blur), 0)
    if len(mask_blur.shape) == 2:
        mask_blur = np.stack((mask_blur,) * 3, axis=-1)
    result = np.array(img_foreground, np.uint8) * (mask_blur / 255.0) + np.array(img_background, np.uint8) * ((255 - mask_blur) / 255.0)

    return result

    Apply a mask to an image to keep pixels where the mask is 255 and set other areas to white.

    Args:
        img_foreground (np.ndarray): The foreground image.
        img_background (np.ndarray): The background image.
        mask (np.ndarray): mask wthite use foreground, the other use background
        mask_blur (int): kernal size of mask_blur

    Returns:
        np.ndarray: The processed image with the specified pixels retained and other areas set to white.
    
scripts/easyphoto_utils/tryon_utils.py