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. |
Isolates a contiguous region of an image based upon a color determined from a user specified image coordinate. |
last modified: December 15, 2018
USAGE: magicwand x,y [-t threshold] [-f format] [-r region] [-m mask] [-c color] [-o opacity] infile outfile
x,y .................. x,y location to get color and seed floodfill PURPOSE: To isolate a contiguous region of an image based upon a color determined from a user specified image coordinate. DESCRIPTION: MAGICWAND determines a contiguous region of an image based upon a color determined from a user specified image coordinate and a color similarity threshold value (fuzz factor). The output can be either an image or a mask. If the region is set to inside, then the image can be made to mask out the background as transparent, mask out the background using an opacity channel, fill the background with a color, display a boundary (outline) edge for the region or apply a translucent color layer over the background. If the region is set to outside, then the inside will be masked and the outside area will show normally. Alternately, the output can be a mask which is either binary (black and white), transparent (transparent and white) or a boundary edge (white on black background). The boundary edge can be made to match the interior or exterior depending upon the region setting. ARGUMENTS: x,y ... x,y are the coordinates in the image where the color is to be extracted and the floodfill is to be seeded. -f format ... FORMAT specifies whether the output will be the modified input image or a mask image. The choices are image or mask. The default is image. -r region ... REGION specifies whether the inside or outside are of the image will show and the other be masked out. The choices are inside or outside. The default is inside. -m mask ... MASK specifies the type of mask to use or create. The choices are transparent, binary, edge, overlay or layer. Only transparent, binary or edge masks will be allowed as output. With a transparent mask, the image will be modified to mask out the complement of the regions specified according to the color setting. Specify the color setting to 1) "trans" to make the background transparent, 2) "none" to mask by multiplying by the opacity setting or 3) a color value to use a fill color. With an overlay mask, which will only be effective on PNG format output images, the masking is done via the opacity channel using the opacity setting. With a layer mask, a translucent color will be layered over the background according to the color and opacity values. The larger the opacity, the lighter the color overlay and the more the image will show. -c color ... COLOR is the color to be used for the background fill or the boundary edge overlaid on the image. Any IM color specification is valid or a value of none. Be sure to enclose them in double quotes. The color value over-rides the opacity for mask=transparent, so use color="none" to allow the opacity to work or use color="trans" to make the background transparent. The default="black". -o opacity ... OPACITY controls the degree of transparency for the area that is masked out using a mask setting of transparent, overlay or layer. A value of zero is fully transparent and a value of 100 is fully opaque. 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. |
Image Modification |
||||
Original Image |
Arguments: |
Arguments: |
||
![]() |
![]() |
![]() |
||
Arguments: |
Arguments: |
Arguments: |
||
![]() |
![]() |
![]() |
||
Arguments: |
Arguments: |
Arguments: |
||
![]() |
![]() |
![]() |
||
Arguments: |
Arguments: |
|
||
![]() |
![]() |
Masks |
||||
Original Image |
Arguments: |
Arguments: |
||
![]() |
![]() |
![]() |
||
Arguments: |
Arguments: |
Arguments: |
||
![]() |
![]() |
![]() |
What the script does is as follows:
This is equivalent to the following IM commands for
|