
Image Blur Filter Kuwahara
The Kuwahara filter performs non-linear filtering of images while maintaining sharp edges. After filtering, the image looks like a roughly painted picture.

Filter mask

Suppose we have the task of finding reservoirs in space. At the pre-processing stage, it is necessary to clean the image from noise and make it smoother and more uniform. Moreover, information about the boundaries of objects in the image should be saved. Apply the kuwahara filter to the original image.
Original image

Kuwahara 21x21

After filtering, the borders became sharper, and you can apply some kind of contour filter to the image, for example, a Canny detector.
Canny detector applied after kuwahara filtering

For comparison, if we were to use a Gaussian filter as preprocessing, we would get the following images:
Gaussian filter 21x21


Although this is not the best filter to create a watercolor or gouache effect, in many cases, in my opinion, a very beautiful effect is obtained.
Original Image

Kuwahara 21x21


Algorithm
- In the vicinity of each pixel, apply a mask of size (2r + 1) * (2r + 1)
- The neighborhood is divided into 4 areas indicated by the numbers I, II, III, IV, size r * r
- Calculate the average intensity and variance in each of the areas I, II, III, IV
- Assign to the central pixel X the average value of the intensity of the region with the smallest dispersion
Filter mask

Application
Segmentation of homogeneous color areas
Suppose we have the task of finding reservoirs in space. At the pre-processing stage, it is necessary to clean the image from noise and make it smoother and more uniform. Moreover, information about the boundaries of objects in the image should be saved. Apply the kuwahara filter to the original image.
Original image

Kuwahara 21x21

After filtering, the borders became sharper, and you can apply some kind of contour filter to the image, for example, a Canny detector.
Canny detector applied after kuwahara filtering

For comparison, if we were to use a Gaussian filter as preprocessing, we would get the following images:
Gaussian filter 21x21


Apply a filter to create the effect of a painted picture
Although this is not the best filter to create a watercolor or gouache effect, in many cases, in my opinion, a very beautiful effect is obtained.
Original Image

Kuwahara 21x21

References
- Sources in java
- C ++ sources with opencv
- Homogeneous area segmentation article
- Images taken from google.com/maps , rsbweb.nih.gov , bobrolet.ru
- Images processed in an online photo editor