griddata (averaging instead of interpolation)

I have many raw data points of a pipe surface that i scanned with a 3D scanner. the amount of points is about 4 times as much as my intended grid points. I would like to average the data (about a small cell) at a every specific grid point (to lessen the scanner noise), instead of using matlab 'linear' 'cubic' or 'nearest neighbor'.
How can i do so, is there better function than griddata that i can use?
thank you

 採用された回答

Bruno Luong
Bruno Luong 2011 年 2 月 18 日

0 投票

As I understood you have 2D data r depending of theta and z (and not 3D).
theta = rand(100000,1)*2*pi;
z = rand(100000,1)*4-2;
r = 1+theta.*exp(-theta.^2-z.^2);
r = r+0.05*randn(size(r));
thetai=linspace(0,2*pi,33);
zi = linspace(-2,2,33);
% FEX: http://www.mathworks.com/matlabcentral/fileexchange/23897-n-dimensional-histogram
tz = [theta(:) z(:)];
[~, ~, ~, loc] = histcn(tz, thetai, zi);
r_avg = accumarray(loc, r(:), [length(thetai) length(zi)]) ./ ...
accumarray(loc, 1, [length(thetai) length(zi)]);
figure(1);
subplot(1,2,1);
plot3(z,theta,r,'.');
subplot(1,2,2);
surf(zi,thetai,r_avg)
Bruno

3 件のコメント

Thuan Le
Thuan Le 2011 年 2 月 18 日
[~,~,~,loc] = histcn(tz, thetai, zi);
im getting error Expression or statement is incorrect--possibly unbalanced (, {, or [.
i downloaded the histcn function.
Bruno Luong
Bruno Luong 2011 年 2 月 18 日
The reason is your matlab is old and does not support ~ operator, replace with:
[trash,trash,trash,loc] = histcn(tz, thetai, zi);
Thuan Le
Thuan Le 2011 年 2 月 18 日
your are correct, my matlab is too old. I'm also looking into TriScatteredInterp, using the natural neighbor interpolation. Anyway thank you for your help.

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

その他の回答 (3 件)

John D'Errico
John D'Errico 2011 年 2 月 16 日

0 投票

No, this will not explicitly average your data points in each bin. It does better than that.

1 件のコメント

Thuan Le
Thuan Le 2011 年 2 月 17 日
gridfit is not quite what i was looking for. it was too bias toward smoothness for my application. Im trying to capture the scallops and wear on the pipe surface. averaging the data about a small cell should be best.
Any other suggestions?

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

Thuan Le
Thuan Le 2011 年 2 月 16 日

0 投票

thank you for your quick reply.
i will take a look at the files and get back soon
Thuan Le
Thuan Le 2011 年 2 月 17 日

0 投票

gridfit is not quite what i was looking for. it was too bias toward smoothness for my application. Im trying to capture the scallops and wear on the pipe surface. averaging the data about a small cell should be best.
Any other suggestions?

4 件のコメント

Bruno Luong
Bruno Luong 2011 年 2 月 17 日
Please explain the "small cell". Is it a cell from prescribed 3D grid or something else?
Thuan Le
Thuan Le 2011 年 2 月 18 日
i have the raw data of (theta, z and r) which map out a surface of a pipe (alot of data point). im specifying a grid of theta and z, so that i can interpolate the radius. so let say for theta = 5 (+-0.5) , z = 6 (+-0.5 to form a 'cell'), interpolate radius by averaging any r values in that theta = 5+-0.5, z = 6+-0.5 range.
John D'Errico
John D'Errico 2011 年 2 月 18 日
You CAN control the amount of smoothing using gridfit. All you have shown is that you did not read the help.
Thuan Le
Thuan Le 2011 年 2 月 18 日
and where is this `help`files that you talked about in your `multiple`posts? all i can see is understanding gridfit.doc and gridfit.pdf

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

カテゴリ

ヘルプ センター および File ExchangeInterpolation of 2-D Selections in 3-D Grids についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by