Re: Using ndimage.gaussian_filter for 3d array
"Juan Nunez-Iglesias" <[email protected]> Tue, 26 Oct 2021 05:10:33 -0500
| Newsgroups | gmane.comp.python.scientific.user |
|---|---|
| Message-ID | <[email protected]> |
A 3D gaussian filter is smoothing across all axes, so in abc[k, :, :] you are getting some of abc[k-1, :, :] and abc[k+1, :, :], and so on, according to the kernel weights in 3D. To smooth in 2D across all slices of a 3D array, specify a different sigma per axis, like so: abc = ndimage.gaussian_filter(abc * 1e2, sigma=(0, 2, 2), output=abc, order=0) Note that you don't need the [:, :, :]: using output=array is how to ensure that the array is modified in-place (if you are trying to avoid an extra allocation). Juan. On Tue, 26 Oct 2021, at 4:59 AM, ashwin .D wrote: > Hello, > I am wanting to use ndimage.gaussian_filter for a 3d array in order to smooth the data . > > When I do this - > > abc[:,:,:] = ndimage.gaussian_filter(abc[:,:,:]*1e2,sigma=2,order=0) I get unreal values. > > However the function call when done within a loop like this > > for k in range(0,N): > abc[k,:,:] = ndimage.gaussian_filter(abc[k,:,:]*1e2,sigma=2,order=0) gives reasonable smoothed values. > > From the docs - https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.gaussian_filter.html > > the input array does not seem to have any restriction on the dimensionality . So where am I going wrong ? > > Best regards, > Ashwin. > > _______________________________________________ > SciPy-User mailing list -- [email protected] > To unsubscribe send an email to [email protected] > https://mail.python.org/mailman3/lists/scipy-user.python.org/ > Member address: [email protected] > _______________________________________________ SciPy-User mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3/lists/scipy-user.python.org/ Member address: [email protected]