Fred's ImageMagick Scripts
|
Feathers (smoothes) the white-to-black transition in a binary mask image. |
last modified: May 30, 2008
|
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.
|