-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
83 lines (81 loc) · 2.7 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# import numpy as np
# import cv2
# import matplotlib.pyplot as plt
#
#
# def get_magnitude_and_phase(image):
# # Compute the Fourier transform of the image
# f_transform = np.fft.fft2(image)
#
# # Get the magnitude and phase of the Fourier transform
# magnitude = np.abs(f_transform)
# phase = np.angle(f_transform)
#
# return magnitude, phase
#
#
# def combine_images(images, selected_magnitudes, selected_phases, weights):
# combined_magnitude = np.zeros_like(images[0], dtype=np.float64)
# combined_phase = np.zeros_like(images[0], dtype=np.float64)
#
# # Normalize weights so that they sum to 1
# weights = np.array(weights)
#
# for i in range(len(images)):
# magnitude, phase = get_magnitude_and_phase(images[i])
#
# if selected_magnitudes[i]:
# combined_magnitude += weights[i] * magnitude
# else:
# combined_magnitude += weights[i] * np.ones_like(magnitude)
#
# if selected_phases[i]:
# combined_phase += weights[i] * phase
# else:
# combined_phase += weights[i] * np.zeros_like(phase)
#
# # Combine magnitude and phase
# combined_f_transform = combined_magnitude * np.exp(1j * combined_phase)
#
# # Inverse Fourier Transform
# combined_image = np.fft.ifft2(combined_f_transform).real
#
# # Convert the result back to uint8
# combined_image = np.clip(combined_image, 0, 255).astype(np.uint8)
#
# return combined_image
#
#
# # Load your four images
# image1 = cv2.imread('images.jpeg', cv2.IMREAD_GRAYSCALE)
# image2 = cv2.imread('images (1).jpeg', cv2.IMREAD_GRAYSCALE)
# image3 = cv2.imread('download.jpeg', cv2.IMREAD_GRAYSCALE)
# image4 = cv2.imread('download (1).jpeg', cv2.IMREAD_GRAYSCALE)
#
# target_size = (125, 125)
# image1 = cv2.resize(image1, target_size)
# image2 = cv2.resize(image2, target_size)
# image3 = cv2.resize(image3, target_size)
# image4 = cv2.resize(image4, target_size)
#
# # Choose the weights for each image
# weights = [1, 1.0, 1.0, 1.0]
#
# # Choose whether to use magnitude or phase for each image
# selected_magnitudes = [True, False, False, False]
# selected_phases = [False, True, False, False]
#
# # Combine images
# combined_image = combine_images([image1, image2, image3, image4], selected_magnitudes, selected_phases, weights)
#
# # Display the result
# plt.imshow(combined_image, cmap='gray')
# plt.title('Combined Image')
# plt.show()
import logging
logging.basicConfig(filename="my_app.log",
filemode="a",
format="(%(asctime)s) | %(name)s | %(levelname)s : '%(message)s' ",
datefmt="%d %B %Y, %H:%M")
my_logger = logging.getLogger("image_mixer.py")
my_logger.warning("This is warning message")