Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pastebin-ul de mai sus e versiunea cea buna (folosind codu profului)
- import matplotlib.pyplot as plt
- import glob
- import os
- import cv2
- from PIL import Image, ImageOps
- import numpy as np
- import random
- def nothing(x):
- pass
- def sp_noise(image,white_noise):
- if white_noise <= 0.1:
- output = np.zeros(image.shape,np.uint8)
- thres = 1 - white_noise
- for i in range(image.shape[0]):
- for j in range(image.shape[1]):
- rdn = random.random()
- if rdn > thres:
- output[i][j] = 255
- else:
- output[i][j] = image[i][j]
- return output
- image = cv2.imread('C:/Users/Frentzy/Pictures/Mercy.jpg')
- numeFereastra = 'Exemplu cu trackbar - ESC pentru inchidere'
- cv2.namedWindow(numeFereastra, cv2.WINDOW_NORMAL)
- cv2.createTrackbar('thresh', numeFereastra, 0, 100, nothing)
- while(1):
- thresh = cv2.getTrackbarPos('thresh', numeFereastra)
- noise_img = sp_noise(image,thresh/1000)
- cv2.imshow(numeFereastra, noise_img)
- if cv2.waitKey(1) == 27: #incheiem cu ESC
- break
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement