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. |
Trims an image to the bounding rectangle about the images' main content using Canny edges as a measure of content detail. |
last modified: August 24, 2019
USAGE: trim2detail [-e edgewidth] [-t1 thresh1] [-t2 thresh2] [-p pad] [-a area]
infile outfile
-e .... edgewidth ... width (sigma) argument for Canny edge detection; float>0; default=1 PURPOSE: To trim an image to the bounding rectangle about the image's main content. DESCRIPTION: TRIM2DETAIL trims an image to the bounding rectangle about the images' main content using Canny edges as a measure of content detail. This script is only designed to work when the background region is of slowly varying content with little to no detail, such as gradual shadowing. ARGUMENTS: -e edgewidth ... EDGEWIDTH is the width argument for canny edge detection. Values are float>0. The default=1. -t1 thresh1 ... THRESH1 is the lower hysteresis (percent) threshold for canny edge detection. Values are 0<=integer<=100. The default=10. -t2 thresh2 ... THRESH2 is the lower hysteresis (percent) threshold for canny edge detection. Values are 0<=integer<=100. The default=30. -p pad ... PAD amount. Values are integer>=0. The default=5 -a area ... AREA of connected components in order to remove small regions. Values are integer>=0. The default=0. REQUIREMENTS: Requires Imagemagick 6.8.9-0 or higher for Canny edge detection. 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 |
Input |
Arguments: |
Example 2 |
Input |
Arguments: |
What the script does is as follows:
See the script for coding details |