-
Notifications
You must be signed in to change notification settings - Fork 149
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
Color Bilateral Filter #606
Conversation
Thanks, this is a nice function to have. I’ll review it this weekend. The old function looks to have a very similar structure to yours except for using lookup tables for both colour and distance weights. |
Using a lookup table for non-greyscale becomes a much trickier as there are many many different combinations. Also the old version only allowed Gaussian Euclidean similarity but this version allows user-specified Similarity which also makes creating a lookup table more difficult. |
4f67242
to
18cec90
Compare
All comments raised have been addressed and #620 opened for the non-related changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks almost good to go - just one bug I’ve spotted.
use super::*; | ||
|
||
#[test] | ||
fn test_bilateral_filter_greyscale() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s leave this test input and expectations the same as it was before as a sanity check - a new implementation shouldn’t change the output values enough to make this fail
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left the input image and input parameters the same or as their equivalents since switching from window_size
to radius
, hence 3 -> 1, but I think rounding differences in the new implementation are causing the output to change slightly. From my testing it still looks to be giving the same output as shown in the images I posted so I'm fairly confident it's doing the right thing overall.
Thanks! |
This PR expands the implementation of
bilateral_filter()
to any pixel type includingRgb
by using aColorSimilarity
trait which allows arbitrary user defined metrics to be used. Another traitWeightedAverage
was needed in order to allow the implementation to work with any pixel type.It's mildly slower than the old version on greyscale images from my testing which was annoying but I can barely even understand the old version as the variable naming was very poor. I think this kind of function can be easily parallelized though which would make it tons faster than the old version.