Explanation of different edge modes in scipy.ndimage
![](https://secure.gravatar.com/avatar/15c05480eda96586c521cf0df92ec41c.jpg?s=120&d=mm&r=g)
Hello, I'm doing some gaussian filtering of periodic 2D arrays using scipy.ndimage.gaussian_filter. There is a 'mode' argument that is set to 'reflect' by default. In _ni_support.py:34 there is a conversion function, '_extend_mode_to_code' that gives the different modes available. For periodic data I believe I should use 'wrap', but I'm interested to know what the other modes mean, esp the difference between 'reflect' and 'mirror'. For the record, the modes defined are 'nearest', 'wrap', 'reflect', 'mirror', and 'constant'. For future reference, is there a place where these arguments are documented? Thanks, Kurt
![](https://secure.gravatar.com/avatar/af6c39d6943bd4b0e1fde23161e7bb8c.jpg?s=120&d=mm&r=g)
Hi Kurt 2008/10/31 Kurt Smith <kwmsmith@gmail.com>:
I'm doing some gaussian filtering of periodic 2D arrays using scipy.ndimage.gaussian_filter. There is a 'mode' argument that is set to 'reflect' by default. In _ni_support.py:34 there is a conversion function, '_extend_mode_to_code' that gives the different modes available. For periodic data I believe I should use 'wrap', but I'm interested to know what the other modes mean, esp the difference between 'reflect' and 'mirror'. For the record, the modes defined are 'nearest', 'wrap', 'reflect', 'mirror', and 'constant'. For future reference, is there a place where these arguments are documented?
Sorry for the long overdue reply. Reflect means: 1 | 2 | 3 | 2 | 1 While mirror means: 1 | 2 | 3 | 3| 2 | 1 (or the other way around, can't remember). The problem with the last approach is the interpolation between 3 and 3, which is currently broken, so I'd advise against using it. Thanks for your interest, Regards Stéfan
![](https://secure.gravatar.com/avatar/15c05480eda96586c521cf0df92ec41c.jpg?s=120&d=mm&r=g)
On Tue, Nov 4, 2008 at 3:30 AM, Stéfan van der Walt <stefan@sun.ac.za>wrote:
Hi Kurt
2008/10/31 Kurt Smith <kwmsmith@gmail.com>:
I'm doing some gaussian filtering of periodic 2D arrays using scipy.ndimage.gaussian_filter. There is a 'mode' argument that is set to 'reflect' by default. In _ni_support.py:34 there is a conversion function, '_extend_mode_to_code' that gives the different modes available. For periodic data I believe I should use 'wrap', but I'm interested to know what the other modes mean, esp the difference between 'reflect' and 'mirror'. For the record, the modes defined are 'nearest', 'wrap', 'reflect', 'mirror', and 'constant'. For future reference, is there a place where these arguments are documented?
Sorry for the long overdue reply.
Reflect means:
1 | 2 | 3 | 2 | 1
While mirror means:
1 | 2 | 3 | 3| 2 | 1
(or the other way around, can't remember).
The problem with the last approach is the interpolation between 3 and 3, which is currently broken, so I'd advise against using it.
Thanks Stefan.
participants (2)
-
Kurt Smith
-
Stéfan van der Walt