Update app.py
Browse files
app.py
CHANGED
|
@@ -15,13 +15,14 @@ def add_noise(image, password):
|
|
| 15 |
"""Add Gaussian noise to the image based on the password."""
|
| 16 |
seed = hash_password(password) % (2**32)
|
| 17 |
np.random.seed(seed)
|
| 18 |
-
mean = np.random.uniform(-0.
|
| 19 |
-
var = np.random.uniform(0.
|
| 20 |
sigma = var ** 0.5
|
| 21 |
noisy_image = random_noise(np.array(image), mode='gaussian', mean=mean, var=var)
|
| 22 |
noisy_image = (255 * noisy_image).astype(np.uint8) # Scale back to 0-255
|
| 23 |
return Image.fromarray(noisy_image)
|
| 24 |
|
|
|
|
| 25 |
from skimage import img_as_float
|
| 26 |
|
| 27 |
def remove_noise(noisy_image, password):
|
|
|
|
| 15 |
"""Add Gaussian noise to the image based on the password."""
|
| 16 |
seed = hash_password(password) % (2**32)
|
| 17 |
np.random.seed(seed)
|
| 18 |
+
mean = np.random.uniform(-0.1, 0.1) # Wider range for mean
|
| 19 |
+
var = np.random.uniform(0.05, 0.1) # Higher variance for stronger noise
|
| 20 |
sigma = var ** 0.5
|
| 21 |
noisy_image = random_noise(np.array(image), mode='gaussian', mean=mean, var=var)
|
| 22 |
noisy_image = (255 * noisy_image).astype(np.uint8) # Scale back to 0-255
|
| 23 |
return Image.fromarray(noisy_image)
|
| 24 |
|
| 25 |
+
|
| 26 |
from skimage import img_as_float
|
| 27 |
|
| 28 |
def remove_noise(noisy_image, password):
|