Fred's ImageMagick Scripts
|
Adaptively sharpens an image or extract edges. |
last modified: June 27, 2008
|
USAGE: sharp [-m method] [-s sharpen] infile outfile
-m ............ method ....... method=0 is edge extract; method=1 is sharpen PURPOSE: To sharpen an image or extract edges adaptively. DESCRIPTION: SHARP is an adaptive technique to either sharpen an image or extract edges. It applies an adaptive gain factor based upon the image's local standard deviation to a high pass filtered version of the image and adds that to a low pass filtered version of the image. The adaptive formula R = method*M + G*H. Here R is the resulting image. M is the low pass filtered image which is the local mean image generated by applying a 3x3 average convolution to the input image, I. H = (I - M) is the high pass filtered image. G is the gain image, which is computed as G = (factor*std)/(S + (factor*std/mg)). Here std is the image's global standard deviation, mg is a maximum gain constant and S is the image's local standard deviation in the 3x3 neighborhood. ARGUMENTS: -m method - method is either 0 or 1. A value of 0 for method indicates edge extraction and value of 1 for method indicates sharpening. The default=1. -f factor factor is the sharpening/edge extraction gain factor. It is a multiplier to the image's actual standard deviation. The value for factor must be greater than or equal to 0. A value of about 0.5 leaves the image nearly unchanged. A smaller value blurs the image or extract more edges. A larger value sharpens the image or extracts fewer edges. This transition value is not exact and is likely image statistics dependent as the result is a mix of the low pass filtered image (not the original image) and the adaptive high pass filtered image. Factor is floating point number. The default=2. 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. |
|
Adaptive Sharpening/Blurring Of A True Color Image |
||||
|
Original Image |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
|
|
Adaptive Edge Extraction From A Grayscale Image |
||||
|
Original Image |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
|
|
What the script does is as follows:
This is equivalent to the following IM commands for
|