Copyright © Fred Weinhaus My scripts are available free of charge for non-commercial (non-profit) use, ONLY. For use of my scripts in commercial (for-profit) environments or non-free applications, please contact me (Fred Weinhaus) for licensing arrangements. My email address is fmw at alink dot net. If you: 1) redistribute, 2) incorporate any of these scripts into other free applications or 3) reprogram them in another scripting language, then you must contact me for permission, especially if the result might be used in a commercial or for-profit environment. Usage, whether stated or not in the script, is restricted to the above licensing arrangements. It is also subject, in a subordinate manner, to the ImageMagick license, which can be found at: http://www.imagemagick.org/script/license.php Please read the Pointers For Use on my home page to properly install and customize my scripts. |
Applies a Kuwahara type edge preserving noise reduction filter to an image. |
last modified: December 15, 2018
USAGE: kuwahara [-d dimension] [-m method] [-s smoothing] infile outfile
-d ... dimension ... square window dimension; integer>=2; default=3 PURPOSE: To apply a Kuwahara type edge preserving noise reduction filter to an image. DESCRIPTION: KUWAHARA applies a Kuwahara type edge preserving noise reduction filter to an image. The basic Kuwahara filter does the following. For each pixel in the image, the four diagonal neighboring square sized windows (northwest, northeast, southeast and soutwest) that overlap with the pixel at their corners are processed to get their mean and standard deviation. The output image has the corresponding pixel filled with the mean of the four window that has the smallest standard deviation, i.e. the smoothest window. I have modified this approach in several ways. First, I use the eight neighboring windows that overlap the pixel coordinate (northwest, north, northeast, east, southeast, south, southwest and west). Second, I allow three different methods to compute the mean and standard deviation. Method 1 uses a square uniformly weighted mean and corresponding standard deviation. This is the traditional approach. Method 2 uses a circular Gaussian weighted mean within the square window and corresponding standard deviation. Method 3 uses the circular Gaussian weighted approach to compute the standard deviation, but uses a square window median value. Arguments: -d dimension ... DIMENSION is the square window dimension. Values are integer>=2. Nominal values are in the range of 2 to 4. The default=3. Values larger than 4 may cause jagged, flat regions. -m method ... METHOD is the method of processing. The choices are: 1=mean, 2=gaussian mean, 3=median. The default=2. -s smoothing ... SMOOTHING is the smoothing factor for method 2 only. Values are float>=1. Nominal values are between 1 and 2. The default=1. The larger the value the more smoothing. References: http://en.wikipedia.org/wiki/Kuwahara_filter CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
Example 1 -- Variation In Dimension (For Different Methods) |
||
Original Image |
||
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Example 2 -- Variation Smoothing |
||
Original Image |
||
Arguments: |
Arguments: |
Arguments: |
Example 2 -- Variation In Dimension |
||
Original Image |
Gaussian Noise Added Image |
|
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
What the script does is as follows:
See the script for code details |