What velue to use for "smooth3(A, 'gaussian', v)?

When using "smooth3(A, 'gaussian', v), unlike the 'box' method, the value v doesn't seem to take affect. Without v, or 5, or 99 it has the same effect. The 'doc smooth3' doesn't provide real information.
Thanks.

 Accepted Answer

Good question @John.
The syntax smooth3(A,'gaussian',V) passes the data A through a gaussian lowpass filter with a default standard deviation of 0.65 (you could specify that in an optional 4th argument). V defines the 3D window size for the filter.
Without seeing your data or the results, I can't explain why various V values produce the same results. If you attach a mat file that contains A and V I could dig deeper.

4 Comments

A different John, of course.
A = randn(20,20,20);
B1 = smooth3(A,'gaussian',3);
B2 = smooth3(A,'gaussian',5);
B3 = smooth3(A,'gaussian',7);
norm(B1 - B2,'fro')
ans = 1.0055
norm(B1 - B3,'fro')
ans = 1.0074
The various smoothed results are certainly not identical. That the different calls are similar in norm of the difference is something I attribute to the fact that my data is itself pure noise. I guess I could have had some real signal in there, but that would take more thought than I think it worth. There IS a difference, which is all I need to show.
John
John on 12 Oct 2022
Edited: John on 12 Oct 2022
Hi, Adam:
That's almost not noticeable by eye on images with 0.2% of difference.
With:
A = randn(20,20,20);
B1 = smooth3(A,'gaussian',3);
B2 = smooth3(A,'gaussian',9);
B3 = smooth3(A,'gaussian',15);
norm(B1 - B2,'fro')
ans = 1.0156
norm(B1 - B3,'fro')
ans = 1.0156
No difference. That's why I didn't see the difference. Maybe I will try ith wider SD at 2nd value place.
The DOC file should say more about the 'gaussian' option.
@John - please learn to use comments, not answers.
Anyway, consider that a Gaussian smoothing kernel of size 15 is HUGE, in comparison to a an array of size only 20x20x20. Do you see that I did get differences in my example, for SMALL gaussian kernels?
Anyway, the size of the tiny difference in Frobenious norm you indicate is also not relevant. That is again no surprise. Taking the frobenenius norm just averages out any remnants of noise.
A = randn(100,100,100);
B1 = smooth3(A,'gaussian',3);
B2 = smooth3(A,'gaussian',9);
B3 = smooth3(A,'gaussian',15);
format long g
norm(B1 - B2,'fro')
ans =
11.5343687718617
norm(B1 - B3,'fro')
ans =
11.5343687719941
Again, there ARE Differences to be seen, but the law of large numbers averages those differences out.
LOOK AT THE ARRAYS THEMSELVES TO SEE THAT!
B1(1:3,1:3,1:3)
ans =
ans(:,:,1) = -0.234102312749705 0.382072219543637 0.339308902178634 0.287843370691201 -0.111414000006913 -0.0625339480640082 0.129363424476748 -0.390423770739839 0.00426595845787685 ans(:,:,2) = 0.094990454554044 0.44155534092969 0.575420147677844 -0.266089109123344 -0.0330899672385768 0.000463778487347755 -0.632685810434764 -0.612382934354194 -0.312260654482024 ans(:,:,3) = -0.435468586043421 -0.211167306940052 -0.064833858178933 -0.185984173044869 0.345543259401304 0.168109924813588 0.256538827469533 0.295591962534587 0.0558459484555244
B2(1:3,1:3,1:3)
ans =
ans(:,:,1) = -0.24001109353323 0.373849267934935 0.322000538123073 0.281420048281016 -0.0982743532723887 -0.0524519085140193 0.129767507354035 -0.37558919785582 0.00684001729650901 ans(:,:,2) = 0.0901436665433138 0.428674231870868 0.562958332174248 -0.259188944716559 -0.0291847019562449 0.011934896561421 -0.614651337056743 -0.594305007405726 -0.300844876871851 ans(:,:,3) = -0.430076302309084 -0.208657293818347 -0.0675240672893176 -0.182313648494426 0.330234304800294 0.163644475651634 0.238106150134462 0.278741479390564 0.0512551907513211
Different numbers.
Thanks for that detailed explanation and demo @John D'Errico!

Sign in to comment.

More Answers (0)

Categories

Find more on Interpolation of 2-D Selections in 3-D Grids in Help Center and File Exchange

Products

Release

R2021b

Asked:

on 11 Oct 2022

Commented:

on 17 Oct 2022

Community Treasure Hunt

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

Start Hunting!