Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guided filter #1104

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Guided filter #1104

wants to merge 6 commits into from

Conversation

SamHames
Copy link

This implements the guided filtering routine for edge preserving smoothing. The website is here: http://research.microsoft.com/en-us/um/people/kahe/eccv10/ . This is not based on the code provided there.

This is just the basic functionality with an example and (some) tests. I'd appreciate some comments and thoughts before I move any further with this.

Todo

  1. Implement a transform.integral based averaging filter so runtime is approximately independent of window size.
  2. Implement the option to use the covariances between colour channels as described in the ECCV paper.
  3. Profile memory usage and give a better guide to the user.
  4. Create some benchmarks and give a comparison with other options in skimage, such as the bilateral filter.

Some examples from the example script:
noisy_square_self_guide
denoised_immunihistochemistry

@RONNCC
Copy link
Contributor

RONNCC commented Aug 17, 2014

just making sure.. it's not patented/pending right?

On Sun, Aug 17, 2014 at 6:02 PM, SamHames notifications@github.com wrote:

This implements the guided filtering routine for edge preserving
smoothing. The website is here:
http://research.microsoft.com/en-us/um/people/kahe/eccv10/ . This is not
based on the code provided there.

This is just the basic functionality with an example and (some) tests. I'd
appreciate some comments and thoughts before I move any further with this.

Todo

  1. Implement a transform.integral based averaging filter so runtime is
    approximately independent of window size.
  2. Implement the option to use the covariances between colour channels as
    described in the ECCV paper.
  3. Profile memory usage and give a better guide to the user.
  4. Create some benchmarks and give a comparison with other options in
    skimage, such as the bilateral filter.

Some examples from the example script:
[image: noisy_square_self_guide]
https://cloud.githubusercontent.com/assets/8400977/3945968/927b1906-2658-11e4-989c-04f22befb22f.png
[image: denoised_immunihistochemistry]

https://cloud.githubusercontent.com/assets/8400977/3945970/99b6916e-2658-11e4-8f44-7baa616f3a0b.png

You can merge this Pull Request by running

git pull https://github.com/SamHames/scikit-image guided_filter

Or view, comment on, or merge it at:

#1104
Commit Summary

  • Implement guided filter
  • Implement guided filter
  • Merge branch 'guided_filter' of github.com:SamHames/scikit-image
    into guided_filter
  • Update examples and doc strings

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#1104.

@SamHames
Copy link
Author

Actually it might be. I'm having trouble wading through the patents - does anybody have any guidance on how to better do that?

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) when pulling b35adfb on SamHames:guided_filter into 9ea0d27 on scikit-image:master.

@stefanv
Copy link
Member

stefanv commented Dec 1, 2014

Normally, the authors will clearly tell you if their work is patented. In this case, that doesn't seem to be the case. It is also included in the latest MATLAB: http://www.mathworks.com/help/images/ref/imguidedfilter.html

@stefanv
Copy link
Member

stefanv commented Dec 1, 2014

@SamHames I browsed the paper and read your PR. First off, thank you very much for taking the time to contribute such a neat PR. Now, from the paper I understand that one of the benefits of this method is that it is fast, linear time--but this implementation is not, thereby losing that advantage. How difficult, do you think, would it be to change this to linear time?

@SamHames
Copy link
Author

@stefanv Thanks for taking the time to have a look.

The only thing needed to make it constant run time is a box filter based on integral images/summed area tables. This is relatively straightforward, and can build on transform.integral_image . It would be best to have this implemented as a filter in it's own right as filters.fast_uniform (or something to that effect).

@stefanv
Copy link
Member

stefanv commented Dec 10, 2014

@SamHames If you're up for it, let's do it!

@soupault soupault self-assigned this Jul 20, 2016
@soupault soupault changed the title WIP: Guided filter Guided filter Oct 25, 2016
@sciunto
Copy link
Member

sciunto commented Dec 26, 2016

@SamHames I know that the last discussion happened two years ago. What's the status of this PR for you?

@aizvorski
Copy link
Contributor

I would like to see this merged. Having fast box filters as the base for this is nice to have but should not be a show-stopper.

@soupault
Copy link
Member

