Adding Gausian Noise to Video
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello! i am using a Video Compression Code made by "naveen V"
below is the code they used for the video compression
ImFolder=uigetdir;
pngFile = dir(strcat(ImFolder,'\*.png'));
S = [pngFile(:).datenum];
[~,S] = sort(S);
pngFiles = pngFile(S);
VideoFile=strcat(ImFolder,'\Video');
writeObj = VideoWriter(VideoFile);
fps= 15;
writeObj.FrameRate = fps;
open(writeObj);
for t= 1:length(pngFiles)
Frame=imread(strcat(ImFolder,'\',pngFiles(t).name));
writeVideo(writeObj,im2frame(Frame));
end
close(writerObj);
I would like to ask how to apply gaussian noise and reed solomon FEC into the code for the purpose of measuing BER of the system.
3 commentaires
Jonas
le 30 Juin 2022
interesting, i don't have problems doing this this (2022a). What is the class of frames? if it is e.g. uint16 you can also use
Frame=Frame+uint16(factor*randn(size(Frame)))
if it is uint8
Frame=Frame+uint8(factor*randn(size(Frame)))
Réponses (1)
Siraj
le 27 Sep 2023
Hi!
I understand that you're trying to make a video from PNG files, add Gaussian noise to the frames, and analyze the Bit Error Rate (BER). However, you're running into an error that says, "Error using +: Integers can only be combined with integers of the same class, or scalar doubles." This error hints at a data type mismatch between your image data and the noise you're adding. To resolve this, ensure that the data types match when you're adding the noise to the frames.
To overcome this issue, you can utilize the "imnoise" function, which allows you to introduce noise to an image. This function offers control over the type of noise you want to apply and lets you adjust the noise's intensity. For more detailed information about the "imnoise" function, you can refer to the following link.
I've included the code below for improved clarity.
% Prompt the user to select a folder containing PNG files
ImFolder = uigetdir;
% List all PNG files in the selected directory
pngFile = dir(fullfile(ImFolder, '*.png'));
% Sort the PNG files by modification date
S = [pngFile(:).datenum];
[~, S] = sort(S);
pngFiles = pngFile(S);
% Define the path for the output video
VideoFile = fullfile(ImFolder, "Video");
% Create a VideoWriter object for video creation
writeObj = VideoWriter(VideoFile);
% Set the frames per second (fps) for the video
fps = 15;
writeObj.FrameRate = fps;
% Open the VideoWriter object to start writing the video
open(writeObj);
% Loop through each PNG file in the sorted list
for t = 1:length(pngFiles)
% Read the PNG file
Frame = imread(fullfile(ImFolder, pngFiles(t).name));
% Add Gaussian noise to the frame
NoisyFrame = imnoise(Frame, "gaussian");
% Convert the noisy frame and write it to the video
writeVideo(writeObj, im2frame(NoisyFrame));
end
% Close the VideoWriter object to save the video
close(writeObj);
Hope this helps.
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!