Freak-ppa commited on
Commit
eaca618
1 Parent(s): 367e3f4

Upload 4 files

Browse files
.gitattributes CHANGED
@@ -37,3 +37,4 @@ ComfyUI/output/ComfyUI_00001_.png filter=lfs diff=lfs merge=lfs -text
37
  ComfyUI/output/ComfyUI_00002_.png filter=lfs diff=lfs merge=lfs -text
38
  ComfyUI/temp/ComfyUI_temp_zprxs_00001_.png filter=lfs diff=lfs merge=lfs -text
39
  ComfyUI/temp/ComfyUI_temp_zprxs_00002_.png filter=lfs diff=lfs merge=lfs -text
 
 
37
  ComfyUI/output/ComfyUI_00002_.png filter=lfs diff=lfs merge=lfs -text
38
  ComfyUI/temp/ComfyUI_temp_zprxs_00001_.png filter=lfs diff=lfs merge=lfs -text
39
  ComfyUI/temp/ComfyUI_temp_zprxs_00002_.png filter=lfs diff=lfs merge=lfs -text
40
+ ComfyUI/custom_nodes/merge_cross_images/result3.png filter=lfs diff=lfs merge=lfs -text
ComfyUI/custom_nodes/merge_cross_images/__init__.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cv2
2
+ import numpy as np
3
+ import os
4
+ import torch
5
+ from PIL import Image
6
+
7
+ class MergeImagesToTemplate:
8
+ @classmethod
9
+ def INPUT_TYPES(s):
10
+ return {
11
+ "required": {
12
+ "image1": ("IMAGE",),
13
+ "image2": ("IMAGE",),
14
+ "image3": ("IMAGE",),
15
+ "image4": ("IMAGE",)
16
+ }
17
+ }
18
+
19
+ RETURN_TYPES = ("IMAGE",)
20
+ FUNCTION = "merge_images"
21
+ CATEGORY = "image"
22
+ OUTPUT_NODE = True
23
+
24
+ def merge_images(self, image1, image2, image3, image4):
25
+ current_directory = os.path.dirname(os.path.abspath(__file__))
26
+ template = cv2.imread(current_directory+"/template_cross2.png", cv2.IMREAD_UNCHANGED)
27
+ scale_top = 0.85
28
+ scale_bottom = 1.434
29
+ top_1 = (271,9)
30
+ top_2 = (831,9)
31
+ bottom_1 = (15,474)
32
+ bottom_2 = (786,474)
33
+
34
+ def prepare_image(img):
35
+ img = np.clip(255.0 * img.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)
36
+ return cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
37
+
38
+ image1 = prepare_image(image1)
39
+ image2 = prepare_image(image2)
40
+ image3 = prepare_image(image3)
41
+ image4 = prepare_image(image4)
42
+
43
+ img1_resized = cv2.resize(image1, (int(512 * scale_top), int(512 * scale_top)))
44
+ img2_resized = cv2.resize(image2, (int(512 * scale_top), int(512 * scale_top)))
45
+ img3_resized = cv2.resize(image3, (int(512 * scale_bottom), int(512 * scale_bottom)))
46
+ img4_resized = cv2.resize(image4, (int(512 * scale_bottom), int(512 * scale_bottom)))
47
+
48
+ background = np.zeros((template.shape[0], template.shape[1], 3), dtype=np.uint8)
49
+ background[:] = (255, 255, 255)
50
+
51
+ background[top_1[1]:top_1[1]+img1_resized.shape[0], top_1[0]:top_1[0]+img1_resized.shape[1]] = img1_resized
52
+ background[top_2[1]:top_2[1]+img2_resized.shape[0], top_2[0]:top_2[0]+img2_resized.shape[1]] = img2_resized
53
+ background[bottom_1[1]:bottom_1[1]+img3_resized.shape[0], bottom_1[0]:bottom_1[0]+img3_resized.shape[1]] = img3_resized
54
+ background[bottom_2[1]:bottom_2[1]+img4_resized.shape[0], bottom_2[0]:bottom_2[0]+img4_resized.shape[1]] = img4_resized
55
+
56
+ alpha_channel = template[:, :, 3] / 255.0
57
+ for c in range(0, 3):
58
+ background[:, :, c] = background[:, :, c] * (1 - alpha_channel) + template[:, :, c] * alpha_channel
59
+
60
+ cv2.imwrite(current_directory+'/result3.png', background)
61
+ background_rgba = cv2.cvtColor(background, cv2.COLOR_BGR2RGBA)
62
+
63
+ result = torch.from_numpy(background_rgba.astype(np.float32) / 255.0).unsqueeze(0)
64
+ return (result,)
65
+
66
+
67
+ NODE_CLASS_MAPPINGS = {"MergeImagesToTemplate": MergeImagesToTemplate}
ComfyUI/custom_nodes/merge_cross_images/result3.png ADDED

Git LFS Details

  • SHA256: 31b43997242f343cd603cd9f11ddc3227ecfb7c6c73e87edfaf37c5cd4a1c7ed
  • Pointer size: 132 Bytes
  • Size of remote file: 2.26 MB
ComfyUI/custom_nodes/merge_cross_images/template_cross.png ADDED
ComfyUI/custom_nodes/merge_cross_images/template_cross2.png ADDED