Repository navigation
[MRG] EHN: median filters will accept floating image - #3616
Conversation
|
Perhaps the following deprecation pathway:
In addition, update the docstring See Also section with a reference to the rank filters, so that users know that this fast option is available for integer images. Add a docstring to either In general, we should consider adding paragraph descriptions to each of the submodule |
|
Ah, @glemaitre I did not read your PR description fully before commenting, so, yes, I guess we are in agreement. Except that I wanted us to move a little bit more quickly. |
|
For reference, our deprecation cycle documentation. |
I think that this is a pretty good idea to move faster for this case. |
|
Hello @glemaitre! Thanks for updating the PR.
|
|
@stefanv @emmanuelle @jni @sciunto This should be ready for a first review. |
sciunto
left a comment
There was a problem hiding this comment.
Excellent! I made only few minor comments, this looks great. Thank you for tackling that during the sprint.
| identical behavior as ``scipy.ndimage.median_filter``. This behavior can be | ||
| set already using ``behavior='ndimage'``. In 0.16, it will be the default | ||
| behavior and in 0.17, the parameter of the previous behavior (i.e., ``mask``, | ||
| ``shift_x``, ``shift_y``) will be removed. |
| ---------- | ||
| image : array-like | ||
| Input image. | ||
| selem : ndarray |
There was a problem hiding this comment.
| selem : ndarray | |
| selem : ndarray, optional |
There was a problem hiding this comment.
damn, it looks like github added a space before the variable. I didn't intend to do that. Just add the optional information....
| with the same number of dimension than ``image``. | ||
| If None, ``selem`` will be a N-D array with 3 elements for each | ||
| dimension (e.g., vector, square, cube, etc.) | ||
| out : ndarray, (same dtype as image) |
There was a problem hiding this comment.
| out : ndarray, (same dtype as image) | |
| out : ndarray, (same dtype as image), optional |
| dimension (e.g., vector, square, cube, etc.) | ||
| out : ndarray, (same dtype as image) | ||
| If None, a new array is allocated. | ||
| mask : ndarray |
There was a problem hiding this comment.
| mask : ndarray | |
| mask : ndarray, optional |
|
|
||
| .. deprecated:: 0.16 | ||
| ``mask`` is deprecated in 0.16 and will be removed 0.17. | ||
| shift_x, shift_y : int |
There was a problem hiding this comment.
| shift_x, shift_y : int | |
| shift_x, shift_y : int, optional |
Glad you used the deprecated flags :)
| See also | ||
| -------- | ||
| skimage.filters.rank.median : Rank-based implementation of the median | ||
| filtering offering more flexibility. |
There was a problem hiding this comment.
perhaps, say that it does not offer the possibility to pass floats. Otherwise, it sounds like rank must be the default :)
emmanuelle
left a comment
There was a problem hiding this comment.
Thanks for the PR! I like your solution. Would it be possible to add one test with a floating point array, and one test with a 3D image? Also, when the input is a floating point array and behavior='rank', a warning should be raised I think.
| ``mask`` is deprecated in 0.16 and will be removed 0.17. | ||
| shift_x, shift_y : int | ||
| Offset added to the structuring element center point. Shift is bounded | ||
| to the structuring element sizes (center must be inside the given |
| shift_x, shift_y : int | ||
| Offset added to the structuring element center point. Shift is bounded | ||
| to the structuring element sizes (center must be inside the given | ||
| structuring element). Only valid when ``behavior='ndimage'``. |
There was a problem hiding this comment.
when behavior='rank' (if I understand well??)
It will be already the case as the other rank functions. |
|
@glemaitre I was thinking of a warning advising to use the ndimage mode, but maybe the existing warning is enough. |
|
Looks good to me! |
* EHN: median filters will accept floating image
Description
Support floating image in
skimage.filters.median. This PR will controversial, but let's start with a potential solution.Things to considered:
skimage.filters.rank.medianscipy.ndimage.median_filterwould be a good candidate for this use caseHowever,
scipy.ndimage.median_filterdoes not accept parameter such asmaskorshift_*skimage.filters.rank.medianusingscipy.ndimage.median_filter: (i) skimage discard the pixel outside of the structural element when computing the median while scipy will pad the image beforehand and (ii) the tie breaking is done differently --- floor for skimage and ceiling for scipy.Therefore my proposal is the following: introduce a parameter
behaviorallowing to switch to the scipy implementation using all the available parameters. By default, we will fall back on the previous behavior for 2 releases. In 2 releases, the scipy function will be the default and in 4 releases, the parameters of the old behavior will be removed at the same time than thebehaviorparameter.I could not come with a cleaner design than those deprecation cycles.
Checklist
./doc/examples(new features only)./benchmarks, if your changes aren't covered by anexisting benchmark
References
closes #1419
closes #1422
closes #2943
For reviewers
later.
__init__.py.doc/release/release_dev.rst.@meeseeksdev backport to v0.14.x