soupault commented Apr 20, 2017

Let's do this.
@SamHames kind ping. Could you enable an access to the branch for the project maintainers (checkbox on the right of this page)?

@SamHames
Copy link
Author

@soupault Done

Obviously life has intervened in the preceding couple of years :) Thanks for checking in.

I'll review where this is at sometime early next week - going from memory I don't think there's any significant work remaining, just details.

Implement the guided filter for fast, adaptive smoothing of
images using local pixel statistics. Guided filtering is fast
without approximations and computes the filtered image in one
pass.
Implements the guided filter for fast, adaptive smoothing of
images.
More informative examples for guided filtering now included.
@pep8speaks
Copy link

pep8speaks commented Apr 21, 2017

Hello @SamHames! Thanks for updating the PR.

Line 32:80: E501 line too long (91 > 79 characters)
Line 48:1: E124 closing bracket does not match visual indentation

Comment last updated on April 23, 2017 at 13:50 Hours UTC

References
==========

.. [1] http://research.microsoft.com/en-us/um/people/kahe/eccv10/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link looks broken... like redirected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm correct, the correct paper is: DOI:10.1007/978-3-642-15549-9_1

@@ -11,7 +11,7 @@
http://www.opticsinfobase.org/josaa/abstract.cfm?URI=josaa-27-7-1593

.. [2] Richardson, William Hadley, "Bayesian-Based Iterative Method of
Image Restoration". JOSA 62 (1): 5559. doi:10.1364/JOSA.62.000055, 1972
Image Restoration". JOSA 62 (1): 55-59. doi:10.1364/JOSA.62.000055, 1972
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to write DOI instead of doi. and the year before the DOI.

References
----------
.. [1] "Guided Image Filtering", by He et al. appearing in ECCV 2010.
http://research.microsoft.com/en-us/um/people/kahe/eccv10/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm correct, the correct paper is: DOI:10.1007/978-3-642-15549-9_1


def _guided_filter(image, guide, eta, radius):
""" Guided filtering on two distinct single channel float images."""
window_size = 2*radius + 1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some PEP8 fixes to bring in these function.

[ 0.10548081, 0.10548081, 0.10548081],
[ 0.82811797, 0.82811797, 0.82811797]]])
"""
if guide is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. as None is default, I would flip the position of this block with the elseblock to start with if guide is None

@sciunto
Copy link
Member

sciunto commented Apr 23, 2017

@soupault What do you wish to do with this PR? Would you want to work on further enhancements or do you prefer that we consider merging this code?

@soupault
Copy link
Member

@sciunto No, I just wanted to rebase the code, and perform the neccessary changes (PEP8-ify, refactor tests, move gallery example to the right place, etc). Pretty much done from my side (still need to fix failing docstring test).
I'd expect @SamHames to double check the implementation in the near time. Then we should consider merging the code.

@codecov-io
Copy link

Codecov Report

Merging #1104 into master will increase coverage by 0.04%.
The diff coverage is 98%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1104      +/-   ##
==========================================
+ Coverage   85.34%   85.38%   +0.04%     
==========================================
  Files         331      333       +2     
  Lines       26444    26543      +99     
==========================================
+ Hits        22568    22665      +97     
- Misses       3876     3878       +2
Impacted Files Coverage Δ
skimage/restoration/tests/test_guided.py 100% <100%> (ø)
skimage/restoration/__init__.py 100% <100%> (ø) ⬆️
skimage/restoration/_guided_filter.py 95.83% <95.83%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad9db13...ea83790. Read the comment docs.

Base automatically changed from master to main February 18, 2021 18:22
@SamHames SamHames closed this by deleting the head repository Oct 20, 2022
@stefanv
Copy link
Member

stefanv commented Oct 20, 2022

Looks like we dropped the ball here. I am sorry about that, @SamHames.

@stefanv
Copy link
Member

stefanv commented Oct 20, 2022

@soupault @grlee77 Any interest in salvaging this work?

@soupault
Copy link
Member

soupault commented Oct 22, 2022

I would say this is a classic algorithm and, definitely, is a good addition. I may pick this up later (no spare time currently). In any case, better to keep the PR open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants