Image and video process
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (0)
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!