5
5
import glob
6
6
7
7
# Define the source image file
8
- source_image1 = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/Porosity_Chi_distribution.png'
9
- source_image2 = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/generated_kc_chi_permability_512x512.png'
8
+ # source_image1 = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/Porosity_Chi_distribution.png'
9
+ # source_image2 = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/generated_kc_chi_permability_512x512.png'
10
+
11
+
10
12
11
13
# Define the destination directory where the copied images will be saved
12
- subdir = 'poro_study_kc_abs_normal_permability/'
14
+
15
+ # batch1
16
+ # subdir = 'poro_study_tanh_kc_chi_permability/'
17
+ # source_image1_hist = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/tanh_kc_permability_from_Chi_porosity.png'
18
+ # source_image2_background = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/generated_tanh_kc_chi_permability_512x512.png'
19
+
20
+
21
+ #batch2
22
+ # subdir = 'poro_study_porosity_chi_distribution/'
23
+ # source_image1_hist = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/Porosity_Chi_distribution.png'
24
+ # source_image2_background = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/generated_porosity_chi_distribution_512x512.png'
25
+
26
+ #batch3
27
+ subdir = 'poro_study_porosity_normal_distribution/'
28
+ source_image1_hist = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/Porosity_normal_distribution.png'
29
+ source_image2_background = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/generated_porosity_normal_distribution_512x512.png'
30
+
31
+
32
+ # DESTINATION
13
33
destination_directory = '/home/grzegorz/GITHUB/LBM/TCLB/example/porous_media/script_output/' + subdir
14
34
15
35
# Define the starting index for naming the copied images
16
36
start_index = 1000
17
37
18
38
# Define the number of times you want to copy the image
19
-
20
- num_files_to_generate = len (os .listdir (destination_directory ))
21
-
39
+ # num_files_to_generate = len(os.listdir(destination_directory))
22
40
num_files_to_generate = 333
23
41
24
-
25
-
26
42
# Loop through and copy the image N times
27
43
for i in range (num_files_to_generate ):
28
- new_filename = f'Porosity_Chi_distribution_ { start_index + i + 1 } .png'
29
- shutil .copyfile (source_image1 , destination_directory + new_filename )
30
- print (f'Copied { source_image1 } to { destination_directory + new_filename } ' )
44
+ new_filename = f'imghist_ { start_index + i + 1 } .png'
45
+ shutil .copyfile (source_image1_hist , destination_directory + new_filename )
46
+ print (f'Copied { source_image1_hist } to { destination_directory + new_filename } ' )
31
47
32
48
for i in range (num_files_to_generate ):
33
- new_filename = f'generated_kc_chi_permability_512x512_ { start_index + i + 1 } .png'
34
- shutil .copyfile (source_image2 , destination_directory + new_filename )
35
- print (f'Copied { source_image2 } to { destination_directory + new_filename } ' )
49
+ new_filename = f'imgbackground_ { start_index + i + 1 } .png'
50
+ shutil .copyfile (source_image2_background , destination_directory + new_filename )
51
+ print (f'Copied { source_image2_background } to { destination_directory + new_filename } ' )
36
52
37
53
38
54
39
55
40
56
print (f'Images copied successfully to { destination_directory } ' )
41
57
42
- def join_images_side_by_side_cv (img1_path , img2_path , output_path ):
58
+ def join_images_side_by_side_cv (img1_path , img2_path , img3_path , output_path ):
43
59
image1 = cv2 .imread (img1_path )
44
60
image2 = cv2 .imread (img2_path )
45
-
61
+ image3 = cv2 . imread ( img3_path )
46
62
# Resize images to the same height
47
63
# height = min(image1.shape[0], image2.shape[0])
48
64
# image1 = cv2.resize(image1, (int(image1.shape[1] * height / image1.shape[0]), height))
49
65
# image2 = cv2.resize(image2, (int(image2.shape[1] * height / image2.shape[0]), height))
50
66
image2 = cv2 .resize (image2 , (512 , 512 ))
67
+ image3 = cv2 .resize (image3 , (512 , 512 ))
68
+
51
69
# Concatenate images horizontally
52
- new_image = np .hstack ((image1 , image2 ))
70
+ new_image = np .hstack ((image1 , image2 , image3 ))
53
71
54
72
# Save the new image
55
73
cv2 .imwrite (output_path , new_image )
56
-
57
-
58
- # image_pairs = [('path_to_image1_1.jpg', 'path_to_image1_2.jpg'), ('path_to_image2_1.jpg', 'path_to_image2_2.jpg')]
59
74
60
75
61
76
def list_and_sort_files (pattern ):
62
77
"""List files matching the pattern and sort them."""
63
78
files = glob .glob (pattern )
64
79
files .sort ()
65
80
return files
66
-
67
-
68
- # for index, (img1_path, img2_path) in enumerate(image_pairs):
69
- # join_images_side_by_side_cv(img1_path, img2_path, f'joined_image_{index+1}.jpg')
70
-
81
+
71
82
# List and sort the files
72
- a_files = list_and_sort_files (destination_directory + 'H_*.png' )
73
- b_files = list_and_sort_files (destination_directory + 'Porosity_Chi_distribution_*.png' )
83
+ H_files = list_and_sort_files (destination_directory + 'H_*.png' )
84
+ a_files = list_and_sort_files (destination_directory + 'imgbackground_*.png' )
85
+ b_files = list_and_sort_files (destination_directory + 'imghist_*.png' )
86
+
74
87
75
88
# Assuming both lists are the same length and correctly matched
76
89
counter = 1000
77
- for a_file , b_file in zip (a_files , b_files ):
78
- counter = counter + 1
79
- output_filename = destination_directory + f"joined_{ counter } .png" # Customize the output filename as needed
80
- join_images_side_by_side_cv (a_file , b_file , output_filename )
81
- print (f'joined { output_filename } ' )
82
-
83
- a_files = list_and_sort_files (destination_directory + 'joined_*.png' )
84
- b_files = list_and_sort_files (destination_directory + 'generated_kc_chi_permability_512x512_*.png' )
85
-
86
- for a_file , b_file in zip (a_files , b_files ):
90
+ for H_file , a_file , b_file in zip (H_files , a_files , b_files ):
87
91
counter = counter + 1
88
92
output_filename = destination_directory + f"joined3_{ counter } .png" # Customize the output filename as needed
89
- join_images_side_by_side_cv (a_file , b_file , output_filename )
93
+ join_images_side_by_side_cv (H_file , a_file , b_file , output_filename )
90
94
print (f'joined { output_filename } ' )
91
95
92
96
@@ -109,4 +113,4 @@ def list_and_sort_files(pattern):
109
113
]
110
114
111
115
# Execute the ffmpeg command, automatically confirming any prompts
112
- subprocess .run (ffmpeg_command , text = True , input = 'y\n ' )
116
+ subprocess .run (ffmpeg_command , text = True , input = 'y\n ' )
0 commit comments