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. |
Feathers (smoothes) the white-to-black transition in a binary mask image. |
last modified: December 15, 2018
USAGE: feather [-d distance] infile outfile -d ..... distance ..... feathering distance; distance>0; default=1 PURPOSE: To feather (smooth) the white-to-black transition in a binary mask image. DESCRIPTION: FEATHER smoothes the white-to-black transition in a binary mask image so that it can be used to composite one image over another in an antialiased manner. The feathering process makes a ramped grayscale transition over a short distance just inside the white region at the white-to-black transition in the binary mask. ARGUMENTS: -d distance ... DISTANCE specifies the distance (in pixels) over which the smoothing occurs at the white-to-black transition in the binary mask. Typically a value of one or two will suffice to anti-alias the rough transition so that the composite formed by using the feathered mask does not show the jagged edge of the overlay image on the background image. The value for distance should be kept small to avoid removing too much from the boundary of the overlay image. The default value is distance=1. 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. |
Feathering A Binary Mask |
|||
Binary Mask |
arguments: |
arguments: |
arguments: |
Compositing With Mask On Checker Background |
|||
Original Image |
Using Binary Mask |
Using Feathered Mask |
Using Feathered Mask |
Compositing With Mask On A Black Background |
|||
Original Image |
Using Binary Mask |
Using Feathered Mask |
Using Feathered Mask |
Mask Creation |
|
Original Image |
magicwand 0,0 -r outside -m binary \ |
magicwand 99,99 -r outside -m binary \ |
convert cyclops_mask1.png cyclops_mask2.png \ |
Alternate Mask Creation |
|
Original Image |
difference from background |
thresholded difference |
pad border to avoid bleeding |
morphologic close operation |
remove padding |
What the script does is as follows:
This is equivalent to the following IM commands for a feathering distance of 1.
|