Image and video process

4 ビュー (過去 30 日間)
Ali alshamrani
Ali alshamrani 2020 年 8 月 28 日
コメント済み: Ali alshamrani 2020 年 9 月 9 日
Hi all,
I am trying to find the speed of one liquid moving above another liquid (oil and water). However, I came with this code shown down by picking up a single row of 1600*2560 and then find the gradient, then find the max gradient ( doing that is to track the edge of oil slick though the video.
By doing that, I plot time VS positions but this plot has a lot of up and down peaks with big variations, what I am trying is to make my code fix these huge differencing without effecting the original trend and be able to extract the plot number to find the speed using a central or forward differencing equation. I did use "smooth data" command but it has a negative effect on the trend of the plot (the plot is attached for your reference).
However, maybe I use a complicated method if there is an alternative method for finding the speed of moving oil on the water surface please share it with me.
X-axis : time
Y-axis: position of the max gradient in different frame
Blue line (smooth data command)
orange line is the original
path2Video = 'C:\files\Herder\June 14/concave.avi';
video = VideoReader(path2Video);
frames = read(video,[1970 3500]);
[w,h,c,totalFrames] = size(frames);
for i=1:totalFrames %cycle through number of frames
A = frames(:,:,1,i);%A=load( ) %load image from first time
B=(A(963,155:2060)); %extract single row of pixel values; remember that row values count from the top of the image
FX=gradient(double(B));
[M,xlocation] = max(FX);
xlocations(i)=xlocation;
end
%time=[30:1]; %however many frames you have0
%x = [0:totalFrames*0.0333];
x = [1:totalFrames];
x = x * 0.033333;
xlocations1 = smoothdata(xlocations)%,'movmean','SmoothingFactor',0.6);
plot(x,xlocations1,x,xlocations) %gives plot of location over time
  5 件のコメント
Image Analyst
Image Analyst 2020 年 9 月 9 日
If it's small enough, attach it here with the paper clip icon.
Ali alshamrani
Ali alshamrani 2020 年 9 月 9 日
I hope now you can see it. I did cutting as well as compressing to the oeiginal video.
Please let me know if you have problem openning the file.

サインインしてコメントする。

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by