diff options
author | Sudipto Mallick <smlckz@termux-alpine> | 2024-02-10 12:49:55 +0000 |
---|---|---|
committer | Sudipto Mallick <smlckz@termux-alpine> | 2024-02-10 12:49:55 +0000 |
commit | 4182a108a01df3aa28009716472f0ef291704866 (patch) | |
tree | 8fabeb2d6ddff80b930c02b3d535b5447bbd41dc /opencv/code/a11.py | |
parent | 02884d29e4f5aea71364a203dcaecd53600d8aa4 (diff) | |
download | zadania-main.tar.gz |
Complete DIP assignments main
Diffstat (limited to 'opencv/code/a11.py')
-rw-r--r-- | opencv/code/a11.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/opencv/code/a11.py b/opencv/code/a11.py new file mode 100644 index 0000000..dc4c436 --- /dev/null +++ b/opencv/code/a11.py @@ -0,0 +1,29 @@ +import cv2 +import numpy as np +import matplotlib.pyplot as plt +from skimage.util import random_noise + +image = cv2.imread("4igr.jpg", cv2.IMREAD_GRAYSCALE) + +# Add salt and pepper noise +salt_pepper_noise = random_noise(image, mode="s&p", amount=0.02) + +# Add Gaussian noise +gaussian_noise = random_noise(image, mode="gaussian", mean=0, var=0.01) + +# Create subplots +plt.figure(figsize=(10, 5)) + +# Salt and pepper noise +plt.subplot(1, 2, 1) +plt.imshow(salt_pepper_noise, cmap="gray") +plt.title("Salt and Pepper Noise") +plt.axis("off") + +# Gaussian noise +plt.subplot(1, 2, 2) +plt.imshow(gaussian_noise, cmap="gray") +plt.title("Gaussian Noise") +plt.axis("off") + +plt.savefig("11.svg") |