def merge_images(
        img1: np.ndarray,
        img2: np.ndarray,
        mask1: np.ndarray,
        mask2: np.ndarray,
        x: float,
        y: float,
    ) -> Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, float]:
        """
        Paste img1 onto img2 with a specified center point (x, y), filter the result by mask1 and mask2, and calculate IoU.

        Args:
            img1 (np.ndarray): The first input image to be pasted.
            img2 (np.ndarray): The second input image.
            mask1 (np.ndarray): The mask corresponding to img1.
            mask2 (np.ndarray): The mask corresponding to img2.
            x (float): The x-coordinate of the center point for pasting.
            y (float): The y-coordinate of the center point for pasting.

        Returns:
            Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, float]:
                - The resulting merged image.
                - The processed img1.
                - The processed img2.
                - The processed mask1.
                - The processed mask2.
                - The Intersection over Union (IoU) value.
        """
        h1, w1 = img1.shape[:2]
        h2, w2 = img2.shape[:2]

        h_max, w_max = max(h1, h2), max(w1, w2)

        # Create large arrays for the final result and intermediate steps
        expand_img1 = np.zeros((h_max, w_max, 3))
        expand_img2 = np.zeros((h_max, w_max, 3))
        result_img = np.zeros((h_max, w_max, 3))
        expand_mask1 = np.zeros((h_max, w_max))
        expand_mask2 = np.zeros((h_max, w_max))

        # Merge masks to determine where to use img1 and where to use img2
        merge_mask = np.zeros((h_max, w_max))

        # Paste images and masks to the center of the larger arrays
        expand_img1 = paste_image_center(img1, expand_img1)
        expand_img2 = paste_image_center(img2, expand_img2)
        expand_mask1 = paste_image_center(mask1, expand_mask1)
        expand_mask2 = paste_image_center(mask2, expand_mask2)

        # Calculate IoU between the expanded masks
        iou = calculate_mask_iou(expand_mask1, expand_mask2)

        # Create a merge mask to determine which pixels to use from each image
        merge_mask = np.where(np.logical_and(expand_mask1 > 128, expand_mask2 > 128), 255, 0)

        # Combine images based on the merge mask
        result_img[merge_mask == 255] = expand_img1[merge_mask == 255]
        result_img[merge_mask == 0] = expand_img2[merge_mask == 0]

        return result_img, expand_img1, expand_img2, expand_mask1, expand_mask2, iou

        Paste img1 onto img2 with a specified center point (x, y), filter the result by mask1 and mask2, and calculate IoU.

        Args:
            img1 (np.ndarray): The first input image to be pasted.
            img2 (np.ndarray): The second input image.
            mask1 (np.ndarray): The mask corresponding to img1.
            mask2 (np.ndarray): The mask corresponding to img2.
            x (float): The x-coordinate of the center point for pasting.
            y (float): The y-coordinate of the center point for pasting.

        Returns:
            Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, np.ndarray, float]:
                - The resulting merged image.
                - The processed img1.
                - The processed img2.
                - The processed mask1.
                - The processed mask2.
                - The Intersection over Union (IoU) value.
        
scripts/easyphoto_utils/tryon_utils.py