The Kuwahara filter is a non-linear smoothing filter used in image processing for adaptive noise reduction. Most filters that are used for image smoothing are linear low-pass filters that effectively reduce noise but also blur out the edges. However the Kuwahara filter is able to apply smoothing on the image while preserving the edges.
It is named after Michiyoshi Kuwahara, Ph.D., who worked at Kyoto and Osaka Sangyo Universities in Japan, developing early medical imaging of dynamic heart muscle in the 1970s and 80s.
Kuwahara Filter description#
The Kuwahara filter works on a window divided into 4 overlapping sub-windows. In each sub-window, the mean and variance are computed.
The output value (located at the center of the window) is set to the mean of the sub-window with the smallest variance.
Applications#
Originally the Kuwahara filter was proposed for use in processing RI-angiocardiographic images of the cardiovascular system.
The fact that any edges are preserved when smoothing makes it especially useful for feature extraction and segmentation and explains why it is used in medical imaging.
The Kuwahara filter however also finds many applications in artistic imaging and fine-art photography due to its ability to remove textures and sharpen the edges of photographs. The level of abstraction helps create a desirable painting-like effect in artistic photographs especially in the case of the colored image version of the filter. These applications have known great success and have encouraged similar research in the field of image processing for the arts.
Although the vast majority of applications have been in the field of image processing there have been cases that use modifications of the Kuwahara filter for machine learning tasks such as clustering.
The Kuwahara filter has been implemented in CVIPtools.
Anisotropic Kuwahara Filtering with Polynomial Weighting Functions Paper#
The Anisotropic Kuwahara Paper link
Kuwahara was the world’s first edge preserving de-noising image processing algorithm. It was upgraded by the “Anisotropic Kuwahara Filtering with Polynomial Weighting Functions” paper, by:
- Upgraded by using a circular kernel instead of Box kernel.
- Instead of using naive weights, we use gaussian weights.
- This new formula: 1/(1+std_div), sector color = Ki, K(x)=(sum of Ki * Wi)/(sum of weights i)
This removes indeterminate behavior and removes all conditional logic of the old algorithm. All these changes were made by Guiseppe Papari.
Thankfully we can just ditch the Gauss and instead approximate the weight using “Polynomials”.
Then we’ll calculate the Eigen-Values. To calculate the Eigen-Values of the structure tensor and use them to calculate the eigenvectors that points in the direction of the minimum rate of change. We’re just essentially figuring out what direction a pixel points in using the eigenvector information.
The filter kernel can now angle itself and stretch itself to better fit image details and edges.
This new filter is called Anisotropic Kuwahara Filter.
Recommendation: In-order to achieve High Contrast Visuals, it is better to apply the anisotropic kuwahara then apply the dither effect.
My Personal Optimized Implementation of Kuwahara filter#
Personal Implementation
The Kuwahara filter is a non-linear filter used for image smoothing while preserving edges. It divides the image into overlapping square regions and computes the mean and variance of pixel values within each region. Then, it selects the region with the smallest variance and replaces all pixels within that region with the mean value of those pixels.