Matlab code to find the Wave height
I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height.I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height. I want to find the water wave height and wave length by analysing the video. I write the code for that :
Is this correct?
videoFile = ‘wave_video.mp4’; % Replace with your video file name
video = VideoReader(videoFile);
numFrames = floor(video.Duration * video.FrameRate);
frameRate = video.FrameRate;
displacement = zeros(1, numFrames);
% Define a threshold value for detecting the wave (adjust this as needed)
threshold = 100;
for k = 1:numFrames
frame = readFrame(video);
grayFrame = rgb2gray(frame);
% Threshold the grayscale image to create a binary mask
binaryImage = grayFrame > threshold;
% Sum the binary image to get an estimation of the wave’s displacement
displacement(k) = sum(binaryImage(:));
end
time = (0:numFrames-1) / frameRate;
plot(time, displacement);
xlabel(‘Time (s)’);
ylabel(‘Displacement’);
title(‘Water Wave Displacement Over Time’);
How to find the unit of that height. matlab, water wave, wave height MATLAB Answers — New Questions