SHARPEDGE

 Adaptively sharpens an image near edges.

EXAMPLES

 Adaptive Edge Sharpening - Variation In Edge Method Original Image Arguments: -k uniform -e 0 -f 2 -t 25 Arguments: -k uniform -e 1 -f 2 -t 25 Arguments: -k uniform -e 2 -f 2

 Adaptive Edge Sharpening - Variation In Gain Factor Original Image Arguments: -k uniform -e 0 -f 1 -t 25 Arguments: -k uniform -e 0 -f 2 -t 25 Arguments: -k uniform -e 0 -f 3 -t 25

 Adaptive Edge Sharpening - Variation Filter Kind Original Image Arguments: -k uniform -e 0 -f 2 -t 25 Arguments: -k binomial -e 0 -f 2 -t 25 Arguments: -k gaussian -w 1 -e 0 -f 2 -t 25

 What the script does is as follows: Computes a local mean image using a (weighted) average convolution. Computes a local standard deviation image using the input image and the local mean image. Thresholds the local standard deviation image to create an edge mask image. Computes a gain image using the local standard deviation image and the global standard deviation of the image. Combines the local mean image and the product of the local gain image times the difference between the input image and the local mean image. This creates an image that is sharpened everywhere. Composites the original image and the sharpened image using the edge mask image. This is equivalent to the following IM commands for the case of adaptive edge sharpening (-k uniform -e 0 -f 5 -t 25): ave="1,1,1,1,1,1,1,1,1" convert \$infile -convolve "\$ave" \$tmpM convert \( \$infile \$infile -compose multiply -composite -convolve "\$ave" \) \ \( \$tmpM \$tmpM -compose multiply -composite \) +swap \ -compose minus -composite -fx "sqrt(u)" \$tmpS convert \$tmpS -colorspace Gray -blur 0x1 -contrast-stretch 0% -black-threshold \$thresh% \$tmp0 std=`echo "\$data" | sed -n '/^.*Standard.*[(]\([0-9.]*\).*\$/{ s//\1/; p; q; }'` std=`echo "scale=1; \$std * 100 / 1" | bc` dstd=`echo "scale=5; \$factor * \$std / 100" | bc` dsdmg=`echo "scale=5; \$dstd / \$mg" | bc` gain="gn=(\$dstd)/(u[2]+(\$dsdmg));" convert \$infile \$tmpM \$tmpS -fx "\$gain (u+(gn*(u-v)))" \$tmp2 convert \$infile \$tmp2 \$tmp1 -composite \$outfile