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.
Suppose that is a grey scale image and that we take a square window of size centered around a point in the image. This square can be divided into four smaller square regions each of which will be [1]
where is the cartesian product. Pixels located on the borders between two regions belong to both regions so there is a slight overlap between subregions.
The arithmetic mean and standard deviation of the four regions centered around a pixel (x,y) are calculated and used to determine the value of the central pixel. The output of the Kuwahara filter for any point is then given by where .
This means that the central pixel will take the mean value of the area that is most homogenous. The location of the pixel in relation to an edge plays a great role in determining which region will have the greater standard deviation. If for example the pixel is located on a dark side of an edge it will most probably take the mean value of the dark region. On the other hand, should the pixel be on the lighter side of an edge it will most probably take a light value. On the event that the pixel is located on the edge it will take the value of the more smooth, least textured region. The fact that the filter takes into account the homogeneity of the regions ensures that it will preserve the edges while using the mean creates the blurring effect.
Similarly to the median filter the Kuwahara filter uses a sliding window approach to access every pixel in the image. The size of the window is chosen in advance and may vary depending on the desired level of blur in the final image. Bigger windows typically result in the creation of more abstract images whereas small windows produce images that retain their detail. Typically windows are chosen to be square with sides that have an odd number of pixels for symmetry. However, there are variations of the Kuwahara filter that use rectangular windows. Additionally, the subregions do not need to overlap or have the same size as long as they cover all of the window.
For color images, the filter should not be performed by applying the filter to each RGB channel separately, and then recombining the three filtered color channels to form the filtered RGB image. The main problem with that is that the quadrants will have different standard deviations for each of the channels. For example, the upper left quadrant may have the lowest standard deviation in the red channel, but the lower right quadrant may have the lowest standard deviation in the green channel. This situation would result in the color of the central pixel to be determined by different regions, which might result in color artifacts or blurrier edges.
To overcome this problem, for color images a slightly modified Kuwahara filter must be used. The image is first converted into another color space, the HSV color space. The modified filter then operates on only the "brightness" channel, the Value coordinate in the HSV model. The variance of the "brightness" of each quadrant is calculated to determine the quadrant from which the final filtered color should be taken from. The filter will produce an output for each channel which will correspond to the mean of that channel from the quadrant that had the lowest standard deviation in "brightness". This ensures that only one region will determine the RGB values of the central pixel.
ImageMagick uses a similar approach, but using the Rec. 709 Luma as the brightness metric. [2]
usingStatisticsusingImages"Computes an average color from a list of colors"rgbAverage(colors)=RGB(sum(map(c->c.r,colors))/length(colors),sum(map(c->c.g,colors))/length(colors),sum(map(c->c.b,colors))/length(colors));""" kuwahara(I, window_size)Applies the kuwahara filter to an image `I`, using a window square of size `window_size`"""functionkuwahara(I,window_size)# Converts the image to a hsv colorspace# (needed to run on colored images)hsv=HSV.(I)# Gets the brightness value as values[y, x]values=channelview(float.(hsv))[3,:,:]# For Rec.601 Luma, replace the above two lines with:# values = Gray.(I)# Create an empty image of the same dimensions as the inputresulting_image=similar(I)# The size of each quadrant of the windowquadrant_size=Int(ceil(window_size/2))# (y, x) loop over the original imageforyin1:size(I,1)forxin1:size(I,2)# The top left position of the windowtl_x=x-(window_size÷2)tl_y=y-(window_size÷2)# Function that keeps a number between 1 and the image size# (makes sure all the positions we're using are valid)c1(i)=map(j->clamp(j,1,size(values,1)),i)c2(i)=map(j->clamp(j,1,size(values,2)),i)# The positions of each quadrantquadrant_a=[c1(tl_y:quadrant_size+tl_y),c2(tl_x:tl_x+quadrant_size)]quadrant_b=[c1(tl_y:quadrant_size+tl_y),c2(tl_x+quadrant_size:tl_x+window_size)]quadrant_c=[c1(tl_y+quadrant_size:tl_y+window_size),c2(tl_x:tl_x+quadrant_size)]quadrant_d=[c1(tl_y+quadrant_size:tl_y+window_size),c2(tl_x+quadrant_size:tl_x+window_size)]# Standard deviation of each quadrantσ_a=std(values[quadrant_a...])σ_b=std(values[quadrant_b...])σ_c=std(values[quadrant_c...])σ_d=std(values[quadrant_d...])# Select the quadrant with the smallest standard deviationquadrants=[quadrant_a,quadrant_b,quadrant_c,quadrant_d]min=argmin([σ_a,σ_b,σ_c,σ_d])quadrant=quadrants[min]# The pixel we're processing receives the average of the quadrantpixels=I[quadrant...]resulting_image[y,x]=rgbAverage(pixels)endendreturnresulting_imageend# Test code with a sample imageurl="https://upload.wikimedia.org/wikipedia/commons/7/73/Lion_waiting_in_Namibia.jpg"download(url,"lion.jpg")img=load("lion.jpg")window_size=13result=kuwahara(img,window_size)save("result.png",result)
Originally the Kuwahara filter was proposed for use in processing RI-angiocardiographic images of the cardiovascular system. [3] 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. [4]
The Kuwahara filter despite its capabilities in edge preservation has certain drawbacks.
The success of the Kuwahara filter has spurred an increase the development of edge-enhancing smoothing filters. Several variations have been proposed for similar use most of which attempt to deal with the drawbacks of the original Kuwahara filter.
The "Generalized Kuwahara filter" proposed by P. Bakker [7] considers several windows that contain a fixed pixel. Each window is then assigned an estimate and a confidence value. The value of the fixed pixel then takes the value of the estimate of the window with the highest confidence. This filter is not characterized by the same ambiguity in the presence of noise and manages to eliminate the block artifacts.
The "Mean of Least Variance"(MLV) filter, proposed by M.A. Schulze [8] also produces edge-enhancing smoothing results in images. Similarly to the Kuwahara filter it assumes a window of size but instead of searching amongst four subregions of size for the one with minimum variance it searches amongst all possible subregions. This means the central pixel of the window will be assigned the mean of the one subregion out of a possible that has the smallest variance.
The "Adaptative Kuwahara filter", proposed by K. Bartyzel, [9] is a combination of the anisotropic Kuwahara filter and the adaptative median filter. In comparison with the standard Kuwahara filter, both the objects and the edges retain a better quality. As opposed to the standard Kuwahara filter, the window size is changing, depending on the local properties of the image. For each of the four basic areas surrounding a pixel, the mean and variance are calculated. Then, the window size of each of the four basic areas is increased by 1. If the variance of a new window is smaller than before the resizing of the filter window, then the mean and variance of the basic area will take the newly calculated values. The window size continues to be increased until the new variance is greater than the previous one, or the maximum allowable window size is reached. The variance of the four areas are then compared, and the value of the output pixel is the average value of the basic area for which the variance was the smallest.
A more recent attempt in edge-enhancing smoothing was also proposed by J. E. Kyprianidis. [6] The filter's output is a weighed sum of the local averages with more weight given the averages of more homogenous regions.
In probability theory and statistics, kurtosis is a measure of the "tailedness" of the probability distribution of a real-valued random variable. Like skewness, kurtosis describes a particular aspect of a probability distribution. There are different ways to quantify kurtosis for a theoretical distribution, and there are corresponding ways of estimating it using a sample from a population. Different measures of kurtosis may have different interpretations.
In statistics, the standard deviation is a measure of the amount of variation of a random variable expected about its mean. A low standard deviation indicates that the values tend to be close to the mean of the set, while a high standard deviation indicates that the values are spread out over a wider range. The standard deviation is commonly used in the determination of what constitutes an outlier and what does not.
In probability theory and statistics, variance is the expected value of the squared deviation from the mean of a random variable. The standard deviation (SD) is obtained as the square root of the variance. Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers is spread out from their average value. It is the second central moment of a distribution, and the covariance of the random variable with itself, and it is often represented by , , , , or .
In statistics, the Pearson correlation coefficient (PCC) is a correlation coefficient that measures linear correlation between two sets of data. It is the ratio between the covariance of two variables and the product of their standard deviations; thus, it is essentially a normalized measurement of the covariance, such that the result always has a value between −1 and 1. As with covariance itself, the measure can only reflect a linear correlation of variables, and ignores many other types of relationships or correlations. As a simple example, one would expect the age and height of a sample of teenagers from a high school to have a Pearson correlation coefficient significantly greater than 0, but less than 1.
In probability theory and statistics, the Rayleigh distribution is a continuous probability distribution for nonnegative-valued random variables. Up to rescaling, it coincides with the chi distribution with two degrees of freedom. The distribution is named after Lord Rayleigh.
The Canny edge detector is an edge detection operator that uses a multi-stage algorithm to detect a wide range of edges in images. It was developed by John F. Canny in 1986. Canny also produced a computational theory of edge detection explaining why the technique works.
The standard error (SE) of a statistic is the standard deviation of its sampling distribution or an estimate of that standard deviation. If the statistic is the sample mean, it is called the standard error of the mean (SEM). The standard error is a key ingredient in producing confidence intervals.
In probability theory and statistics, the coefficient of variation (CV), also known as Normalized Root-Mean-Square Deviation (NRMSD), Percent RMS, and relative standard deviation (RSD), is a standardized measure of dispersion of a probability distribution or frequency distribution. It is defined as the ratio of the standard deviation to the mean , and often expressed as a percentage ("%RSD"). The CV or RSD is widely used in analytical chemistry to express the precision and repeatability of an assay. It is also commonly used in fields such as engineering or physics when doing quality assurance studies and ANOVA gauge R&R, by economists and investors in economic models, and in psychology/neuroscience.
In image processing, a Gaussian blur is the result of blurring an image by a Gaussian function.
The median filter is a non-linear digital filtering technique, often used to remove noise from an image or signal. Such noise reduction is a typical pre-processing step to improve the results of later processing. Median filtering is very widely used in digital image processing because, under certain conditions, it preserves edges while removing noise, also having applications in signal processing.
The structural similarityindex measure (SSIM) is a method for predicting the perceived quality of digital television and cinematic pictures, as well as other kinds of digital images and videos. It is also used for measuring the similarity between two images. The SSIM index is a full reference metric; in other words, the measurement or prediction of image quality is based on an initial uncompressed or distortion-free image as reference.
In imaging science, difference of Gaussians (DoG) is a feature enhancement algorithm that involves the subtraction of one Gaussian blurred version of an original image from another, less blurred version of the original. In the simple case of grayscale images, the blurred images are obtained by convolving the original grayscale images with Gaussian kernels having differing width. Blurring an image using a Gaussian kernel suppresses only high-frequency spatial information. Subtracting one image from the other preserves spatial information that lies between the range of frequencies that are preserved in the two blurred images. Thus, the DoG is a spatial band-pass filter that attenuates frequencies in the original grayscale image that are far from the band center.
Block Truncation Coding (BTC) is a type of lossy image compression technique for greyscale images. It divides the original images into blocks and then uses a quantizer to reduce the number of grey levels in each block whilst maintaining the same mean and standard deviation. It is an early predecessor of the popular hardware DXTC technique, although BTC compression method was first adapted to color long before DXTC using a very similar approach called Color Cell Compression. BTC has also been adapted to video compression.
In electronics and signal processing, mainly in digital signal processing, a Gaussian filter is a filter whose impulse response is a Gaussian function. Gaussian filters have the properties of having no overshoot to a step function input while minimizing the rise and fall time. This behavior is closely connected to the fact that the Gaussian filter has the minimum possible group delay. A Gaussian filter will have the best combination of suppression of high frequencies while also minimizing spatial spread, being the critical point of the uncertainty principle. These properties are important in areas such as oscilloscopes and digital telecommunication systems.
The root-mean-square deviation (RMSD) or root-mean-square error (RMSE) is either one of two closely related and frequently used measures of the differences between true or predicted values on the one hand and observed values or an estimator on the other.
In statistics and in particular statistical theory, unbiased estimation of a standard deviation is the calculation from a statistical sample of an estimated value of the standard deviation of a population of values, in such a way that the expected value of the calculation equals the true value. Except in some important situations, outlined later, the task has little relevance to applications of statistics since its need is avoided by standard procedures, such as the use of significance tests and confidence intervals, or by using Bayesian analysis.
In regression, mean response and predicted response, also known as mean outcome and predicted outcome, are values of the dependent variable calculated from the regression parameters and a given value of the independent variable. The values of these two responses are the same, but their calculated variances are different. The concept is a generalization of the distinction between the standard error of the mean and the sample standard deviation.
Non-local means is an algorithm in image processing for image denoising. Unlike "local mean" filters, which take the mean value of a group of pixels surrounding a target pixel to smooth the image, non-local means filtering takes a mean of all pixels in the image, weighted by how similar these pixels are to the target pixel. This results in much greater post-filtering clarity, and less loss of detail in the image compared with local mean algorithms.
Foreground detection is one of the major tasks in the field of computer vision and image processing whose aim is to detect changes in image sequences. Background subtraction is any technique which allows an image's foreground to be extracted for further processing.
A guided filter is an edge-preserving smoothing image filter. As with a bilateral filter, it can filter out noise or texture while retaining sharp edges.