English 中文(简体)
符合3个层面数据集的最小广场
原标题:least squares fitting to a 3 dimensional data set

I am working on video stabilisation ( making shaky videos non-shaky) using matlab. One of the steps is to find a smooth camera path given the unstable camera path. The unstable camera path is one which gives the jittering or shake to the video. I have camera path specified using camera position which is a 3d-data. camera path - (cx,cy,cz);

As i plot in matlab, i can visually see the shakiness of the camera motion. So now i require a least squares fitting to be done on the camera path specified by(cx,cy,cz);

I came across polyfit() which does fitting for 2-dimensional data. But what i need is a 3-d smooth curve fit to the shaky curve. Thanks in advance.

最佳回答

Approach using least square fit:

t = (1:0.1:5) ;

% model
px = [ 5 2 1 ];
x =  polyval(px,t);

py = [ -2 1 1 ];
y = polyval(py,t);

pz = [ 1 20 1 ];
z = polyval(pz,t);

%  plot model
figure
plot3(x,y,z)
hold all

% simulate measurement 
xMeasured = x+2*(rand(length(x),1)-0.5);
yMeasured = y+2*(rand(length(y),1)-0.5);
zMeasured = z+2*(rand(length(z),1)-0.5);

% plot simulated measurements
plot3(xMeasured, yMeasured, zMeasured, or )
hold off
grid on

% least squares fit 
A = [t.^2, t, t./t];
pxEstimated = AxMeasured;
pyEstimated = AyMeasured;
pzEstimated = AzMeasured;
问题回答

您是否适合三个单独的1d曲线,用于cx(t)、cy(t)、cz(t)?

BTW:我认为你需要的是卡尔曼过滤器,而不是适合照相机的聚合物。 但是,我不敢肯定,是否马塔布拉为此提供支持。

Let me be grateful to stackoverflow.com first of all and then my thanks to zellus and nikie who had started me thinking about the problem more. So now I have reached the solution which follows zellus approach and as nikie pointed out I used parameter t . cx, cy,cz are the coordinates in 3d space and in my case they are all 343x1 doubles My final code is shown below which fits the 3d data set:

t = linspace(1,343,343) ;

 load cx.mat;
 load cy.mat;
 load cz.mat;

 plot3(cx, cy, cz, r ),title( source Camera Path );
 hold all

 A = [t.^2, t, t./t];
 fx = Acx;
 fy = Acy;
 fz = Acz;


 Xev = polyval(fx,t);
 Yev = polyval(fy,t);
 Zev = polyval(fz,t);

 plot3(Xev,Yev,Zev, +b ),title( Fitting Line );

我期待着与非常有帮助的人们就斯塔克韦罗问题进行更有意义的讨论。





相关问题
Resources for Image Recognition

I am looking for a recommendation for an introduction to image processing algorithms (face and shape recognition, etc.) and wondered if anyone had an good recommendations, either for books, ...

Good reference book for digital image processing? [closed]

I am learning digital image processing on my own and would like recomendations on good reference books. If you know of books to definately stay away from that would be useful as well. Thanks

Python Tesseract can t recognize this font

I have this image: I want to read it to a string using python, which I didn t think would be that hard. I came upon tesseract, and then a wrapper for python scripts using tesseract. So I started ...

What s the quickest way to parallelize code?

I have an image processing routine that I believe could be made very parallel very quickly. Each pixel needs to have roughly 2k operations done on it in a way that doesn t depend on the operations ...

Computing object statistics from the second central moments

I m currently working on writing a version of the MATLAB RegionProps function for GNU Octave. I have most of it implemented, but I m still struggling with the implementation of a few parts. I had ...

Viola-Jones face detection claims 180k features

I ve been implementing an adaptation of Viola-Jones face detection algorithm. The technique relies upon placing a subframe of 24x24 pixels within an image, and subsequently placing rectangular ...

热门标签