forked from mrychlik/faces
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_noise.m
29 lines (24 loc) · 942 Bytes
/
add_noise.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%----------------------------------------------------------------
% File: add_noise.m
%----------------------------------------------------------------
%
% Author: Marek Rychlik (rychlik@arizona.edu)
% Date: Sat Dec 14 12:34:12 2024
% Copying: (C) Marek Rychlik, 2020. All rights reserved.
%
%----------------------------------------------------------------
% Example: Adding white noise to a grayscale or color image
% Load or create a grayscale image with values in the range [0, 1]
image = imread('peppers.png'); % Replace this with your actual image
% Specify the noise level (variance of the noise)
noiseLevel = 0.01; % Adjust this to control the noise intensity
% Add white Gaussian noise
noisyImage = imnoise(image, 'gaussian', 0, noiseLevel);
% Display the original and noisy images
figure;
subplot(1, 2, 1);
imshow(image, []);
title('Original Image');
subplot(1, 2, 2);
imshow(noisyImage, []);
title('Noisy Image');