Closed ripytide closed 3 months ago
Here is an example of it in action:
Before:
After:
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.
All comments raised have been addressed and #620 opened for the non-related changes.
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.