diff options
Diffstat (limited to 'opencv/code/a7.py')
-rw-r--r-- | opencv/code/a7.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/opencv/code/a7.py b/opencv/code/a7.py new file mode 100644 index 0000000..d9fbb0c --- /dev/null +++ b/opencv/code/a7.py @@ -0,0 +1,26 @@ +import cv2 +import numpy as np + +image = cv2.imread("4i.jpg", cv2.IMREAD_GRAYSCALE) + +# a) Brightness enhancement +brightness_enhanced = cv2.add(image, 50) +cv2.imwrite("7.a.jpg", brightness_enhanced) + +# b) Brightness suppression +brightness_suppressed = cv2.subtract(image, 50) +cv2.imwrite("7.b.jpg", brightness_suppressed) + +# c) Contrast manipulation +alpha = 1.5 +contrast_adjusted = cv2.multiply(image, alpha) +cv2.imwrite("7.c.jpg", contrast_adjusted) + +# d) Gray level slicing without background +lower_threshold = 100 +upper_threshold = 200 +gray_level_sliced = np.copy(image) +gray_level_sliced[ + (gray_level_sliced >= lower_threshold) & (gray_level_sliced <= upper_threshold) +] = 255 +cv2.imwrite("7.d.jpg", gray_level_sliced) |