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. |
Applies a contour outline to the image content. |
last modified: September 13, 2023
USAGE: contour [-t trim] [-T tolerance] [-d dilate] [-e erode] [-p pad]
[-i icolor] [-o ocolor] [-s shadow] [-r ramping] [-h highlight] [-m method]
[-f fuzzval] [-c coords] [-a area] [-v view] infile [maskfile] outfile
-t ... trim ........ preprocess trim to image content bounding box; PURPOSE: To apply a contour outline to the image content. DESCRIPTION: CONTOUR applies a contour outline to the image content. This is generate via a mask image. The mask image may come from the alpha channel of the input image, from a mask image or by a transparent floodfill or transparent recoloring operation. The background color may be selected along with the shadowing and highlight edge around the contour. ARGUMENTS: -t trim ... TRIM is the preprocess trim to image content bounding box. Choices are: yes (y) or no (n). The default=yes. -T tolerance ... TOLERANCE is the preprocessing trim tolerance percent (i.e., fuzz value). Values are 0<=integer<=100. The default=2. -d dilate ... DILATE distance is the contour dilate distance in pixels. Values are integer>=0. The default=20. The actual distance will be the difference between the dilate distance and the erode distance. Larger values for dilate help fill gaps. -e erode ... ERODE distance is the contour erode distance in pixels. Values are integer>=0. The default=0. The actual distance will be the difference between the dilate distance and the erode distance. -p pad ... PAD is the image pad amount after trimming. Value are integer>=0. The default is twice the contour distance to allow room for the shadow. -i icolor ... ICOLOR is the input image existing background color, which should be nearly a constant opaque color. This option is used only if the input image is opaque and no mask image is provided. The default=white. -o ocolor ... OCOLOR is the output image desired background color. Any IM opaque color is allowed. The default=white. -s shadow ... SHADOW brightness in percent. Values are 0<=integer<=100. The default=30. -r ramping ... RAMPING is the shadow ramping amount (blur sigma value). Values are integer>=0. The default=10. -h highlight ... HIGHLIGHT is a flag to show a black highlight edge around the contour. Values are on or off. The default=on. -f fuzzval ... FUZZVAL is the fuzz value for the floodfill. Value are 0<=integer<=100. The default=2. -m method ... METHOD of generating transparency when the input image has no alpha channel and there is no mask. Choices are: floodfill (f) and recolor (r). A choice of floodfill will not leave holes in the result. A choice of recolor may leave holes in the result, if there are content gaps larger than the contour distance and these are desired. The default=floodfill. -c coords ... COORDS are the coordinates to start the floodfill. They must be a comma separate pair of x,y values. The default=0,0 (upper left corner of the input image). -a area ... AREA of gaps to fill with connected-components. Values are integer pixels counts>=0 or integer percents>=0. The default=1%. -v view ... VIEW connected-components information. Choices are: yes or no. The default=no. 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. |
Example 1 - Extract Mask By Floodfill Of White Background |
Original Image |
Arguments: |
Arguments: |
Arguments: |
Example 2 - Extract Mask From Alpha Channel |
Original Image |
Arguments: |
Arguments: |
Example 3 - Mask Image Provided |
Original Image (source) |
Mask Image (source) |
Arguments: |
Example 4 - Extract Mask By Floodfill Black Background |
Original Image |
Arguments: |
Example 5 - Extract Mask By Floodfill White Background |
Original Image |
Arguments: |
Arguments: |
Arguments: |
Arguments: |
Example 6 - Extract Mask By Floodfill White Background |
Original Image |
Arguments: |
What the script does for m=morphology is as follows:
This is equivalent to the following IM commands when the image has no alpha channel or no mask.
|