Update Scripts/image_processing.py
Browse files- Scripts/image_processing.py +26 -27
Scripts/image_processing.py
CHANGED
|
@@ -1,27 +1,26 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
x = x
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
clipped_image
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
wrapped_image
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 1 |
+
import cv2
|
| 2 |
+
import numpy as np
|
| 3 |
+
|
| 4 |
+
def modulo(x, L):
|
| 5 |
+
positive = x > 0
|
| 6 |
+
x = x % L
|
| 7 |
+
x = np.where( ( x == 0) & positive, L, x)
|
| 8 |
+
return x
|
| 9 |
+
|
| 10 |
+
def apply_blur(image, kernel_size):
|
| 11 |
+
"""Aplica desenfoque gaussiano a la imagen."""
|
| 12 |
+
return cv2.GaussianBlur(image, (kernel_size, kernel_size), 0)
|
| 13 |
+
|
| 14 |
+
def clip_image(image, correction, sat_factor):
|
| 15 |
+
"""Clips image with saturation factor and correction."""
|
| 16 |
+
processed_image = np.power(image, correction) * sat_factor
|
| 17 |
+
clipped_image = np.clip(processed_image, 0, 1)
|
| 18 |
+
return clipped_image
|
| 19 |
+
|
| 20 |
+
def wrap_image(image, correction, sat_factor):
|
| 21 |
+
"""Wraps image with saturation factor and correction."""
|
| 22 |
+
processed_image = np.power(image, 1.0) * sat_factor
|
| 23 |
+
wrapped_image = modulo(processed_image, 1.0)
|
| 24 |
+
return wrapped_image
|
| 25 |
+
|
| 26 |
+
|
|
|