How to arrange vector array

2 visualizaciones (últimos 30 días)
Nur
Nur el 15 de En. de 2014
Comentada: Nur el 15 de En. de 2014
Hi,
I have a problem with this coding.
imgreference=imread('C:\Users\Acer\Documents\MATLAB\Flow\Flow1.jpg');
% Read frames
text='C:\Users\Acer\Documents\MATLAB\Flow\Flow';
fr = [];
tt = [];
mm = [];
for im=18:20;
filname=strcat(text,int2str(im));
filname=strcat(filname,'.jpg');
img=imread(filname);
[fx,fy,ft,vAvg,uAvg,u,v]=HS(img,imgreference);
U= u.^2;
V=v.^2;
velocity =sqrt(U+V);
fr = [velocity; fr];
b = reshape(fr,360,480,[]);
OpticalFlow = [u;v];
tt = [OpticalFlow; tt];
O = reshape(tt,360,480,[]);
SpatiotemporalAverageOF = [uAvg;vAvg];
mm = [SpatiotemporalAverageOF; mm];
Oave = reshape(mm,360,480,[]);
end
Question;
How to arrange OpticalFlow= [u;v] so that it forms 360x480x3 instead of 360x480x6.
for b = reshape(fr,360,480,[]) i got 360x480x3.
I want both of these values are same to do further mathematical operations.
Thanks friend!

Respuestas (1)

Walter Roberson
Walter Roberson el 15 de En. de 2014
You cannot. If it is coming out as 360 x 480 x 6 then it has twice as much data as would be used for 360 x 480 x 3.
MATLAB does not have HS() in any toolbox, so I cannot analyze to see why u and v are coming out 360 x 240 x 6.
If you are using HS from http://www.mathworks.com/matlabcentral/fileexchange/22756-horn-schunck-optical-flow-method then that routine only returns two values, u and v, not the 7 that you show being returned.
  1 comentario
Nur
Nur el 15 de En. de 2014
Thanks for your answer. Yes, I used HS from that link and it returns value u and v. I want to use this value for next processing(Social Force Model). That why I called the u and v value from Horn-Schunck optical flow.From my review, optical flow equal to Optical Flow(u,v)..so I want to use both u and v value but don't know how to arrange them opticalflow=[u v],opticalflow=[u;v],opticalflow=[u,v] or etc so that the size of that vector 360x480x3. I got 360x480x6 because i do put opticalflow=[u;v].

Iniciar sesión para comentar.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by