How to arrange vector array

조회 수: 5 (최근 30일)
Nur
Nur 2014년 1월 15일
댓글: Nur 2014년 1월 15일
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!

답변 (1개)

Walter Roberson
Walter Roberson 2014년 1월 15일
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
Nur
Nur 2014년 1월 15일
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].

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by